Struct Relation

Source
pub struct Relation<M: Model> { /* private fields */ }
Expand description

A relation is a collection of records of a particular model and some metadata. associated with the relation.

Relation also implements typical CRUD operations, which are used by the database.

Implementations§

Source§

impl<M: Model> Relation<M>

Source

pub fn new_with_records(records: Vec<M>) -> Self

Creates a new relation with the given records.

It needs to be public, since it may be used by custom partitioned adapters (.e.g crate::adapters::CsvAdapter uses it).

Source

pub fn is_dirty(&self) -> bool

Is there any unsaved changes?

It needs to be public, since it’s invoked by the code generated with crate::state macro.

Source

pub fn reset_dirty(&mut self)

Resets the dirty flag to false.

It needs to be public, since it’s invoked by the code generated with crate::state macro.

Source

pub fn records(&self) -> &[M]

Returns reference to the records. This is intended to be used only by partitioned adapters.

Trait Implementations§

Source§

impl<M: Debug + Model> Debug for Relation<M>

Source§

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

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

impl<M> Default for Relation<M>
where M: Model,

Source§

fn default() -> Self

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

impl<'de, M: Model> Deserialize<'de> for Relation<M>

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<M: Model> Serialize for Relation<M>

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

Auto Trait Implementations§

§

impl<M> Freeze for Relation<M>

§

impl<M> RefUnwindSafe for Relation<M>
where M: RefUnwindSafe,

§

impl<M> Send for Relation<M>
where M: Send,

§

impl<M> Sync for Relation<M>
where M: Sync,

§

impl<M> Unpin for Relation<M>
where M: Unpin,

§

impl<M> UnwindSafe for Relation<M>
where M: 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<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>,