pub struct ASCOMErrorCode(/* private fields */);
Expand description
Alpaca representation of an ASCOM error code.
Implementations§
Source§impl ASCOMErrorCode
impl ASCOMErrorCode
Sourcepub const fn new_for_driver(driver_code: u16) -> Self
pub const fn new_for_driver(driver_code: u16) -> Self
Generate ASCOM error code from a zero-based driver error code.
Will panic if the driver error code is larger than the maximum allowed (2815).
You’ll typically want to define an enum for your driver errors and use this in a single
place - in the From
conversion from your driver error type to the ASCOMError
.
§Example
use ascom_alpaca::{ASCOMError, ASCOMErrorCode};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum MyDriverError {
#[error("Port communication error: {0}")]
PortError(#[from] std::io::Error),
#[error("Initialization error: {0}")]
InitializationError(String),
}
// this allows you to then use `my_driver.method()?` when implementing Alpaca traits
// and it will convert your driver error to an ASCOM error automatically
impl From<MyDriverError> for ASCOMError {
fn from(error: MyDriverError) -> Self {
ASCOMError::new(
ASCOMErrorCode::new_for_driver(match error {
MyDriverError::PortError(_) => 0,
MyDriverError::InitializationError(_) => 1,
}),
error,
)
}
}
Sourcepub const fn as_driver_error(self) -> Result<u16, u16>
pub const fn as_driver_error(self) -> Result<u16, u16>
Get the driver-specific error code.
Returns Ok
with 0
-based driver error code if this is a driver error.
Returns Err
with raw error code if not a driver error.
Source§impl ASCOMErrorCode
impl ASCOMErrorCode
Sourcepub const ACTION_NOT_IMPLEMENTED: Self
pub const ACTION_NOT_IMPLEMENTED: Self
The requested action is not implemented in this driver
Sourcepub const INVALID_OPERATION: Self
pub const INVALID_OPERATION: Self
The requested operation can not be undertaken at this time
Sourcepub const INVALID_VALUE: Self
pub const INVALID_VALUE: Self
Invalid value
Sourcepub const INVALID_WHILE_PARKED: Self
pub const INVALID_WHILE_PARKED: Self
The attempted operation is invalid because the mount is currently in a Parked state
Sourcepub const INVALID_WHILE_SLAVED: Self
pub const INVALID_WHILE_SLAVED: Self
The attempted operation is invalid because the mount is currently in a Slaved state
Sourcepub const NOT_CONNECTED: Self
pub const NOT_CONNECTED: Self
The communications channel is not connected
Sourcepub const NOT_IMPLEMENTED: Self
pub const NOT_IMPLEMENTED: Self
Property or method not implemented
Sourcepub const NOT_IN_CACHE: Self
pub const NOT_IN_CACHE: Self
The requested item is not present in the ASCOM cache
Sourcepub const UNSPECIFIED: Self
pub const UNSPECIFIED: Self
Unspecified error
Sourcepub const VALUE_NOT_SET: Self
pub const VALUE_NOT_SET: Self
A value has not been set
Trait Implementations§
Source§impl Clone for ASCOMErrorCode
impl Clone for ASCOMErrorCode
Source§fn clone(&self) -> ASCOMErrorCode
fn clone(&self) -> ASCOMErrorCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ASCOMErrorCode
impl Debug for ASCOMErrorCode
Source§impl<'de> Deserialize<'de> for ASCOMErrorCode
impl<'de> Deserialize<'de> for ASCOMErrorCode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ASCOMErrorCode
impl Display for ASCOMErrorCode
Source§impl PartialEq for ASCOMErrorCode
impl PartialEq for ASCOMErrorCode
Source§impl Serialize for ASCOMErrorCode
impl Serialize for ASCOMErrorCode
Source§impl TryFrom<u16> for ASCOMErrorCode
impl TryFrom<u16> for ASCOMErrorCode
impl Copy for ASCOMErrorCode
impl Eq for ASCOMErrorCode
impl StructuralPartialEq for ASCOMErrorCode
Auto Trait Implementations§
impl Freeze for ASCOMErrorCode
impl RefUnwindSafe for ASCOMErrorCode
impl Send for ASCOMErrorCode
impl Sync for ASCOMErrorCode
impl Unpin for ASCOMErrorCode
impl UnwindSafe for ASCOMErrorCode
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
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
key
and return true
if they are equal.