[−][src]Struct bp7::bundle::Bundle
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>
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]
&self,
block_type: CanonicalBlockType
) -> Option<&CanonicalBlock>
Get first extension block matching the block type
pub fn extension_block_mut(
&mut self,
block_type: CanonicalBlockType
) -> Option<&mut CanonicalBlock>
[src]
&mut self,
block_type: CanonicalBlockType
) -> Option<&mut CanonicalBlock>
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]
&mut self,
local_node: EndpointID,
residence_time: u64
) -> 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
Trait Implementations
impl Clone for Bundle
[src]
fn clone(&self) -> Bundle
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for Bundle
[src]
impl From<Vec<u8>> for Bundle
[src]
Deserialize from CBOR byte buffer.
fn from(item: ByteBuffer) -> Self
[src]
impl From<String> for Bundle
[src]
Deserialize from JSON string.
impl PartialEq<Bundle> for Bundle
[src]
impl Debug for Bundle
[src]
impl Serialize for Bundle
[src]
impl<'de> Deserialize<'de> for Bundle
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl Sync for Bundle
impl Send for Bundle
impl Unpin for Bundle
impl RefUnwindSafe for Bundle
impl UnwindSafe for Bundle
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,