pub struct SettingRow {
pub key: String,
pub value: Value,
pub updated_at: DateTime<Utc>,
}Expand description
One row of settings: an app-wide key/value pair (e.g. the history-retention policy).
Fields§
§key: String§value: Value§updated_at: DateTime<Utc>Implementations§
Source§impl SettingRow
impl SettingRow
Sourcepub async fn get(pool: &SqlitePool, key: &str) -> DbResult<Option<Self>>
pub async fn get(pool: &SqlitePool, key: &str) -> DbResult<Option<Self>>
Loads one app-wide setting by key, returning None when it has not been stored yet.
The database constraint guarantees that value is syntactically valid JSON, but the
shape is intentionally left to the feature that owns the key. Parsing it here keeps
callers from having to duplicate the TEXT-to-JSON conversion.
Sourcepub async fn upsert(
pool: &SqlitePool,
key: &str,
value: &Value,
updated_at: DateTime<Utc>,
) -> DbResult<Self>
pub async fn upsert( pool: &SqlitePool, key: &str, value: &Value, updated_at: DateTime<Utc>, ) -> DbResult<Self>
Inserts or replaces one app-wide setting and returns the stored row.
updated_at is supplied by the caller so database tests and clock ownership remain
deterministic, matching the other repository methods in this module.
Trait Implementations§
Source§impl Clone for SettingRow
impl Clone for SettingRow
Source§fn clone(&self) -> SettingRow
fn clone(&self) -> SettingRow
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SettingRow
impl Debug for SettingRow
Source§impl PartialEq for SettingRow
impl PartialEq for SettingRow
Source§fn eq(&self, other: &SettingRow) -> bool
fn eq(&self, other: &SettingRow) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SettingRow
Auto Trait Implementations§
impl Freeze for SettingRow
impl RefUnwindSafe for SettingRow
impl Send for SettingRow
impl Sync for SettingRow
impl Unpin for SettingRow
impl UnsafeUnpin for SettingRow
impl UnwindSafe for SettingRow
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
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>
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 more