pub enum Key {
Int(i64),
Text(String),
}Expand description
A primary key value, normalized.
posts.id may be INTEGER while comments.commentable_id is BIGINT or even
VARCHAR; all three hold the same key. Key lets the crate match them up and
write a key into any of those columns.
Variants§
Implementations§
Source§impl Key
impl Key
Sourcepub fn of<M>(model: &M) -> Option<Key>where
M: ModelTrait,
pub fn of<M>(model: &M) -> Option<Key>where
M: ModelTrait,
The primary key of model.
§Panics
If the entity has a composite primary key; relations here link single keys.
Sourcepub fn from_value(value: &Value) -> Option<Key>
pub fn from_value(value: &Value) -> Option<Key>
The key a column value holds, or None for NULL and types that are not keys.
A string holding a canonical integer ("15", not "015") becomes
Key::Int, so a VARCHAR morph column matches an integer primary key.
Sourcepub fn to_value_for<C>(&self, column: C) -> Result<Value, DbErr>where
C: ColumnTrait,
pub fn to_value_for<C>(&self, column: C) -> Result<Value, DbErr>where
C: ColumnTrait,
This key as a value of the type column stores, ready to be written to it
or compared with it.
§Errors
When the key does not fit: a negative key in an unsigned column, a word in an integer column, a non-UUID in a UUID column.
Trait Implementations§
impl Eq for Key
Source§impl Ord for Key
impl Ord for Key
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Key
impl PartialOrd for Key
impl StructuralPartialEq for Key
Auto Trait Implementations§
impl Forget for Key
impl Freeze for Key
impl Move for Key
impl RefUnwindSafe for Key
impl Send for Keywhere
RawVecInner: Send,
impl Sync for Keywhere
RawVecInner: Sync,
impl Unpin for Key
impl UnsafeUnpin for Key
impl UnwindSafe for Keywhere
RawVecInner: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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