openthread::ot::message

Struct 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 Message<'_>

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 Boxable for Message<'_>

Source§

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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _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, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _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>,

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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