Struct geekorm_core::builder::keys::primary::PrimaryKey
source · 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::{PrimaryKey};
use geekorm::prelude::*;
#[derive(Clone, GeekTable, Default)]
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::PrimaryKey;
use geekorm::prelude::*;
#[derive(Clone, GeekTable, Default)]
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 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§fn eq(&self, other: &PrimaryKey<T>) -> bool
fn eq(&self, other: &PrimaryKey<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)