pub struct Chan(/* private fields */);Implementations§
Source§impl Chan
For channels known at compile time
Validation happens at compile time via const fn
impl Chan
For channels known at compile time Validation happens at compile time via const fn
Sourcepub fn new<P: ChanValidate>(id: u8) -> Result<Self, P::Error>
pub fn new<P: ChanValidate>(id: u8) -> Result<Self, P::Error>
Creates a new Chan with platform-specific validation via P.
Sourcepub unsafe fn new_unchecked(id: u8) -> Self
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")
}
}
}
Trait Implementations§
impl Copy for Chan
impl Eq for Chan
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more