mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-19 15:31:19 +02:00
Refactor into grpc events
This commit is contained in:
16
src-tauri/src/grpc.rs
Normal file
16
src-tauri/src/grpc.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use KeyAndValueRef::{Ascii, Binary};
|
||||
|
||||
use grpc::{KeyAndValueRef, MetadataMap};
|
||||
|
||||
pub fn metadata_to_map(metadata: MetadataMap) -> HashMap<String, String> {
|
||||
let mut entries = HashMap::new();
|
||||
for r in metadata.iter() {
|
||||
match r {
|
||||
Ascii(k, v) => entries.insert(k.to_string(), v.to_str().unwrap().to_string()),
|
||||
Binary(k, v) => entries.insert(k.to_string(), format!("{:?}", v)),
|
||||
};
|
||||
}
|
||||
entries
|
||||
}
|
||||
Reference in New Issue
Block a user