pub struct ASCOMErrorCode(/* private fields */);
Expand description

Alpaca representation of an ASCOM error code.

Implementations§

source§

impl ASCOMErrorCode

source

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,
        )
    }
}
source

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

pub const fn raw(self) -> u16

Get the raw error code.

source§

impl ASCOMErrorCode

source

pub const OK: Self = _

source

pub const ACTION_NOT_IMPLEMENTED: Self = _

The requested action is not implemented in this driver

source

pub const INVALID_OPERATION: Self = _

The requested operation can not be undertaken at this time

source

pub const INVALID_VALUE: Self = _

Invalid value

source

pub const INVALID_WHILE_PARKED: Self = _

The attempted operation is invalid because the mount is currently in a Parked state

source

pub const INVALID_WHILE_SLAVED: Self = _

The attempted operation is invalid because the mount is currently in a Slaved state

source

pub const NOT_CONNECTED: Self = _

The communications channel is not connected

source

pub const NOT_IMPLEMENTED: Self = _

Property or method not implemented

source

pub const NOT_IN_CACHE: Self = _

The requested item is not present in the ASCOM cache

source

pub const SETTINGS: Self = _

Settings error

source

pub const UNSPECIFIED: Self = _

Unspecified error

source

pub const VALUE_NOT_SET: Self = _

A value has not been set

Trait Implementations§

source§

impl Clone for ASCOMErrorCode

source§

fn clone(&self) -> ASCOMErrorCode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ASCOMErrorCode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for ASCOMErrorCode

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for ASCOMErrorCode

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for ASCOMErrorCode

source§

fn eq(&self, other: &ASCOMErrorCode) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for ASCOMErrorCode

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<u16> for ASCOMErrorCode

source§

fn try_from(raw: u16) -> Result<Self>

Convert a raw error code into an ASCOMErrorCode if it’s in the valid range.

§

type Error = Report

The type returned in the event of a conversion error.
source§

impl Copy for ASCOMErrorCode

source§

impl Eq for ASCOMErrorCode

source§

impl StructuralEq for ASCOMErrorCode

source§

impl StructuralPartialEq for ASCOMErrorCode

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,