xwrust::xwos::sync::flg

Struct FlgSel

source
pub struct FlgSel<'a, const N: XwSz, const M: XwSz>
where [XwBmp; { _ }]: Sized,
{ pub flg: &'a Flg<N>, pub sel: &'a Sel<M>, pub pos: XwSq, }
Expand description

事件标志的选择子

FlgSel<'a, N, M>Flg<N>Sel<M> 具有相同的生命周期约束 'a 。因为 FlgSel<'a, N, M> 中包含了 Flg<N>Sel<M> 的引用。

FlgSel<'a, N, M> 中包含了绑定的位置信息,事件标志采用 非独占 的方式进行绑定。

FlgSel::selected() 可用来判断事件标志是否被选择。

FlgSel<'a, N, M>drop() 时,会自动将 Flg<N>Sel<M> 解绑。

Fields§

§flg: &'a Flg<N>

事件标志

§sel: &'a Sel<M>

信号选择器

§pos: XwSq

位置

Implementations§

source§

impl<'a, const N: XwSz, const M: XwSz> FlgSel<'a, N, M>
where [XwBmp; { _ }]: Sized,

source

pub fn selected(&self, trg: &Bmp<M>) -> bool

判断触发的 选择信号 是否包括此事件标志

§示例
    let msk = Bmp::<8>::new(); // 8位位图
    msk.s1all(); // 掩码为0xFF
    loop {
        let res = sel.select(&msk);
        match res {
            Ok(t) => { // 信号选择器上有 **选择信号** , `t` 为 **选择信号** 的位图。
                if flg0sel.selected(&t) { // 事件标志被选择到
                }
            },
            Err(e) => { // 等待信号选择器失败,`e` 为 `SelError`
                flgeak;
            },
        }
    }

Trait Implementations§

source§

impl<'a, const N: XwSz, const M: XwSz> Drop for FlgSel<'a, N, M>
where [XwBmp; { _ }]: Sized,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a, const N: XwSz, const M: XwSz> Send for FlgSel<'a, N, M>
where [XwBmp; { _ }]: Sized,

source§

impl<'a, const N: XwSz, const M: XwSz> Sync for FlgSel<'a, N, M>
where [XwBmp; { _ }]: Sized,

Auto Trait Implementations§

§

impl<'a, const N: usize, const M: usize> Freeze for FlgSel<'a, N, M>
where [usize; { _ }]: Sized,

§

impl<'a, const N: usize, const M: usize> !RefUnwindSafe for FlgSel<'a, N, M>

§

impl<'a, const N: usize, const M: usize> Unpin for FlgSel<'a, N, M>
where [usize; { _ }]: Sized,

§

impl<'a, const N: usize, const M: usize> !UnwindSafe for FlgSel<'a, N, M>

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.