pub struct GbpFrame {
pub version: u8,
pub group_id: ByteBuf,
pub epoch: u64,
pub transition_id: u32,
pub stream_type: u8,
pub stream_id: u32,
pub flags: u16,
pub sequence_no: u32,
pub payload_size: u32,
pub encrypted_payload: ByteBuf,
}Expand description
CBOR-encoded GBP frame.
Fields§
§version: u8Protocol version (currently 1).
group_id: ByteBuf16-byte group identifier.
epoch: u64Sender’s current epoch.
transition_id: u32Last applied transition_id.
stream_type: u8StreamType as a u8 (see gbp_core::StreamType).
stream_id: u32Logical stream identifier within the session.
flags: u16Delivery flags (see gbp_core::GbpFlags).
sequence_no: u32Per-stream sequence number (replay window key).
payload_size: u32Declared payload length; MUST equal encrypted_payload.len().
encrypted_payload: ByteBufEncrypted payload (an opaque byte string).
Implementations§
Source§impl GbpFrame
impl GbpFrame
Sourcepub fn new(
group_id: GroupId,
epoch: u64,
transition_id: u32,
stream_type: StreamType,
stream_id: u32,
flags: u16,
sequence_no: u32,
encrypted_payload: Vec<u8>,
) -> Self
pub fn new( group_id: GroupId, epoch: u64, transition_id: u32, stream_type: StreamType, stream_id: u32, flags: u16, sequence_no: u32, encrypted_payload: Vec<u8>, ) -> Self
Builds a frame from already-encrypted payload bytes.
payload_size is set to encrypted_payload.len() automatically.
Sourcepub fn to_cbor(&self) -> Vec<u8> ⓘ
pub fn to_cbor(&self) -> Vec<u8> ⓘ
Serialises the frame into a freshly allocated CBOR byte vector.
Sourcepub fn from_cbor(data: &[u8]) -> Result<Self, CodecError>
pub fn from_cbor(data: &[u8]) -> Result<Self, CodecError>
Decodes a CBOR-encoded frame and validates payload_size.
Sourcepub fn stream_type_typed(&self) -> Result<StreamType, CodecError>
pub fn stream_type_typed(&self) -> Result<StreamType, CodecError>
Returns the typed StreamType, or CodecError::UnknownEnumValue for
unknown stream classes.
Sourcepub fn group_id_array(&self) -> GroupId
pub fn group_id_array(&self) -> GroupId
Returns group_id as a 16-byte array, padding with zeros or
truncating if necessary.