[−][src]Enum misskey_core::model::ApiResult
Result type that represents immediate response from Misskey.
ApiResult
is either successful response (ApiResult::Ok
) or an error
(ApiResult::Err
) with ApiError
.
We implement this type in a way that distinguishes it from the Result<T, ApiError>
, since the
ApiResult
is a normal response to a successful request, even if it is an
ApiResult::Err
. (see the return type of crate::Client::request
)
You can convert ApiResult<T>
to Result<T, ApiError>
by using Into::into
or ApiResult::into_result
.
Variants
Contains the error value, namely ApiError
.
Fields of Err
error: ApiError
The error returned from Misskey.
Contains the success value.
Implementations
impl<T> ApiResult<T>
[src]
pub fn into_result(self) -> Result<T, ApiError>
[src]
Converts ApiResult
to Result
for convenient handling.
You can also use Into::into
, but this is preferred as it expresses the intent more clearly.
pub fn ok(self) -> Option<T>
[src]
Converts ApiResult<T>
to Option<T>
, consuming self
, and discarding the error, if any.
pub fn err(self) -> Option<ApiError>
[src]
Converts ApiResult<T>
to Option<ApiError>
, consuming self
, and discarding the success
value, if any.
pub fn is_ok(&self) -> bool
[src]
Returns true if the API result is ApiResult::Ok
.
pub fn is_err(&self) -> bool
[src]
Returns true if the API result is ApiResult::Err
.
pub fn expect(self, msg: &str) -> T
[src]
Returns the contained ApiResult::Ok
value, consuming the self
value.
Panics
Panics if the value is an ApiResult::Err
, with a panic message including the
passed message, and the content of the ApiResult::Err
.
pub fn unwrap(self) -> T
[src]
Returns the contained ApiResult::Ok
value, consuming the self
value.
Panics
Panics if the value is an ApiResult::Err
, with a panic message provided by the
ApiResult::Err
's value.
pub fn map<U, F>(self, op: F) -> ApiResult<U> where
F: FnOnce(T) -> U,
[src]
F: FnOnce(T) -> U,
Maps a ApiResult<T>
to ApiResult<U>
by applying a function to a
contained ApiResult::Ok
value, leaving an ApiResult::Err
value untouched.
Trait Implementations
impl<T: Clone> Clone for ApiResult<T>
[src]
impl<T: Debug> Debug for ApiResult<T>
[src]
impl<'de, T> Deserialize<'de> for ApiResult<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T> Into<Result<T, ApiError>> for ApiResult<T>
[src]
impl<T> Serialize for ApiResult<T> where
T: Serialize,
[src]
T: Serialize,
Auto Trait Implementations
impl<T> RefUnwindSafe for ApiResult<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for ApiResult<T> where
T: Send,
T: Send,
impl<T> Sync for ApiResult<T> where
T: Sync,
T: Sync,
impl<T> Unpin for ApiResult<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ApiResult<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,