brainwires_agent_network/
connection.rs1use serde_json::Value;
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Default)]
6pub struct ClientInfo {
7 pub name: String,
9 pub version: String,
11}
12
13#[derive(Debug, Clone)]
15pub struct RequestContext {
16 pub client_info: Option<ClientInfo>,
18 pub request_id: Value,
20 pub initialized: bool,
22 pub metadata: HashMap<String, Value>,
24}
25
26impl RequestContext {
27 pub fn new(request_id: Value) -> Self {
29 Self {
30 client_info: None,
31 request_id,
32 initialized: false,
33 metadata: HashMap::new(),
34 }
35 }
36
37 pub fn with_client_info(mut self, info: ClientInfo) -> Self {
39 self.client_info = Some(info);
40 self
41 }
42
43 pub fn set_initialized(&mut self) {
45 self.initialized = true;
46 }
47
48 pub fn get_metadata(&self, key: &str) -> Option<&Value> {
50 self.metadata.get(key)
51 }
52
53 pub fn set_metadata(&mut self, key: String, value: Value) {
55 self.metadata.insert(key, value);
56 }
57}