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>

source

pub fn new(value: i32) -> Self

Create a new primary key with an integer

source§

impl PrimaryKey<String>

source

pub fn new(value: String) -> Self

Create a new primary key with a String

Trait Implementations§

source§

impl<T> Clone for PrimaryKey<T>
where T: Display + 'static + Clone,

source§

fn clone(&self) -> PrimaryKey<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for PrimaryKey<T>
where T: Debug + Display + 'static,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for PrimaryKey<String>

source§

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

source§

fn from(value: &PrimaryKey<String>) -> Self

Converts to this type from the input type.
source§

impl From<&PrimaryKey<i32>> for Value

source§

fn from(value: &PrimaryKeyInteger) -> Self

Converts to this type from the input type.
source§

impl From<&String> for PrimaryKey<String>

source§

fn from(value: &String) -> Self

Converts to this type from the input type.
source§

impl From<&str> for PrimaryKey<String>

source§

fn from(value: &str) -> Self

Converts to this type from the input type.
source§

impl<D> From<PrimaryKey<String>> for ForeignKey<String, D>
where D: TableBuilder + Default,

source§

fn from(value: PrimaryKey<String>) -> Self

Converts to this type from the input type.
source§

impl From<PrimaryKey<String>> for String

source§

fn from(value: PrimaryKey<String>) -> Self

Converts to this type from the input type.
source§

impl From<PrimaryKey<String>> for Value

source§

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,

source§

fn from(value: PrimaryKey<i32>) -> Self

Converts to this type from the input type.
source§

impl From<PrimaryKey<i32>> for Value

source§

fn from(value: PrimaryKeyInteger) -> Self

Converts to this type from the input type.
source§

impl From<PrimaryKey<i32>> for i32

source§

fn from(value: PrimaryKeyInteger) -> Self

Converts to this type from the input type.
source§

impl From<String> for PrimaryKey<String>

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl<T> PartialEq for PrimaryKey<T>
where T: Display + 'static + PartialEq,

source§

fn eq(&self, other: &PrimaryKey<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for PrimaryKey<String>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToSqlite for PrimaryKey<String>

source§

fn on_create(&self, _query: &QueryBuilder) -> Result<String, Error>

Convert to SQLite for creating a table
source§

fn to_sqlite(&self) -> String

Convert to generic SQLite (only use for some generic types)
source§

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>

Convert to SQLite for inserting a row
source§

fn on_update(&self, query: &QueryBuilder) -> Result<(String, Values), Error>

Convert to SQLite for updating a row
source§

impl<T> Copy for PrimaryKey<T>
where T: Display + 'static + Copy,

source§

impl<T> Eq for PrimaryKey<T>
where T: Display + 'static + Eq,

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,