Struct SDKResult

Source
pub struct SDKResult<T>(pub Result<T, WootingAnalogResult>);

Tuple Fields§

§0: Result<T, WootingAnalogResult>

Methods from Deref<Target = Result<T, WootingAnalogResult>>§

1.0.0 · Source

pub fn is_ok(&self) -> bool

Returns true if the result is Ok.

§Examples
let x: Result<i32, &str> = Ok(-3);
assert_eq!(x.is_ok(), true);

let x: Result<i32, &str> = Err("Some error message");
assert_eq!(x.is_ok(), false);
1.0.0 · Source

pub fn is_err(&self) -> bool

Returns true if the result is Err.

§Examples
let x: Result<i32, &str> = Ok(-3);
assert_eq!(x.is_err(), false);

let x: Result<i32, &str> = Err("Some error message");
assert_eq!(x.is_err(), true);
1.0.0 · Source

pub fn as_ref(&self) -> Result<&T, &E>

Converts from &Result<T, E> to Result<&T, &E>.

Produces a new Result, containing a reference into the original, leaving the original in place.

§Examples
let x: Result<u32, &str> = Ok(2);
assert_eq!(x.as_ref(), Ok(&2));

let x: Result<u32, &str> = Err("Error");
assert_eq!(x.as_ref(), Err(&"Error"));
1.47.0 · Source

pub fn as_deref(&self) -> Result<&<T as Deref>::Target, &E>
where T: Deref,

Converts from Result<T, E> (or &Result<T, E>) to Result<&<T as Deref>::Target, &E>.

Coerces the Ok variant of the original Result via Deref and returns the new Result.

§Examples
let x: Result<String, u32> = Ok("hello".to_string());
let y: Result<&str, &u32> = Ok("hello");
assert_eq!(x.as_deref(), y);

let x: Result<String, u32> = Err(42);
let y: Result<&str, &u32> = Err(&42);
assert_eq!(x.as_deref(), y);
1.0.0 · Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the possibly contained value.

The iterator yields one value if the result is Result::Ok, otherwise none.

§Examples
let x: Result<u32, &str> = Ok(7);
assert_eq!(x.iter().next(), Some(&7));

let x: Result<u32, &str> = Err("nothing!");
assert_eq!(x.iter().next(), None);

Trait Implementations§

Source§

impl<T: Debug> Debug for SDKResult<T>

Source§

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

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

impl<T> Default for SDKResult<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Deref for SDKResult<T>

Source§

type Target = Result<T, WootingAnalogResult>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> From<FfiStr<'a>> for SDKResult<FfiStr<'a>>

Source§

fn from(res: FfiStr<'a>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Result<T, WootingAnalogResult>> for SDKResult<T>

Source§

fn from(ptr: Result<T, WootingAnalogResult>) -> Self

Converts to this type from the input type.
Source§

impl From<WootingAnalogResult> for SDKResult<()>

Source§

fn from(res: WootingAnalogResult) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for SDKResult<f32>

Source§

fn from(res: f32) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for SDKResult<c_int>

Source§

fn from(res: c_int) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for SDKResult<u32>

Source§

fn from(res: c_int) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for SDKResult<u32>

Source§

fn from(res: u32) -> Self

Converts to this type from the input type.
Source§

impl<T> Into<Result<T, WootingAnalogResult>> for SDKResult<T>

Source§

fn into(self) -> Result<T, WootingAnalogResult>

Converts this type into the (usually inferred) input type.
Source§

impl Into<WootingAnalogResult> for SDKResult<()>

Source§

fn into(self) -> WootingAnalogResult

Converts this type into the (usually inferred) input type.
Source§

impl Into<f32> for SDKResult<f32>

Source§

fn into(self) -> f32

Converts this type into the (usually inferred) input type.
Source§

impl Into<i32> for SDKResult<c_int>

Source§

fn into(self) -> c_int

Converts this type into the (usually inferred) input type.
Source§

impl Into<i32> for SDKResult<u32>

Source§

fn into(self) -> i32

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<T> Freeze for SDKResult<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SDKResult<T>
where T: RefUnwindSafe,

§

impl<T> Send for SDKResult<T>
where T: Send,

§

impl<T> Sync for SDKResult<T>
where T: Sync,

§

impl<T> Unpin for SDKResult<T>
where T: Unpin,

§

impl<T> UnwindSafe for SDKResult<T>
where T: UnwindSafe,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.