pub struct PrimaryKey<T>where
T: Display + 'static,{ /* private fields */ }
Expand description
Primary Key Type
The Primary Key is a column in a Table used to uniquely identify a row.
In GeekORM, it can be an i32
(default), a String
, or a Uuid
.
§Example
Here is an example of how to use the PrimaryKey struct with an integer
use geekorm::prelude::*;
#[derive(Table, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Users {
pub id: PrimaryKey<i32>,
pub username: String,
}
let user = Users {
id: PrimaryKey::from(1),
username: String::from("JohnDoe")
};
Here is an example of how to use the PrimaryKey struct with a String
use geekorm::prelude::*;
#[derive(Table, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Users {
pub id: PrimaryKey<String>,
pub username: String,
}
let user = Users {
id: PrimaryKey::from("1"),
username: String::from("JohnDoe")
};
Implementations§
Source§impl PrimaryKey<i32>
impl PrimaryKey<i32>
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 copy 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<'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<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<i32>> for Value
impl From<&PrimaryKey<i32>> 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<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: PrimaryKeyInteger) -> Self
fn from(value: PrimaryKeyInteger) -> 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: 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 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
impl<T> Copy for PrimaryKey<T>
impl<T> Eq for PrimaryKey<T>
impl<T> StructuralPartialEq for PrimaryKey<T>where
T: Display + '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