HasOne

Enum HasOne 

Source
pub enum HasOne<E: EntityTrait> {
    Unloaded,
    NotFound,
    Loaded(Box<E::ModelEx>),
}

Variantsยง

ยง

Unloaded

ยง

NotFound

ยง

Loaded(Box<E::ModelEx>)

Implementationsยง

Sourceยง

impl<E: EntityTrait> HasOne<E>

Source

pub fn loaded<M: Into<E::ModelEx>>(model: M) -> Self

Construct a HasOne::Loaded value

Source

pub fn is_unloaded(&self) -> bool

Return true if variant is Unloaded

Source

pub fn is_not_found(&self) -> bool

Return true if variant is NotFound

Source

pub fn is_loaded(&self) -> bool

Return true if variant is Loaded

Source

pub fn is_none(&self) -> bool

True if variant is Unloaded or NotFound

Source

pub fn as_ref(&self) -> Option<&E::ModelEx>

Get a reference, if loaded

Source

pub fn as_mut(&mut self) -> Option<&mut E::ModelEx>

Get a mutable reference, if loaded

Source

pub fn into_option(self) -> Option<E::ModelEx>

Convert into an Option<ModelEx>

Source

pub fn take(&mut self) -> Option<E::ModelEx>

Take ownership of the contained Model, leaving Unloaded in place.

Source

pub fn unwrap(self) -> E::ModelEx

ยงPanics

Panics if called on Unloaded or NotFound values.

Sourceยง

impl<E> HasOne<E>

Trait Implementationsยง

Sourceยง

impl<E: Clone + EntityTrait> Clone for HasOne<E>
where E::ModelEx: Clone,

Sourceยง

fn clone(&self) -> HasOne<E>

Returns a duplicate of the value. Read more
1.0.0ยง

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

Performs copy-assignment from source. Read more
Sourceยง

impl<E: Debug + EntityTrait> Debug for HasOne<E>
where E::ModelEx: Debug,

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl<E: EntityTrait> Default for HasOne<E>

Sourceยง

fn default() -> HasOne<E>

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl<'de, E> Deserialize<'de> for HasOne<E>
where E: EntityTrait, E::ModelEx: Deserialize<'de>,

Available on crate feature with-json only.
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<E: EntityTrait> From<HasOne<E>> for Option<Box<E::ModelEx>>

Sourceยง

fn from(value: HasOne<E>) -> Self

Converts to this type from the input type.
Sourceยง

impl<E: EntityTrait> From<Option<Box<<E as EntityTrait>::ModelEx>>> for HasOne<E>

Sourceยง

fn from(value: Option<Box<E::ModelEx>>) -> Self

Converts to this type from the input type.
Sourceยง

impl<E> Hash for HasOne<E>
where E: EntityTrait, E::ModelEx: Hash,

Sourceยง

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0ยง

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Sourceยง

impl<E> PartialEq<HasOne<E>> for Option<Box<E::ModelEx>>

Sourceยง

fn eq(&self, other: &HasOne<E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0ยง

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<E> PartialEq<Option<Box<<E as EntityTrait>::ModelEx>>> for HasOne<E>

Sourceยง

fn eq(&self, other: &Option<Box<E::ModelEx>>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0ยง

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<E> PartialEq for HasOne<E>

Sourceยง

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0ยง

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<E> Serialize for HasOne<E>

Available on crate feature with-json only.
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<E> Eq for HasOne<E>
where E: EntityTrait, E::ModelEx: Eq,

Auto Trait Implementationsยง

ยง

impl<E> Freeze for HasOne<E>

ยง

impl<E> RefUnwindSafe for HasOne<E>

ยง

impl<E> Send for HasOne<E>
where <E as EntityTrait>::ModelEx: Send,

ยง

impl<E> Sync for HasOne<E>
where <E as EntityTrait>::ModelEx: Sync,

ยง

impl<E> Unpin for HasOne<E>

ยง

impl<E> UnwindSafe for HasOne<E>

Blanket Implementationsยง

ยง

impl<T> Any for T
where T: 'static + ?Sized,

ยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
ยง

impl<T> Borrow<T> for T
where T: ?Sized,

ยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
ยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

ยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
ยง

impl<T> CloneToUninit for T
where T: Clone,

ยง

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
ยง

impl<T> From<T> for T

ยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
ยง

impl<T, U> Into<U> for T
where U: From<T>,

ยง

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> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
ยง

impl<T> ToOwned for T
where T: Clone,

ยง

type Owned = T

The resulting type after obtaining ownership.
ยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
ยง

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

Uses borrowed data to replace owned data, usually by cloning. Read more
ยง

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
ยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

ยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
ยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

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