bolt_proto/message/
route.rs1use std::collections::HashMap;
2
3use bolt_proto_derive::*;
4
5use crate::{impl_try_from_message, message::SIGNATURE_ROUTE, Value};
6
7#[bolt_structure(SIGNATURE_ROUTE)]
8#[derive(Debug, Clone, Eq, PartialEq)]
9pub struct Route {
10 pub(crate) context: HashMap<String, Value>,
11 pub(crate) bookmarks: Vec<String>,
12 pub(crate) database: Value,
13}
14
15impl Route {
16 pub fn new(
17 context: HashMap<String, Value>,
18 bookmarks: Vec<String>,
19 database: Option<String>,
20 ) -> Self {
21 Self {
22 context,
23 bookmarks,
24 database: Value::from(database),
25 }
26 }
27
28 pub fn context(&self) -> &HashMap<String, Value> {
29 &self.context
30 }
31
32 pub fn bookmarks(&self) -> &[String] {
33 &self.bookmarks
34 }
35
36 pub fn database(&self) -> &Value {
37 &self.database
38 }
39}
40
41impl_try_from_message!(Route, Route);