[−][src]Struct roughenough::RtMessage
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]
Construct a new RtMessage from the on-the-wire representation in bytes
Arguments
bytes
- On-the-wire representation
pub fn new_deliberately_invalid(tags: Vec<Tag>, values: Vec<Vec<u8>>) -> Self
[src]
Dangerous: construct a new RtMessage without validation or error checking.
Intended only for construction of deliberately bogus responses as part of Roughtime's ecosystem.
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 get_field(&self, tag: Tag) -> Option<&[u8]>
[src]
pub fn num_fields(&self) -> u32
[src]
Returns the number of tag/value pairs in the message
pub fn tags(&self) -> &[Tag]
[src]
Returns a slice of the tags in the message
pub fn values(&self) -> &[Vec<u8>]
[src]
Returns a slice of the values in the message
pub fn into_hash_map(self) -> HashMap<Tag, Vec<u8>>
[src]
Converts the message into a HashMap
mapping each tag to its value
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
Auto Trait Implementations
impl RefUnwindSafe for RtMessage
impl Send for RtMessage
impl Sync for RtMessage
impl Unpin for RtMessage
impl UnwindSafe for RtMessage
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> 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, 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>,