pub struct Tracked<E: Entity> { /* private fields */ }Expand description
Implementations§
Source§impl<E: Entity> Tracked<E>
impl<E: Entity> Tracked<E>
Sourcepub fn new(entity: E) -> Self
pub fn new(entity: E) -> Self
Wrap an in-hand entity; its current column values become the baseline.
Sourcepub async fn load<X, V>(exec: &X, pk: V) -> Result<Option<Self>>
pub async fn load<X, V>(exec: &X, pk: V) -> Result<Option<Self>>
Load pk’s row and wrap it for tracking. None when no row matches.
Sourcepub fn changes(&self) -> Vec<(&'static str, Value)>
pub fn changes(&self) -> Vec<(&'static str, Value)>
The columns whose value differs from the baseline (the dirty set), in the entity’s declared column order.
Sourcepub async fn save<X: Executor>(&mut self, exec: &X) -> Result<u64>
pub async fn save<X: Executor>(&mut self, exec: &X) -> Result<u64>
Persist the dirty columns with a single UPDATE … WHERE pk = ?, returning
rows affected. A no-op returning 0 when nothing changed. On success the
baseline is reset to the saved state, so a later save writes only newer
changes (and an immediate re-save is a no-op).
Sourcepub fn into_inner(self) -> E
pub fn into_inner(self) -> E
Unwrap, discarding tracking state.
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for Tracked<E>where
E: Freeze,
impl<E> RefUnwindSafe for Tracked<E>where
E: RefUnwindSafe,
impl<E> Send for Tracked<E>where
E: Send,
impl<E> Sync for Tracked<E>where
E: Sync,
impl<E> Unpin for Tracked<E>where
E: Unpin,
impl<E> UnsafeUnpin for Tracked<E>where
E: UnsafeUnpin,
impl<E> UnwindSafe for Tracked<E>where
E: UnwindSafe,
Blanket Implementations§
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