pub struct ModelDelegate<'a, M, PK>where
M: 'static,
PK: 'static,{ /* private fields */ }Implementations§
Source§impl<'a, M, PK> ModelDelegate<'a, M, PK>where
M: 'static,
PK: 'static,
impl<'a, M, PK> ModelDelegate<'a, M, PK>where
M: 'static,
PK: 'static,
pub fn new( runtime: &'a SqlxRuntime, descriptor: &'static ModelDescriptor<M, PK>, ) -> ModelDelegate<'a, M, PK>
pub fn descriptor(&self) -> &'static ModelDescriptor<M, PK>
pub fn bind(self, ctx: CoolContext) -> ScopedModelDelegate<'a, M, PK>
pub fn find_many(&self) -> FindMany<'a, M, PK>
pub fn find_unique(&self, id: PK) -> FindUnique<'a, M, PK>
pub fn create<I>(&self, input: I) -> CreateRecord<'a, M, PK, I>
Sourcepub fn upsert<I>(&self, input: I) -> UpsertRecord<'a, M, PK, I>
pub fn upsert<I>(&self, input: I) -> UpsertRecord<'a, M, PK, I>
Insert-or-update on primary-key conflict. Available only on
models whose @id field is client-supplied (no @default(...));
attempting to call this on a model with a server-generated PK
is a compile error.
pub fn update(&self, id: PK) -> UpdateRecord<'a, M, PK>
Sourcepub fn update_many(&self) -> UpdateMany<'a, M, PK>
pub fn update_many(&self) -> UpdateMany<'a, M, PK>
Bulk UPDATE by predicate. Refuses to run without at least one filter — table-wide bulk updates are a footgun that should be written in raw SQL.
pub fn delete(&self, id: PK) -> DeleteRecord<'a, M, PK>
Sourcepub fn aggregate(&self) -> Aggregate<'a, M, PK>
pub fn aggregate(&self) -> Aggregate<'a, M, PK>
Side-effect-free aggregate read. Returns a builder that
branches into .count() / .sum(col) / .avg(col) /
.min(col) / .max(col). Aggregates apply the read policy
AND soft-delete column so the result always describes rows the
caller could retrieve via find_many.
Sourcepub fn delete_many(&self) -> DeleteMany<'a, M, PK>
pub fn delete_many(&self) -> DeleteMany<'a, M, PK>
Bulk DELETE by predicate. Mirrors update_many: applies the
delete policy and soft-delete column (if any), fans audit +
outbox out per-row via RETURNING, refuses to run without at
least one filter.
Source§impl<'a, M, PK> ModelDelegate<'a, M, PK>where
M: 'static,
PK: 'static,
impl<'a, M, PK> ModelDelegate<'a, M, PK>where
M: 'static,
PK: 'static,
Source§impl<'a, M, PK> ModelDelegate<'a, M, PK>where
M: 'static,
PK: 'static,
impl<'a, M, PK> ModelDelegate<'a, M, PK>where
M: 'static,
PK: 'static,
Sourcepub fn batch_get(&self, ids: Vec<PK>) -> BatchGet<'a, M, PK>
pub fn batch_get(&self, ids: Vec<PK>) -> BatchGet<'a, M, PK>
Fetch many rows by primary key in a single round-trip; missing
rows surface as per-item NotFound in the envelope rather
than aborting.
Sourcepub fn batch_create<I>(&self, inputs: Vec<I>) -> BatchCreate<'a, M, PK, I>
pub fn batch_create<I>(&self, inputs: Vec<I>) -> BatchCreate<'a, M, PK, I>
Insert many rows in one outer transaction; each input runs under a nested SAVEPOINT, so a per-item failure (validation, policy, unique conflict) doesn’t take down the rest of the batch.
Sourcepub fn batch_update<I>(
&self,
items: Vec<(PK, I, Option<i64>)>,
) -> BatchUpdate<'a, M, PK, I>
pub fn batch_update<I>( &self, items: Vec<(PK, I, Option<i64>)>, ) -> BatchUpdate<'a, M, PK, I>
Update many rows in one outer transaction with per-item
patches and optional if_match versions. Per-item failures
roll back at the savepoint; successful items commit together.
Sourcepub fn batch_delete(&self, ids: Vec<PK>) -> BatchDelete<'a, M, PK>
pub fn batch_delete(&self, ids: Vec<PK>) -> BatchDelete<'a, M, PK>
Delete many rows by primary key in a single statement; rows
that don’t exist (or that policy hid) surface as per-item
NotFound.
Sourcepub fn batch_upsert<I>(&self, inputs: Vec<I>) -> BatchUpsert<'a, M, PK, I>
pub fn batch_upsert<I>(&self, inputs: Vec<I>) -> BatchUpsert<'a, M, PK, I>
Insert-or-update many rows in one outer transaction with
per-item savepoints. Eligible only for models whose @id is
client-supplied — same compile-time gate as the single-row
.upsert(...).
Trait Implementations§
Source§impl<'a, M, PK> Clone for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Clone for ModelDelegate<'a, M, PK>
Source§fn clone(&self) -> ModelDelegate<'a, M, PK>
fn clone(&self) -> ModelDelegate<'a, M, PK>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a, M, PK> Debug for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Debug for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Copy for ModelDelegate<'a, M, PK>
Auto Trait Implementations§
impl<'a, M, PK> Freeze for ModelDelegate<'a, M, PK>
impl<'a, M, PK> !RefUnwindSafe for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Send for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Sync for ModelDelegate<'a, M, PK>
impl<'a, M, PK> Unpin for ModelDelegate<'a, M, PK>
impl<'a, M, PK> UnsafeUnpin for ModelDelegate<'a, M, PK>
impl<'a, M, PK> !UnwindSafe for ModelDelegate<'a, M, PK>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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> ⓘ
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> ⓘ
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<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].