Struct ascom_alpaca::ASCOMErrorCode
source · 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§fn eq(&self, other: &ASCOMErrorCode) -> bool
fn eq(&self, other: &ASCOMErrorCode) -> bool
self
and other
values to be equal, and is used
by ==
.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 StructuralEq for ASCOMErrorCode
impl StructuralPartialEq for ASCOMErrorCode
Auto Trait Implementations§
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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.