Struct roughenough::RtMessage
[−]
[src]
pub struct RtMessage { /* fields omitted */ }
A Roughtime protocol message; a map of u32 tags to arbitrary byte-strings.
Methods
impl RtMessage
[src]
pub fn new(num_fields: u32) -> Self
[src]
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
[src]
pub fn add_field(&mut self, tag: Tag, value: &[u8]) -> Result<(), Error>
[src]
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 num_fields(&self) -> u32
[src]
Returns the number of tag/value pairs in the message
[src]
pub fn values(&self) -> &[Vec<u8>]
[src]
pub fn into_hash_map(self) -> HashMap<Tag, Vec<u8>>
[src]
pub fn encode(&self) -> Result<Vec<u8>, Error>
[src]
Encode this message into its on-the-wire representation.
pub fn encoded_size(&self) -> usize
[src]
Returns the length in bytes of this message's on-the-wire representation.
pub fn pad_to_kilobyte(&mut self)
[src]
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 Debug for RtMessage
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more