Join

Enum Join 

Source
pub enum Join<E>
where E: Keyed,
{ Entity(Box<E>), Key(<E as Keyed>::Key), }
Expand description

The Join struct that hold either an entity or its key.

Variants§

§

Entity(Box<E>)

Full entity is held. The entity is wrapped inside a Box. That does allow circular dependencies, in theory. In practice the compiler goes wild :(

§

Key(<E as Keyed>::Key)

The entities key

Implementations§

Source§

impl<T> Join<T>
where T: Keyed,

Source

pub fn with_entity(entity: T) -> Join<T>

Constructs join for entity

Source

pub fn with_key(key: impl Into<<T as Keyed>::Key>) -> Join<T>

Constructs join for key

Source

pub fn entity(&self) -> Option<&T>

Returns entity or None, if key is held.

Source

pub fn entity_mut(&mut self) -> Option<&mut T>

Returns mutable entity or None, if key is held.

Source

pub fn entity_or_err<E>(&self, err: E) -> Result<&T, E>

Returns entity or error E, if key is held.

Source

pub fn entity_mut_or_err<E>(&mut self, err: E) -> Result<&mut T, E>

Returns mut entity or error E, if key is held.

Source

pub fn key(&self) -> <T as Keyed>::Key
where <T as Keyed>::Key: Clone,

Returns a key. If entity is held, key is taken from that entity

Source

pub fn into_entity(self) -> Result<T, ToqlError>

Unwraps join into its entity. Can fail

Trait Implementations§

Source§

impl<E> Clone for Join<E>
where E: Clone + Keyed, <E as Keyed>::Key: Clone,

Source§

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

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<E> Debug for Join<E>
where E: Debug + Keyed, <E as Keyed>::Key: Debug,

Source§

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

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

impl<E> Default for Join<E>
where E: Default + Keyed,

Source§

fn default() -> Join<E>

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

impl<T, R, E> FromRow<R, E> for Join<T>
where T: Keyed + FromRow<R, E>, E: From<ToqlError>,

Source§

fn forward<'a, I>(iter: &mut I) -> Result<usize, E>
where I: Iterator<Item = &'a Select>, Join<T>: Sized,

Returns the number of selects This is needed to advance the iterator and the row index. The Deserializer needs this information to skip left joins that have fields selected but are null. Those left joins cause select information in the select stream that must be skipped.
Source§

fn from_row<'a, I>( row: &R, i: &mut usize, iter: &mut I, ) -> Result<Option<Join<T>>, E>
where I: Iterator<Item = &'a Select> + Clone, Join<T>: Sized,

Read row values into struct, starting from index. Advances iter and index Returns None for value unselected values or joined entities that have null keys. Return Error, if value is selected, but cannot be converted.
Source§

impl<T> KeyFields for Join<T>
where T: KeyFields + Keyed, <T as Keyed>::Key: KeyFields,

Source§

type Entity = <T as KeyFields>::Entity

Source§

fn fields() -> Vec<String>

Return primary key fields for a given entity.
Source§

fn params(&self) -> Vec<SqlArg>

Return key values as params. Useful to loop across a composite key.
Source§

impl<T> Keyed for &Join<T>
where T: Keyed, <T as Keyed>::Key: Clone,

Source§

type Key = <T as Keyed>::Key

Type of key.
Source§

fn key(&self) -> <T as Keyed>::Key

Return value of the key for a given entity.
Source§

impl<T> Keyed for Join<T>
where T: Keyed, <T as Keyed>::Key: Clone,

Source§

type Key = <T as Keyed>::Key

Type of key.
Source§

fn key(&self) -> <T as Keyed>::Key

Return value of the key for a given entity.
Source§

impl<T> KeyedMut for Join<T>
where T: KeyedMut, <T as Keyed>::Key: Clone,

Source§

fn set_key(&mut self, key: <T as Keyed>::Key)

Set the key of the implementing struct.
Source§

impl<E> PartialEq for Join<E>
where E: PartialEq + Keyed, <E as Keyed>::Key: PartialEq,

Source§

fn eq(&self, other: &Join<E>) -> 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> TreeIdentity for Join<T>
where T: Keyed + TreeIdentity, <T as Keyed>::Key: Clone + TryFrom<Vec<SqlArg>, Error = ToqlError>,

Source§

fn auto_id<'a, I>(descendents: I) -> Result<bool, ToqlError>
where I: Iterator<Item = FieldPath<'a>>,

Returns true, if struct located at descendents has database generated keys.
Source§

fn set_id<'a, 'b, I>( &mut self, descendents: I, action: &'b IdentityAction, ) -> Result<(), ToqlError>
where I: Iterator<Item = FieldPath<'a>> + Clone,

Set or refresh keys of structs located at descendents.
Source§

impl<T, R, E> TreeIndex<R, E> for Join<T>
where T: Keyed + TreeIndex<R, E>, E: From<ToqlError>,

Source§

fn index<'a, I>( descendents: I, rows: &[R], row_offset: usize, index: &mut HashMap<u64, Vec<usize>>, ) -> Result<(), E>
where I: Iterator<Item = FieldPath<'a>> + Clone,

Source§

impl<T> TreeInsert for Join<T>
where T: Keyed + TreeInsert + Mapped, <T as Keyed>::Key: Key + Clone,

Source§

fn columns<'a, I>(descendents: I) -> Result<SqlExpr, ToqlError>
where I: Iterator<Item = FieldPath<'a>>,

Return columns of struct located at descendents.
Source§

fn values<'a, 'b, I, J>( &self, descendents: I, roles: &HashSet<String>, should_insert: &mut J, values: &mut SqlExpr, ) -> Result<(), ToqlError>
where I: Iterator<Item = FieldPath<'a>> + Clone, J: Iterator<Item = &'b bool>,

Return values of structs located at descendents. The should_insert argument allows the method to only insert a part of the collection. This is needed to deal with newly added merges.
Source§

impl<T, R, E> TreeMerge<R, E> for Join<T>
where T: Keyed + TreeMerge<R, E>, E: From<ToqlError>,

Source§

fn merge<'a, I>( &mut self, descendents: I, field: &str, rows: &[R], row_offset: usize, index: &HashMap<u64, Vec<usize>>, selection_stream: &SelectStream, ) -> Result<(), E>
where I: Iterator<Item = FieldPath<'a>> + Clone,

Source§

impl<T> TreePredicate for Join<T>
where T: Keyed + TreePredicate, <T as Keyed>::Key: Clone,

Source§

fn columns<'a, I>(descendents: I) -> Result<Vec<String>, ToqlError>
where I: Iterator<Item = FieldPath<'a>>,

Return the key column names
Source§

fn args<'a, I>( &self, descendents: I, args: &mut Vec<SqlArg>, ) -> Result<(), ToqlError>
where I: Iterator<Item = FieldPath<'a>> + Clone,

Return the key column values
Source§

impl<T> TreeUpdate for Join<T>
where T: Keyed + TreeUpdate + Mapped, <T as Keyed>::Key: Key + Clone,

Source§

fn update<'a, I>( &self, descendents: I, fields: &HashSet<String>, roles: &HashSet<String>, exprs: &mut Vec<SqlExpr>, ) -> Result<(), ToqlError>
where I: Iterator<Item = FieldPath<'a>> + Clone,

Source§

impl<E> Eq for Join<E>
where E: Eq + Keyed, <E as Keyed>::Key: Eq,

Source§

impl<E> StructuralPartialEq for Join<E>
where E: Keyed,

Auto Trait Implementations§

§

impl<E> Freeze for Join<E>
where <E as Keyed>::Key: Freeze,

§

impl<E> RefUnwindSafe for Join<E>
where <E as Keyed>::Key: RefUnwindSafe, E: RefUnwindSafe,

§

impl<E> Send for Join<E>
where <E as Keyed>::Key: Send, E: Send,

§

impl<E> Sync for Join<E>
where <E as Keyed>::Key: Sync, E: Sync,

§

impl<E> Unpin for Join<E>
where <E as Keyed>::Key: Unpin,

§

impl<E> UnwindSafe for Join<E>
where <E as Keyed>::Key: UnwindSafe, E: 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> 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
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> 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