pub enum BackendState {
Uninitialized,
Initializing,
Ready,
Closing,
Closed,
Error,
}Expand description
Backend lifecycle state.
Represents the current state of a backend in its lifecycle. Backends transition through these states during initialization, operation, and shutdown.
§State Transitions
Uninitialized -> Initializing -> Ready -> Closing -> Closed
↓ ↓
Error ←--------┘§Examples
use canlink_hal::BackendState;
let state = BackendState::Uninitialized;
assert!(!state.is_ready());
let state = BackendState::Ready;
assert!(state.is_ready());Variants§
Uninitialized
Backend has not been initialized
Initializing
Backend is currently initializing
Ready
Backend is ready for operations
Closing
Backend is closing
Closed
Backend has been closed
Error
Backend encountered an error
Implementations§
Source§impl BackendState
impl BackendState
Sourcepub const fn is_ready(&self) -> bool
pub const fn is_ready(&self) -> bool
Check if the backend is ready for operations.
§Examples
use canlink_hal::BackendState;
assert!(BackendState::Ready.is_ready());
assert!(!BackendState::Uninitialized.is_ready());Sourcepub const fn is_error(&self) -> bool
pub const fn is_error(&self) -> bool
Check if the backend is in an error state.
§Examples
use canlink_hal::BackendState;
assert!(BackendState::Error.is_error());
assert!(!BackendState::Ready.is_error());Sourcepub const fn is_closed(&self) -> bool
pub const fn is_closed(&self) -> bool
Check if the backend is closed.
§Examples
use canlink_hal::BackendState;
assert!(BackendState::Closed.is_closed());
assert!(!BackendState::Ready.is_closed());Sourcepub const fn can_operate(&self) -> bool
pub const fn can_operate(&self) -> bool
Check if the backend can accept operations.
Returns true only if the backend is in the Ready state.
§Examples
use canlink_hal::BackendState;
assert!(BackendState::Ready.can_operate());
assert!(!BackendState::Initializing.can_operate());
assert!(!BackendState::Error.can_operate());Sourcepub const fn description(&self) -> &'static str
pub const fn description(&self) -> &'static str
Get a human-readable description of the state.
§Examples
use canlink_hal::BackendState;
assert_eq!(BackendState::Ready.description(), "Ready");
assert_eq!(BackendState::Error.description(), "Error");Trait Implementations§
Source§impl Clone for BackendState
impl Clone for BackendState
Source§fn clone(&self) -> BackendState
fn clone(&self) -> BackendState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BackendState
impl Debug for BackendState
Source§impl Default for BackendState
impl Default for BackendState
Source§fn default() -> BackendState
fn default() -> BackendState
Returns the “default value” for a type. Read more
Source§impl Display for BackendState
impl Display for BackendState
Source§impl Hash for BackendState
impl Hash for BackendState
Source§impl PartialEq for BackendState
impl PartialEq for BackendState
impl Copy for BackendState
impl Eq for BackendState
impl StructuralPartialEq for BackendState
Auto Trait Implementations§
impl Freeze for BackendState
impl RefUnwindSafe for BackendState
impl Send for BackendState
impl Sync for BackendState
impl Unpin for BackendState
impl UnsafeUnpin for BackendState
impl UnwindSafe for BackendState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.