pub struct PrimaryKey<T>where
T: Serialize + 'static,{ /* private fields */ }
Expand description
§Primary Key
The Primary Key is a column in a Table used to uniquely identify a row.
In GeekORM, it can be an u64
(default), a String
, or a Uuid
.
§Standard Example
Here is an example of how to use the PrimaryKey.
use geekorm::prelude::*;
#[derive(Table, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Users {
#[geekorm(primary_key, auto_increment)]
pub id: PrimaryKey<u64>,
#[geekorm(unique)]
pub username: String,
}
let user = Users {
id: PrimaryKey::from(1),
username: String::from("JohnDoe")
};
Implementations§
Source§impl<T> PrimaryKey<T>where
T: Serialize + 'static,
impl<T> PrimaryKey<T>where
T: Serialize + 'static,
Source§impl PrimaryKey<u64>
impl PrimaryKey<u64>
Source§impl PrimaryKey<String>
impl PrimaryKey<String>
Trait Implementations§
Source§impl<T> Clone for PrimaryKey<T>
impl<T> Clone for PrimaryKey<T>
Source§fn clone(&self) -> PrimaryKey<T>
fn clone(&self) -> PrimaryKey<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T> Debug for PrimaryKey<T>
impl<T> Debug for PrimaryKey<T>
Source§impl Default for PrimaryKey<i32>
impl Default for PrimaryKey<i32>
Source§impl<'de> Deserialize<'de> for PrimaryKey<String>
impl<'de> Deserialize<'de> for PrimaryKey<String>
Source§fn deserialize<D>(deserializer: D) -> Result<PrimaryKey<String>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<PrimaryKey<String>, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'de> Deserialize<'de> for PrimaryKey<Uuid>
impl<'de> Deserialize<'de> for PrimaryKey<Uuid>
Source§fn deserialize<D>(deserializer: D) -> Result<PrimaryKeyUuid, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<PrimaryKeyUuid, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'de> Deserialize<'de> for PrimaryKey<i32>
For backwards compatibility
impl<'de> Deserialize<'de> for PrimaryKey<i32>
For backwards compatibility
Source§fn deserialize<D>(deserializer: D) -> Result<PrimaryKey<i32>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<PrimaryKey<i32>, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Display for PrimaryKey<T>
impl<T> Display for PrimaryKey<T>
Source§impl From<&PrimaryKey<String>> for Value
impl From<&PrimaryKey<String>> for Value
Source§fn from(value: &PrimaryKey<String>) -> Self
fn from(value: &PrimaryKey<String>) -> Self
Converts to this type from the input type.
Source§impl From<&PrimaryKey<Uuid>> for Value
impl From<&PrimaryKey<Uuid>> for Value
Source§fn from(value: &PrimaryKeyUuid) -> Self
fn from(value: &PrimaryKeyUuid) -> Self
Converts to this type from the input type.
Source§impl From<&PrimaryKey<i32>> for Value
impl From<&PrimaryKey<i32>> for Value
Source§fn from(value: &PrimaryKey<i32>) -> Self
fn from(value: &PrimaryKey<i32>) -> Self
Converts to this type from the input type.
Source§impl From<&PrimaryKey<i32>> for i32
impl From<&PrimaryKey<i32>> for i32
Source§fn from(value: &PrimaryKey<i32>) -> Self
fn from(value: &PrimaryKey<i32>) -> Self
Converts to this type from the input type.
Source§impl From<&PrimaryKey<i32>> for u64
impl From<&PrimaryKey<i32>> for u64
Source§fn from(value: &PrimaryKey<i32>) -> Self
fn from(value: &PrimaryKey<i32>) -> Self
Converts to this type from the input type.
Source§impl From<&PrimaryKey<u64>> for Value
impl From<&PrimaryKey<u64>> for Value
Source§fn from(value: &PrimaryKeyInteger) -> Self
fn from(value: &PrimaryKeyInteger) -> Self
Converts to this type from the input type.
Source§impl<D> From<PrimaryKey<String>> for ForeignKey<String, D>where
D: TableBuilder + Default,
impl<D> From<PrimaryKey<String>> for ForeignKey<String, D>where
D: TableBuilder + Default,
Source§fn from(value: PrimaryKey<String>) -> Self
fn from(value: PrimaryKey<String>) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<String>> for String
impl From<PrimaryKey<String>> for String
Source§fn from(value: PrimaryKey<String>) -> Self
fn from(value: PrimaryKey<String>) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<String>> for Value
impl From<PrimaryKey<String>> for Value
Source§fn from(value: PrimaryKey<String>) -> Self
fn from(value: PrimaryKey<String>) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<Uuid>> for Value
impl From<PrimaryKey<Uuid>> for Value
Source§fn from(value: PrimaryKeyUuid) -> Self
fn from(value: PrimaryKeyUuid) -> Self
Converts to this type from the input type.
Source§impl<D> From<PrimaryKey<i32>> for ForeignKey<i32, D>where
D: TableBuilder + Default,
impl<D> From<PrimaryKey<i32>> for ForeignKey<i32, D>where
D: TableBuilder + Default,
Source§fn from(value: PrimaryKey<i32>) -> Self
fn from(value: PrimaryKey<i32>) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<i32>> for Value
impl From<PrimaryKey<i32>> for Value
Source§fn from(value: PrimaryKey<i32>) -> Self
fn from(value: PrimaryKey<i32>) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<i32>> for i32
impl From<PrimaryKey<i32>> for i32
Source§fn from(value: PrimaryKey<i32>) -> Self
fn from(value: PrimaryKey<i32>) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<i32>> for u64
impl From<PrimaryKey<i32>> for u64
Source§fn from(value: PrimaryKey<i32>) -> Self
fn from(value: PrimaryKey<i32>) -> Self
Converts to this type from the input type.
Source§impl<D> From<PrimaryKey<u64>> for ForeignKey<u64, D>where
D: TableBuilder + Default,
impl<D> From<PrimaryKey<u64>> for ForeignKey<u64, D>where
D: TableBuilder + Default,
Source§fn from(value: PrimaryKey<u64>) -> Self
fn from(value: PrimaryKey<u64>) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<u64>> for Value
impl From<PrimaryKey<u64>> for Value
Source§fn from(value: PrimaryKeyInteger) -> Self
fn from(value: PrimaryKeyInteger) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<u64>> for i32
This is to make sure we are backwards compatible
impl From<PrimaryKey<u64>> for i32
This is to make sure we are backwards compatible
Source§fn from(value: PrimaryKeyInteger) -> Self
fn from(value: PrimaryKeyInteger) -> Self
Converts to this type from the input type.
Source§impl From<PrimaryKey<u64>> for u64
impl From<PrimaryKey<u64>> for u64
Source§fn from(value: PrimaryKeyInteger) -> Self
fn from(value: PrimaryKeyInteger) -> Self
Converts to this type from the input type.
Source§impl<T> PartialEq for PrimaryKey<T>
impl<T> PartialEq for PrimaryKey<T>
Source§impl Serialize for PrimaryKey<String>
impl Serialize for PrimaryKey<String>
Source§impl Serialize for PrimaryKey<Uuid>
impl Serialize for PrimaryKey<Uuid>
Source§impl Serialize for PrimaryKey<i32>
impl Serialize for PrimaryKey<i32>
Source§impl ToSqlite for PrimaryKey<String>
impl ToSqlite for PrimaryKey<String>
Source§fn on_create(&self, _query: &QueryBuilder) -> Result<String, Error>
fn on_create(&self, _query: &QueryBuilder) -> Result<String, Error>
Convert to SQLite for creating a table
Source§fn on_select(&self, query: &QueryBuilder) -> Result<String, Error>
fn on_select(&self, query: &QueryBuilder) -> Result<String, Error>
Convert to SQLite for selecting a row
Source§fn on_insert(&self, query: &QueryBuilder) -> Result<(String, Values), Error>
fn on_insert(&self, query: &QueryBuilder) -> Result<(String, Values), Error>
Convert to SQLite for inserting a row
Source§fn on_update(&self, query: &QueryBuilder) -> Result<(String, Values), Error>
fn on_update(&self, query: &QueryBuilder) -> Result<(String, Values), Error>
Convert to SQLite for updating a row
impl<T> Copy for PrimaryKey<T>
impl<T> Eq for PrimaryKey<T>
impl<T> StructuralPartialEq for PrimaryKey<T>where
T: Serialize + 'static,
Auto Trait Implementations§
impl<T> Freeze for PrimaryKey<T>where
T: Freeze,
impl<T> RefUnwindSafe for PrimaryKey<T>where
T: RefUnwindSafe,
impl<T> Send for PrimaryKey<T>where
T: Send,
impl<T> Sync for PrimaryKey<T>where
T: Sync,
impl<T> Unpin for PrimaryKey<T>where
T: Unpin,
impl<T> UnwindSafe for PrimaryKey<T>where
T: 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request