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 NOT_IMPLEMENTED: Self
pub const NOT_IMPLEMENTED: Self
Property or method not implemented.
Sourcepub const INVALID_VALUE: Self
pub const INVALID_VALUE: Self
Invalid value.
Sourcepub const VALUE_NOT_SET: Self
pub const VALUE_NOT_SET: Self
A value has not been set.
Sourcepub const NOT_CONNECTED: Self
pub const NOT_CONNECTED: Self
The communications channel is not connected.
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 INVALID_OPERATION: Self
pub const INVALID_OPERATION: Self
The requested operation can not be undertaken at this time.
Sourcepub const ACTION_NOT_IMPLEMENTED: Self
pub const ACTION_NOT_IMPLEMENTED: Self
The requested action is not implemented in this driver.
Sourcepub const OPERATION_CANCELLED: Self
pub const OPERATION_CANCELLED: Self
In-progress asynchronous operation has been cancelled.
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.