Skip to main content

Chan

Struct Chan 

Source
pub struct Chan(/* private fields */);

Implementations§

Source§

impl Chan

For channels known at compile time Validation happens at compile time via const fn

Source

pub fn new<P: ChanValidate>(id: u8) -> Result<Self, P::Error>

Creates a new Chan with platform-specific validation via P.

Source

pub unsafe fn new_unchecked(id: u8) -> Self

§Safety

This constructor does not perform any validation on the provided id. It is the caller’s responsibility to ensure that the id is valid for the intended platform and use case.

In driver implementations, the implementor should refer to the platform-specific documentation for the valid range of channel IDs. Hence, this function is unsafe and should be used with caution.

In real implementation, it should be like:

use consortium_core::Chan;

// Here we assume a `Channel` for `stm32mp2` series.

impl ChanValidate for stm32mp::Channel {
   type Error = &'static str;

   fn validate(id: u8) -> Result<Chan, Self::Error> {
       if id < 16 {
           Ok(unsafe { Chan::new_unchecked(id) })
       } else {
           Err("Invalid channel ID")
       }
   }
}
Source

pub fn id(&self) -> u8

Returns the raw channel identifier.

Trait Implementations§

Source§

impl Clone for Chan

Source§

fn clone(&self) -> Chan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Chan

Source§

impl Debug for Chan

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Chan

Source§

impl From<Chan> for u8

Source§

fn from(chan: Chan) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Chan

Source§

fn eq(&self, other: &Chan) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Chan

Auto Trait Implementations§

§

impl Freeze for Chan

§

impl RefUnwindSafe for Chan

§

impl Send for Chan

§

impl Sync for Chan

§

impl Unpin for Chan

§

impl UnsafeUnpin for Chan

§

impl UnwindSafe for Chan

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> MaybeSend for T

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.