Skip to main content

UnifiError

Enum UnifiError 

Source
#[non_exhaustive]
pub enum UnifiError {
Show 18 variants MissingUrl, MissingApiKey, ClientBuild(Error), Timeout { method: String, url: String, source: Error, }, Connect { method: String, url: String, source: Error, }, Request { method: String, url: String, source: Error, }, Unauthorized(String), Forbidden { method: String, url: String, }, NotFound { method: String, url: String, }, RateLimited { method: String, url: String, retry_after: Option<Duration>, }, EmptyBody { method: String, url: String, }, Decode { url: String, source: Error, }, UnexpectedStatus { status: u16, url: String, body: Box<Value>, }, UnknownAction(String), InvalidRequest { context: String, message: String, }, PathTemplate(String), ConnectorPath(String), HybridRouting(String),
}
Expand description

Everything that can go wrong talking to a UniFi controller.

Marked #[non_exhaustive]: this crate is meant to be published and consumed externally, so a caller that matches on this must include a wildcard arm — adding a new variant (e.g. a future status-class split) must never be a semver-breaking change for downstream code.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

MissingUrl

UnifiConfig::url was empty.

§

MissingApiKey

UnifiConfig::api_key was empty.

§

ClientBuild(Error)

The underlying reqwest::Client failed to build.

§

Timeout

The request exceeded the client timeout.

Fields

§method: String

HTTP method of the request that timed out.

§url: String

Full request URL.

§source: Error

Underlying transport error (kept for Error::source() chain-walking even though the message above doesn’t repeat its text).

§

Connect

The controller could not be reached (DNS, TCP, or TLS handshake failure).

Fields

§method: String

HTTP method of the request that failed to connect.

§url: String

Full request URL.

§source: Error

Underlying transport error (kept for Error::source() chain-walking even though the message above doesn’t repeat its text).

§

Request

A transport-level failure other than timeout or connect.

Fields

§method: String

HTTP method of the failed request.

§url: String

Full request URL.

§source: Error

Underlying transport error.

§

Unauthorized(String)

The controller rejected the API key (HTTP 401). Unlike the other status-class variants this has no method field: a rejected key is rejected the same way for every verb, so there’s nothing extra to carry — not an oversight.

Tuple Fields

§0: String

Full request URL.

§

Forbidden

The API key is valid but lacks permission for the request (HTTP 403).

Fields

§method: String

HTTP method of the forbidden request.

§url: String

Full request URL.

§

NotFound

The controller has no such endpoint (HTTP 404).

Fields

§method: String

HTTP method of the request.

§url: String

Full request URL.

§

RateLimited

The controller rejected the request for exceeding its rate limit (HTTP 429).

Fields

§method: String

HTTP method of the rate-limited request.

§url: String

Full request URL.

§retry_after: Option<Duration>

Parsed Retry-After response header, when present and expressed in seconds (the HTTP-date form is not parsed).

§

EmptyBody

A GET returned a successful status with no body, where a JSON body was expected.

Fields

§method: String

HTTP method of the request.

§url: String

Full request URL.

§

Decode

The response body was not valid JSON.

Fields

§url: String

Full request URL.

§source: Error

Underlying JSON parse error.

§

UnexpectedStatus

The controller returned a non-success status not covered by a more specific variant.

Fields

§status: u16

HTTP status code.

§url: String

Full request URL.

§body: Box<Value>

Response body, if any was returned.

§

UnknownAction(String)

crate::ActionDispatcher::execute was asked to run an action that has no registered crate::capabilities::Capability.

§

InvalidRequest

A request’s parameters were malformed (wrong type, wrong API family, unknown hybrid target, etc). context is an action name or an HTTP method + path, whichever the caller had on hand.

Fields

§context: String

What was being executed when validation failed.

§message: String

What was wrong with the request.

§

PathTemplate(String)

Path-template substitution failed (unmatched brace, missing parameter, wrong type).

§

ConnectorPath(String)

The *path connector wildcard segment failed validation (traversal, encoded separators, or outside the allowed API prefixes).

§

HybridRouting(String)

Hybrid action routing (official vs. internal) failed.

Trait Implementations§

Source§

impl Debug for UnifiError

Source§

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

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

impl Display for UnifiError

Source§

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

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

impl Error for UnifiError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

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

Source§

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>,

Source§

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>,

Source§

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<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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