Enum PredefinedResponseError

Source
#[non_exhaustive]
pub enum PredefinedResponseError { Unhandled, Aborted, ParseFailed(Cow<'static, str>), NotifyHandler, Internal(i32), InternalDetailed(i32, String), }
Expand description

Some predefined reponse error types. Most of them are automatically generated from the server.

In default, errors are serialized as following form:

{
    "code": "PARSE_FAILED",
    "detail": "Failed to parse argument. (hint: Type 'i32' is expected)"
}

The encoded error types may be customized by Codec::encode_response_predefined.

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

Unhandled

You should not use this error type directly. This error type is used internally by the library when the request object is dropped before sending request. To specify intentional abort, use PredefinedResponseError::Aborted instead.

§

Aborted

Use this when you want to abort the request intentionally.

§

ParseFailed(Cow<'static, str>)

The typename will be obtained from std::any::type_name

§

NotifyHandler

Invalid request/notify handler type

§

Internal(i32)

Internal error. This is only generated by the user.

§

InternalDetailed(i32, String)

Internal error. This is only generated by the user.

Implementations§

Source§

impl PredefinedResponseError

Source

pub fn is_unhandled(&self) -> bool

Returns true if this is a PredefinedResponseError::Unhandled, otherwise false

Source

pub fn is_aborted(&self) -> bool

Returns true if this is a PredefinedResponseError::Aborted, otherwise false

Source

pub fn is_parse_failed(&self) -> bool

Returns true if this is a PredefinedResponseError::ParseFailed, otherwise false

Source

pub fn as_parse_failed_mut(&mut self) -> Option<&mut Cow<'static, str>>

Optionally returns mutable references to the inner fields if this is a PredefinedResponseError::ParseFailed, otherwise None

Source

pub fn as_parse_failed(&self) -> Option<&Cow<'static, str>>

Optionally returns references to the inner fields if this is a PredefinedResponseError::ParseFailed, otherwise None

Source

pub fn into_parse_failed(self) -> Result<Cow<'static, str>, Self>

Returns the inner fields if this is a PredefinedResponseError::ParseFailed, otherwise returns back the enum in the Err case of the result

Source

pub fn is_notify_handler(&self) -> bool

Returns true if this is a PredefinedResponseError::NotifyHandler, otherwise false

Source

pub fn is_internal(&self) -> bool

Returns true if this is a PredefinedResponseError::Internal, otherwise false

Source

pub fn as_internal_mut(&mut self) -> Option<&mut i32>

Optionally returns mutable references to the inner fields if this is a PredefinedResponseError::Internal, otherwise None

Source

pub fn as_internal(&self) -> Option<&i32>

Optionally returns references to the inner fields if this is a PredefinedResponseError::Internal, otherwise None

Source

pub fn into_internal(self) -> Result<i32, Self>

Returns the inner fields if this is a PredefinedResponseError::Internal, otherwise returns back the enum in the Err case of the result

Source

pub fn is_internal_detailed(&self) -> bool

Returns true if this is a PredefinedResponseError::InternalDetailed, otherwise false

Source

pub fn as_internal_detailed_mut(&mut self) -> Option<(&mut i32, &mut String)>

Optionally returns mutable references to the inner fields if this is a PredefinedResponseError::InternalDetailed, otherwise None

Source

pub fn as_internal_detailed(&self) -> Option<(&i32, &String)>

Optionally returns references to the inner fields if this is a PredefinedResponseError::InternalDetailed, otherwise None

Source

pub fn into_internal_detailed(self) -> Result<(i32, String), Self>

Returns the inner fields if this is a PredefinedResponseError::InternalDetailed, otherwise returns back the enum in the Err case of the result

Trait Implementations§

Source§

impl Debug for PredefinedResponseError

Source§

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

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

impl<'de> Deserialize<'de> for PredefinedResponseError

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 PredefinedResponseError

Source§

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

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

impl Error for PredefinedResponseError

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

impl Serialize for PredefinedResponseError

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

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.

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> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

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

impl<T> UserData for T
where T: Any + Send + Sync + 'static,

Source§

fn as_any(&self) -> &(dyn Any + Send + Sync + 'static)

Source§

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