Struct openthread::ot::message::Message

source ·
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>

source

pub fn ip6_new<T: Boxable<OtType = otInstance>>( instance: &'a T, settings: Option<&Settings> ) -> Result<Box<Message<'a>>, NoBufs>

Functional equivalent of otsys::otIp6NewMessage.

source

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

pub fn ip4_new<T: Boxable<OtType = otInstance>>( instance: &'a T, settings: Option<&Settings> ) -> Result<Box<Message<'a>>, NoBufs>

Functional equivalent of otsys::otIp4NewMessage.

source§

impl<'a> Message<'a>

source

pub fn udp_new<T: Boxable<OtType = otInstance>>( instance: &'a T, settings: Option<&Settings> ) -> Result<Box<Message<'a>>, NoBufs>

Functional equivalent of otsys::otIp6NewMessage.

source§

impl<'a> Message<'a>

source

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.

Functional equivalent of otsys::otMessageIsLinkSecurityEnabled.

source

pub fn len(&self) -> usize

Functional equivalent of otsys::otMessageGetLength.

source

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.

source

pub fn offset(&self) -> usize

Functional equivalent of otsys::otMessageGetOffset.

source

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.

source

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.

source

pub fn rssi(&self) -> Decibels

Functional equivalent of otsys::otMessageGetRss.

source

pub fn to_vec(&self) -> Vec<u8>

Renders this message to a new Vec<u8> using otsys::otMessageRead.

Trait Implementations§

source§

impl<'a> Boxable for Message<'a>

§

type OtType = otMessage

The underlying implementation-opaque OpenThread type used by the standard C-API.
source§

unsafe fn finalize(&mut self)

Finalizes or frees the underlying OpenThread object. Read more
source§

unsafe fn ref_from_ot_ptr<'a>(ptr: *mut Self::OtType) -> Option<&'a Self>

Creates a reference to a safe wrapper object from an OpenThread pointer. Read more
source§

unsafe fn ref_from_ot_const_ptr<'a>( ptr: *const Self::OtType ) -> Option<&'a Self>

Creates a reference to a safe wrapper object from an OpenThread const pointer. Read more
source§

unsafe fn mut_from_ot_ptr<'a>(ptr: *mut Self::OtType) -> Option<&'a mut Self>

Creates a mutable reference to a safe wrapper object from an OpenThread pointer. Read more
source§

fn as_ot_ptr(&self) -> *mut Self::OtType

Returns the underlying OpenThread pointer for this object. The default implementation simply casts the reference to a pointer.
source§

impl Debug for Message<'_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Message<'a>

§

impl<'a> RefUnwindSafe for Message<'a>

§

impl<'a> !Send for Message<'a>

§

impl<'a> !Sync for Message<'a>

§

impl<'a> Unpin for Message<'a>

§

impl<'a> UnwindSafe for Message<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Encode<Ambiguous1> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T> Encode<Ambiguous2> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more