pub struct HasOne<P, C>(/* private fields */);Expand description
One parent, one child.
The same query as HasMany; the difference is that you read it with
Related::one. A second matching row is not an error here, because the
database is where uniqueness belongs: put a unique index on the foreign key
and the question cannot arise.
Implementations§
Trait Implementations§
Source§impl<P, C> Relation<P> for HasOne<P, C>
impl<P, C> Relation<P> for HasOne<P, C>
Source§fn far_key(&self) -> &str
fn far_key(&self) -> &str
The column on the other side that this relationship matches against.
Source§fn load<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Related<C>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasOne<P, C>: 'async_trait,
fn load<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Related<C>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasOne<P, C>: 'async_trait,
Load the related rows for every parent, in one query.
Source§fn count<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<RelatedCounts, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasOne<P, C>: 'async_trait,
fn count<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<RelatedCounts, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasOne<P, C>: 'async_trait,
Count the related rows for every parent, in one query, without
transferring them.
Source§fn for_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parent: &'life1 P,
related: &'life2 (dyn Repository<Self::Related> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Related>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sized + 'async_trait,
fn for_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parent: &'life1 P,
related: &'life2 (dyn Repository<Self::Related> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Related>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sized + 'async_trait,
Load for a single parent. Read more
Auto Trait Implementations§
impl<P, C> Freeze for HasOne<P, C>
impl<P, C> RefUnwindSafe for HasOne<P, C>where
HasMany<P, C>: RefUnwindSafe,
impl<P, C> Send for HasOne<P, C>
impl<P, C> Sync for HasOne<P, C>
impl<P, C> Unpin for HasOne<P, C>
impl<P, C> UnsafeUnpin for HasOne<P, C>where
HasMany<P, C>: UnsafeUnpin,
impl<P, C> UnwindSafe for HasOne<P, C>where
HasMany<P, C>: UnwindSafe,
Blanket Implementations§
impl<T> Actor for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreCreates a shared type from an unshared type.