ocapn_netlayer/
message.rs

1use ocapn_syrup::Value;
2
3use crate::crypto::{PublicKey, Signature};
4use crate::locator::Peer;
5
6// TODO: implement From<T> for Value, for all these; implement Serializer from that From
7// TODO: is there a way to "impl Serializer for From<T>" because it's a lotta boilerplate?
8
9pub struct StartSession {
10    pub captp_version: String,
11    pub session_pubkey: PublicKey,
12    pub acceptable_location: Peer,
13    pub acceptable_location_sig: Signature,
14}
15
16pub struct Abort {
17    pub reason: String,
18}
19
20pub struct DeliverOnly<T: ObjectArgs> {
21    pub to_desc: Descriptor,
22    pub args: ObjectMethod<T>,
23    // TODO: what goes in here?
24}
25
26pub struct Deliver<T: ObjectArgs> {
27    pub to_desc: Descriptor,
28    pub args: ObjectMethod<T>,
29    pub answer_pos: Option<u32>,
30    pub resolve_me_desc: Descriptor,
31}
32
33pub struct Listen {
34    pub to_desc: Descriptor,
35    pub listen_desc: Descriptor,
36    pub wants_partial: bool,
37}
38
39pub enum Descriptor {
40    ImportObject(u32),
41    ImportPromise(u32),
42    Export(u32),
43}
44
45pub struct ObjectMethod<T: ObjectArgs> {
46    pub name: String,
47    pub args: T,
48}
49
50pub trait ObjectArgs: Into<Vec<Value>> {}
51
52pub struct GcExport {
53    pub export_pos: u32,
54    pub wire_delta: u32,
55}