pub struct PrimaryKey { /* private fields */ }Expand description
Primary key metadata.
Implementations§
Source§impl PrimaryKey
impl PrimaryKey
Sourcepub const fn new(table: TableName, column: ColumnName) -> PrimaryKey
pub const fn new(table: TableName, column: ColumnName) -> PrimaryKey
Creates single-column primary key metadata.
Examples found in repository?
examples/basic_usage.rs (line 12)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let database = DatabaseName::new("app")?;
8 let schema = SchemaName::new("public")?;
9 let table = TableName::new("users")?;
10 let column = ColumnName::new("id")?;
11
12 let primary_key = PrimaryKey::new(table.clone(), column.clone());
13 let page = PageRequest::new(1, 50);
14 let isolation = TransactionIsolation::Serializable;
15
16 assert_eq!(database.as_str(), "app");
17 assert_eq!(schema.as_str(), "public");
18 assert_eq!(primary_key.table(), &table);
19 assert_eq!(primary_key.column(), &column);
20 assert_eq!(page.per_page(), 50);
21 assert_eq!(SortDirection::Ascending.as_str(), "ascending");
22 assert_eq!(isolation.as_str(), "serializable");
23
24 Ok(())
25}Sourcepub const fn table(&self) -> &TableName
pub const fn table(&self) -> &TableName
Returns the table name.
Examples found in repository?
examples/basic_usage.rs (line 18)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let database = DatabaseName::new("app")?;
8 let schema = SchemaName::new("public")?;
9 let table = TableName::new("users")?;
10 let column = ColumnName::new("id")?;
11
12 let primary_key = PrimaryKey::new(table.clone(), column.clone());
13 let page = PageRequest::new(1, 50);
14 let isolation = TransactionIsolation::Serializable;
15
16 assert_eq!(database.as_str(), "app");
17 assert_eq!(schema.as_str(), "public");
18 assert_eq!(primary_key.table(), &table);
19 assert_eq!(primary_key.column(), &column);
20 assert_eq!(page.per_page(), 50);
21 assert_eq!(SortDirection::Ascending.as_str(), "ascending");
22 assert_eq!(isolation.as_str(), "serializable");
23
24 Ok(())
25}Sourcepub const fn column(&self) -> &ColumnName
pub const fn column(&self) -> &ColumnName
Returns the column name.
Examples found in repository?
examples/basic_usage.rs (line 19)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let database = DatabaseName::new("app")?;
8 let schema = SchemaName::new("public")?;
9 let table = TableName::new("users")?;
10 let column = ColumnName::new("id")?;
11
12 let primary_key = PrimaryKey::new(table.clone(), column.clone());
13 let page = PageRequest::new(1, 50);
14 let isolation = TransactionIsolation::Serializable;
15
16 assert_eq!(database.as_str(), "app");
17 assert_eq!(schema.as_str(), "public");
18 assert_eq!(primary_key.table(), &table);
19 assert_eq!(primary_key.column(), &column);
20 assert_eq!(page.per_page(), 50);
21 assert_eq!(SortDirection::Ascending.as_str(), "ascending");
22 assert_eq!(isolation.as_str(), "serializable");
23
24 Ok(())
25}Trait Implementations§
Source§impl Clone for PrimaryKey
impl Clone for PrimaryKey
Source§fn clone(&self) -> PrimaryKey
fn clone(&self) -> PrimaryKey
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PrimaryKey
impl Debug for PrimaryKey
Source§impl Hash for PrimaryKey
impl Hash for PrimaryKey
Source§impl Ord for PrimaryKey
impl Ord for PrimaryKey
Source§fn cmp(&self, other: &PrimaryKey) -> Ordering
fn cmp(&self, other: &PrimaryKey) -> Ordering
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
Source§impl PartialEq for PrimaryKey
impl PartialEq for PrimaryKey
Source§fn eq(&self, other: &PrimaryKey) -> bool
fn eq(&self, other: &PrimaryKey) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for PrimaryKey
impl PartialOrd for PrimaryKey
impl Eq for PrimaryKey
impl StructuralPartialEq for PrimaryKey
Auto Trait Implementations§
impl Freeze for PrimaryKey
impl RefUnwindSafe for PrimaryKey
impl Send for PrimaryKey
impl Sync for PrimaryKey
impl Unpin for PrimaryKey
impl UnsafeUnpin for PrimaryKey
impl UnwindSafe for PrimaryKey
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