pub enum Protocol {
NewStream {
full: Bytes,
pub_key: Bytes,
base_msg: Bytes,
header: Bytes,
},
Message {
full: Bytes,
pub_key: Bytes,
base_msg: Bytes,
message: Bytes,
},
RequestNewStream {
full: Bytes,
pub_key: Bytes,
base_msg: Bytes,
},
}Expand description
E2e crypto protocol enum.
The enum variant fields are all shallow clone parts of the “full” field:
fullthe entire message send/recv via sbd-client.pub_keythe pub_key peer send/recv to/from.base_msgthe base message send/recv to/from the peer....all additional fields are broken out by enum variant.
Variants§
NewStream
Message indicating a new stream state should be created along with the secretstream header for doing so.
Message
An encrypted message.
RequestNewStream
Request for a new decryption stream state.
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn from_full(full: Bytes) -> Option<Self>
pub fn from_full(full: Bytes) -> Option<Self>
Parse a protocol message from complete message bytes. If None, this message should be ignored.
Sourcepub fn new_stream(pub_key: &[u8], header: &[u8]) -> Self
pub fn new_stream(pub_key: &[u8], header: &[u8]) -> Self
Create a “NewStream” message type.
Panics if the pub_key is not 32 bytes or the header is not 24.
Why not take a &[u8; N] you ask? It’s just a lot harder to work
with in rust…
Sourcepub fn message(pub_key: &[u8], message: &[u8]) -> Self
pub fn message(pub_key: &[u8], message: &[u8]) -> Self
Create a “Message” message type.
Panics if the pub_key is not 32 bytes.
Why not take a &[u8; N] you ask? It’s just a lot harder to work
with in rust…
Sourcepub fn request_new_stream(pub_key: &[u8]) -> Self
pub fn request_new_stream(pub_key: &[u8]) -> Self
Create a “RequestNewStream” message type.
Panics if the pub_key is not 32 bytes.
Why not take a &[u8; N] you ask? It’s just a lot harder to work
with in rust…