#[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
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
impl PredefinedResponseError
Sourcepub fn is_unhandled(&self) -> bool
pub fn is_unhandled(&self) -> bool
Returns true if this is a PredefinedResponseError::Unhandled
, otherwise false
Sourcepub fn is_aborted(&self) -> bool
pub fn is_aborted(&self) -> bool
Returns true if this is a PredefinedResponseError::Aborted
, otherwise false
Sourcepub fn is_parse_failed(&self) -> bool
pub fn is_parse_failed(&self) -> bool
Returns true if this is a PredefinedResponseError::ParseFailed
, otherwise false
Sourcepub fn as_parse_failed_mut(&mut self) -> Option<&mut Cow<'static, str>>
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
Sourcepub fn as_parse_failed(&self) -> Option<&Cow<'static, str>>
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
Sourcepub fn into_parse_failed(self) -> Result<Cow<'static, str>, Self>
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
Sourcepub fn is_notify_handler(&self) -> bool
pub fn is_notify_handler(&self) -> bool
Returns true if this is a PredefinedResponseError::NotifyHandler
, otherwise false
Sourcepub fn is_internal(&self) -> bool
pub fn is_internal(&self) -> bool
Returns true if this is a PredefinedResponseError::Internal
, otherwise false
Sourcepub fn as_internal_mut(&mut self) -> Option<&mut i32>
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
Sourcepub fn as_internal(&self) -> Option<&i32>
pub fn as_internal(&self) -> Option<&i32>
Optionally returns references to the inner fields if this is a PredefinedResponseError::Internal
, otherwise None
Sourcepub fn into_internal(self) -> Result<i32, Self>
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
Sourcepub fn is_internal_detailed(&self) -> bool
pub fn is_internal_detailed(&self) -> bool
Returns true if this is a PredefinedResponseError::InternalDetailed
, otherwise false
Sourcepub fn as_internal_detailed_mut(&mut self) -> Option<(&mut i32, &mut String)>
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
Sourcepub fn as_internal_detailed(&self) -> Option<(&i32, &String)>
pub fn as_internal_detailed(&self) -> Option<(&i32, &String)>
Optionally returns references to the inner fields if this is a PredefinedResponseError::InternalDetailed
, otherwise None
Sourcepub fn into_internal_detailed(self) -> Result<(i32, String), Self>
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