pub struct Bundle {
pub primary: PrimaryBlock,
pub canonicals: Vec<CanonicalBlock>,
}
Expand description
Bundle represents a bundle as defined in section 4.2.1. Each Bundle contains one primary block and multiple canonical blocks.
Fields
primary: PrimaryBlock
canonicals: Vec<CanonicalBlock>
Implementations
sourceimpl Bundle
impl Bundle
pub fn new(primary: PrimaryBlock, canonicals: Vec<CanonicalBlock>) -> Bundle
sourcepub fn validate(&self) -> Result<(), ErrorList>
pub fn validate(&self) -> Result<(), ErrorList>
Validate bundle and optionally return list of errors.
sourcepub fn sort_canonicals(&mut self)
pub fn sort_canonicals(&mut self)
Sort canonical blocks by block number
sourcepub fn add_canonical_block(&mut self, cblock: CanonicalBlock)
pub fn add_canonical_block(&mut self, cblock: CanonicalBlock)
Automatically assign a block number and add canonical block to bundle
sourcepub fn is_administrative_record(&self) -> bool
pub fn is_administrative_record(&self) -> bool
Checks whether the bundle is an administrative record
sourcepub fn payload(&self) -> Option<&ByteBuffer>
pub fn payload(&self) -> Option<&ByteBuffer>
Return payload of bundle if an payload block exists and carries data.
sourcepub fn set_payload_block(&mut self, payload: CanonicalBlock)
pub fn set_payload_block(&mut self, payload: CanonicalBlock)
Sets or updates the payload block
sourcepub fn set_payload(&mut self, payload: ByteBuffer)
pub fn set_payload(&mut self, payload: ByteBuffer)
Sets or updates the payload
sourcepub fn set_crc(&mut self, crc_type: CrcRawType)
pub fn set_crc(&mut self, crc_type: CrcRawType)
Sets the given CRCType for each block. The crc value is calculated on-the-fly before serializing.
sourcepub fn crc_valid(&mut self) -> bool
pub fn crc_valid(&mut self) -> bool
Check whether a bundle has only valid CRC checksums in all blocks.
sourcepub fn calculate_crc(&mut self)
pub fn calculate_crc(&mut self)
Calculate crc for all blocks.
sourcepub fn extension_block_by_type(
&self,
block_type: CanonicalBlockType
) -> Option<&CanonicalBlock>
pub fn extension_block_by_type(
&self,
block_type: CanonicalBlockType
) -> Option<&CanonicalBlock>
Get first extension block matching the block type
sourcepub fn extension_block_by_type_mut(
&mut self,
block_type: CanonicalBlockType
) -> Option<&mut CanonicalBlock>
pub fn extension_block_by_type_mut(
&mut self,
block_type: CanonicalBlockType
) -> Option<&mut CanonicalBlock>
Get mutable reference for first extension block matching the block type
sourcepub fn to_cbor(&mut self) -> ByteBuffer
pub fn to_cbor(&mut self) -> ByteBuffer
Serialize bundle as CBOR encoded byte buffer.
sourcepub fn id(&self) -> String
pub fn id(&self) -> String
ID returns a kind of uniquene representation of this bundle, containing the souce node and creation timestamp. If this bundle is a fragment, the offset is also present.
sourcepub fn update_extensions(
&mut self,
local_node: EndpointID,
residence_time: u128
) -> bool
pub fn update_extensions(
&mut self,
local_node: EndpointID,
residence_time: u128
) -> bool
Update extension blocks such as hop count, bundle age and previous node. Return true if all successful, omit missing blocks. Return false if hop count is exceeded, bundle age exceeds life time or bundle lifetime itself is exceeded
sourcepub fn previous_node(&self) -> Option<&EndpointID>
pub fn previous_node(&self) -> Option<&EndpointID>
Return the previous node of a bundle should a Previous Node Block exist
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Bundle
impl<'de> Deserialize<'de> for Bundle
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Bundle
Auto Trait Implementations
impl RefUnwindSafe for Bundle
impl Send for Bundle
impl Sync for Bundle
impl Unpin for Bundle
impl UnwindSafe for Bundle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more