[][src]Struct bp7::bundle::Bundle

pub struct Bundle {
    pub primary: PrimaryBlock,
    pub canonicals: Vec<CanonicalBlock>,
}

Bundle represents a bundle as defined in section 4.2.1. Each Bundle contains one primary block and multiple canonical blocks.

Fields

primary: PrimaryBlockcanonicals: Vec<CanonicalBlock>

Methods

impl Bundle[src]

pub fn new(primary: PrimaryBlock, canonicals: Vec<CanonicalBlock>) -> Bundle[src]

pub fn validation_errors(&self) -> Option<Bp7ErrorList>[src]

Validate bundle and optionally return list of errors.

pub fn sort_canonicals(&mut self)[src]

Sort canonical blocks by block number

pub fn add_canonical_block(&mut self, cblock: CanonicalBlock)[src]

Automatically assign a block number and add canonical block to bundle

pub fn is_administrative_record(&self) -> bool[src]

Checks whether the bundle is an administrative record

pub fn payload(&self) -> Option<&ByteBuffer>[src]

Return payload of bundle if an payload block exists and carries data.

pub fn set_crc(&mut self, crc_type: CRCType)[src]

Sets the given CRCType for each block. The crc value is calculated on-the-fly before serializing.

pub fn crc_valid(&mut self) -> bool[src]

Check whether a bundle has only valid CRC checksums in all blocks.

pub fn calculate_crc(&mut self)[src]

Calculate crc for all blocks.

pub fn extension_block(
    &self,
    block_type: CanonicalBlockType
) -> Option<&CanonicalBlock>
[src]

Get first extension block matching the block type

pub fn extension_block_mut(
    &mut self,
    block_type: CanonicalBlockType
) -> Option<&mut CanonicalBlock>
[src]

Get mutable reference for first extension block matching the block type

pub fn to_cbor(&mut self) -> ByteBuffer[src]

Serialize bundle as CBOR encoded byte buffer.

pub fn to_json(&mut self) -> String[src]

Serialize bundle as JSON encoded string.

pub fn id(&self) -> String[src]

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.

pub fn update_extensions(
    &mut self,
    local_node: EndpointID,
    residence_time: u64
) -> bool
[src]

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

pub fn previous_node(&self) -> Option<&EndpointID>[src]

Return the previous node of a bundle should a Previous Node Block exist

Trait Implementations

impl Clone for Bundle[src]

impl Debug for Bundle[src]

impl Default for Bundle[src]

impl<'de> Deserialize<'de> for Bundle[src]

impl Display for Bundle[src]

impl PartialEq<Bundle> for Bundle[src]

impl Serialize for Bundle[src]

impl StructuralPartialEq for Bundle[src]

impl TryFrom<String> for Bundle[src]

Deserialize from JSON string.

type Error = String

The type returned in the event of a conversion error.

impl TryFrom<Vec<u8>> for Bundle[src]

Deserialize from CBOR byte buffer.

type Error = String

The type returned in the event of a conversion error.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,