[−][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>
Implementations
impl Bundle
[src]
pub fn new(primary: PrimaryBlock, canonicals: Vec<CanonicalBlock>) -> Bundle
[src]
pub fn validate(&self) -> Result<(), 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_payload_block(&mut self, payload: CanonicalBlock)
[src]
Sets or updates the payload block
pub fn set_payload(&mut self, payload: ByteBuffer)
[src]
Sets or updates the payload
pub fn set_crc(&mut self, crc_type: CrcRawType)
[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_by_type(
&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_by_type_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: u128
) -> bool
[src]
&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
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]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
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.
fn try_from(item: String) -> Result<Self, Self::Error>
[src]
impl TryFrom<Vec<u8>> for Bundle
[src]
Deserialize from CBOR byte buffer.
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,