xwrust::xwmd::xwmq

Struct Xwmq

source
pub struct Xwmq<const N: XwSz, T>
where [u8; { _ }]: Sized,
{ /* private fields */ }
Expand description

消息队列对象结构体

Implementations§

source§

impl<const N: XwSz, T> Xwmq<N, T>
where [u8; { _ }]: Sized,

source

pub const fn new() -> Self

新建消息队列对象

此方法是编译期方法。

§示例
  • 具有 static 约束的全局变量全局变量:
use xwrust::xwmd::xwmq::*;

static MQ: Xwmq<16, String> = Xwmq::new(); // 16个消息槽,数据类型为String
  • 在heap中创建:
extern crate alloc;
use alloc::sync::Arc;

use xwrust::xwmd::xwmq::*;

pub fn xwrust_example_xwmq() {
    let mq: Arc<Xwmq<16, String>> = Arc::new(Xwmq::new()); // 16个消息槽,数据类型为String
}
source

pub fn init<'a>(&'a self) -> (XwmqTx<'a, N, T>, XwmqRx<'a, N, T>)

初始化消息队列对象

消息队列对象必须调用此方法一次,方可正常使用。 初始化后会返回消息队列的发送者 XwmqTx 以及接收者 XwmqRx

§示例
use xwrust::xwmd::xwmq::*;

static MQ: Xwmq<16, String> = Xwmq::new();

pub fn xwrust_example_xwmq() {
    let (tx, rx) = MQ.init();
}

Trait Implementations§

source§

impl<const N: XwSz, T> Send for Xwmq<N, T>
where [u8; { _ }]: Sized,

source§

impl<const N: XwSz, T> Sync for Xwmq<N, T>
where [u8; { _ }]: Sized,

Auto Trait Implementations§

§

impl<const N: usize, T> !Freeze for Xwmq<N, T>

§

impl<const N: usize, T> !RefUnwindSafe for Xwmq<N, T>

§

impl<const N: usize, T> Unpin for Xwmq<N, T>
where [u8; { _ }]: Sized, T: Unpin,

§

impl<const N: usize, T> UnwindSafe for Xwmq<N, T>
where [u8; { _ }]: Sized, T: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

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.
§

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

Performs the conversion.