[−][src]Struct roughenough::RtMessage
A Roughtime protocol message; a map of u32 tags to arbitrary byte-strings.
Methods
impl RtMessage
[src]
impl RtMessage
pub fn new(num_fields: u32) -> Self
[src]
pub fn new(num_fields: u32) -> Self
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
[src]
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Construct a new RtMessage from the on-the-wire representation in bytes
Arguments
bytes
- On-the-wire representation
pub fn add_field(&mut self, tag: Tag, value: &[u8]) -> Result<(), Error>
[src]
pub fn add_field(&mut self, tag: Tag, value: &[u8]) -> Result<(), Error>
Add a field to this RtMessage
Arguments
-
tag
- TheTag
to add. Tags must be added in strictly increasing order, violating this will result in aError::TagNotStrictlyIncreasing
. -
value
- Value for the tag.
pub fn get_field(&self, tag: Tag) -> Option<&[u8]>
[src]
pub fn get_field(&self, tag: Tag) -> Option<&[u8]>
pub fn num_fields(&self) -> u32
[src]
pub fn num_fields(&self) -> u32
Returns the number of tag/value pairs in the message
Returns a slice of the tags in the message
pub fn values(&self) -> &[Vec<u8>]
[src]
pub fn values(&self) -> &[Vec<u8>]
Returns a slice of the values in the message
pub fn into_hash_map(self) -> HashMap<Tag, Vec<u8>>
[src]
pub fn into_hash_map(self) -> HashMap<Tag, Vec<u8>>
Converts the message into a HashMap
mapping each tag to its value
pub fn encode(&self) -> Result<Vec<u8>, Error>
[src]
pub fn encode(&self) -> Result<Vec<u8>, Error>
Encode this message into its on-the-wire representation.
pub fn encoded_size(&self) -> usize
[src]
pub fn encoded_size(&self) -> usize
Returns the length in bytes of this message's on-the-wire representation.
pub fn pad_to_kilobyte(&mut self)
[src]
pub fn pad_to_kilobyte(&mut self)
Adds a PAD tag to the end of this message, with a length set such that the final encoded size of this message is 1KB
If the encoded size of this message is already >= 1KB, this method does nothing
Trait Implementations
impl Clone for RtMessage
[src]
impl Clone for RtMessage
fn clone(&self) -> RtMessage
[src]
fn clone(&self) -> RtMessage
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for RtMessage
[src]
impl Debug for RtMessage
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more