pub struct Message<'a>(/* private fields */);
Expand description
OpenThread Message. Functional equivalent of otsys::otMessage
.
This type cannot be instantiated directly: owned instances are
passed around in an ot::Box<ot::Message>
, or OtMessageBox
for short.
otMessage
instances keep a reference to their otInstance
, so this type does not
implement Send
nor Sync
.
Implementations§
Source§impl<'a> Message<'a>
impl<'a> Message<'a>
Sourcepub fn ip6_new<T: Boxable<OtType = otInstance>>(
instance: &'a T,
settings: Option<&Settings>,
) -> Result<Box<Message<'a>>, NoBufs>
pub fn ip6_new<T: Boxable<OtType = otInstance>>( instance: &'a T, settings: Option<&Settings>, ) -> Result<Box<Message<'a>>, NoBufs>
Functional equivalent of otsys::otIp6NewMessage
.
Sourcepub fn ip6_new_from_bytes<T: Boxable<OtType = otInstance>, D: AsRef<[u8]>>(
instance: &'a T,
data: D,
settings: Option<&Settings>,
) -> Result<Box<Message<'a>>, MalformedOrNoBufs>
pub fn ip6_new_from_bytes<T: Boxable<OtType = otInstance>, D: AsRef<[u8]>>( instance: &'a T, data: D, settings: Option<&Settings>, ) -> Result<Box<Message<'a>>, MalformedOrNoBufs>
Functional equivalent of
otsys::otIp6NewMessageFromBuffer
.
Note that, due to limitation in how the underlying method can report errors, it is impossible to differentiate the “NoBufs” error condition from the “IPv6 header malformed” error condition, hence the unusual error type.
Source§impl Message<'_>
impl Message<'_>
Sourcepub fn append(&mut self, data: &[u8]) -> Result
pub fn append(&mut self, data: &[u8]) -> Result
Functional equivalent of otsys::otMessageAppend
.
The length of data
must be less than 2^16, or else the method will return
an Err
with ot::Error::InvalidArgs
.
Sourcepub fn is_link_security_enabled(&self) -> bool
pub fn is_link_security_enabled(&self) -> bool
Functional equivalent of
otsys::otMessageIsLinkSecurityEnabled
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Functional equivalent of otsys::otMessageGetLength
.
Sourcepub fn set_len(&mut self, len: usize) -> Result
pub fn set_len(&mut self, len: usize) -> Result
Functional equivalent of otsys::otMessageSetLength
.
In addition to the error codes outlined in otsys::otMessageSetLength
, this method
will return Err(Error::InvalidArgs)
if the len
parameter is larger than 65,535 bytes.
Sourcepub fn offset(&self) -> usize
pub fn offset(&self) -> usize
Functional equivalent of otsys::otMessageGetOffset
.
Sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Functional equivalent of otsys::otMessageSetOffset
.
Calling this method with an offset
larger than or equal to exceed 2^16 will cause a panic.
Sourcepub fn set_direct_transmission(&mut self, direct_transmission: bool)
pub fn set_direct_transmission(&mut self, direct_transmission: bool)
This function sets/forces the message to be forwarded using direct transmission.
Functional equivalent of
otsys::otMessageSetDirectTransmission
.
Default setting for a new message is false
.
Sourcepub fn rssi(&self) -> Decibels
pub fn rssi(&self) -> Decibels
Functional equivalent of otsys::otMessageGetRss
.