OneOf

Enum OneOf 

Source
pub enum OneOf<T, O> {
    This(T),
    Other(O),
}

Variants§

§

This(T)

§

Other(O)

Implementations§

Source§

impl<T, O> OneOf<T, O>

Source

pub fn map_t<X>(self, f: impl FnOnce(T) -> X) -> OneOf<X, O>

map OneOf<T, O> -> OneOf<X, O>

Source

pub fn map_o<X>(self, f: impl FnOnce(O) -> X) -> OneOf<T, X>

map OneOf<T, O> -> OneOf<T, X>

Source

pub fn unify(self, f: impl FnOnce(O) -> T) -> T

make OneOf<T, O> -> T

Source

pub fn transpose(self) -> OneOf<O, T>

OneOf<T, O> -> OneOf<O, T>

Source§

impl<T, O> OneOf<T, OneOf<T, O>>

Source

pub fn flat_o(self) -> OneOf<T, O>

OneOf<T, OneOf<T, O>> -> OneOf<T, O>`

Source

pub fn flat_o_map_t<X>(self, f: impl FnOnce(T) -> X) -> OneOf<X, O>

apply flat_o then apply map_t

Source

pub fn flat_o_map_o<X>(self, f: impl FnOnce(O) -> X) -> OneOf<T, X>

apply flat_o then apply map_o

Source§

impl<T: Default, O> OneOf<T, O>

Source

pub fn default_this() -> Self

Source

pub fn opt_default_this() -> Option<Self>

Source§

impl<T, O: Default> OneOf<T, O>

Source

pub fn default_other() -> Self

Source

pub fn opt_default_other() -> Option<Self>

Source§

impl OneOf<i32, String>

Source

pub fn ok_resp<T: Serialize, R: Into<Option<T>>>( self, result: R, ) -> ResponseMessage

helper function to construct a ok response with request id

Source§

impl<I, C> OneOf<I, ReqWithContext<C>>

Source

pub fn or_else<F, R>(self, f: F) -> OneOf<I, ReqWithContext<C>>
where C: Clone, R: FromReq, F: FnOnce(C, ReqId, R) -> I,

if previous handler does not match method field, pass alternative handler

Source§

impl<I, C> OneOf<I, NoticeWithContext<C>>

Source

pub fn or_else<F, N>(self, f: F) -> OneOf<I, NoticeWithContext<C>>
where C: Clone, N: FromNotice, F: FnOnce(C, N) -> I,

if previous handler does not match method field, pass alternative handler

Trait Implementations§

Source§

impl<T: Clone, O: Clone> Clone for OneOf<T, O>

Source§

fn clone(&self) -> OneOf<T, O>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, O: Debug> Debug for OneOf<T, O>

Source§

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

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

impl<T: Default, U> Default for OneOf<T, U>

Source§

fn default() -> Self

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

impl<'de, T, O> Deserialize<'de> for OneOf<T, O>
where T: Deserialize<'de>, O: Deserialize<'de>,

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<T: PartialEq, O: PartialEq> PartialEq for OneOf<T, O>

Source§

fn eq(&self, other: &OneOf<T, O>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, O> Serialize for OneOf<T, O>
where T: Serialize, O: Serialize,

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

impl<T, O> StructuralPartialEq for OneOf<T, O>

Auto Trait Implementations§

§

impl<T, O> Freeze for OneOf<T, O>
where T: Freeze, O: Freeze,

§

impl<T, O> RefUnwindSafe for OneOf<T, O>

§

impl<T, O> Send for OneOf<T, O>
where T: Send, O: Send,

§

impl<T, O> Sync for OneOf<T, O>
where T: Sync, O: Sync,

§

impl<T, O> Unpin for OneOf<T, O>
where T: Unpin, O: Unpin,

§

impl<T, O> UnwindSafe for OneOf<T, O>
where T: UnwindSafe, O: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,