pub struct SchemaName(/* private fields */);Expand description
A strongly typed database identifier wrapper: SchemaName.
Implementations§
Source§impl SchemaName
impl SchemaName
Sourcepub fn new(input: impl AsRef<str>) -> Result<SchemaName, DatabaseNameError>
pub fn new(input: impl AsRef<str>) -> Result<SchemaName, DatabaseNameError>
Creates a database identifier from non-empty text.
§Errors
Returns DatabaseNameError when the value is empty or contains control characters.
Examples found in repository?
examples/basic_usage.rs (line 8)
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 fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the stored identifier text.
Examples found in repository?
examples/basic_usage.rs (line 17)
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 fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the identifier and returns the owned string.
Trait Implementations§
Source§impl AsRef<str> for SchemaName
impl AsRef<str> for SchemaName
Source§impl Clone for SchemaName
impl Clone for SchemaName
Source§fn clone(&self) -> SchemaName
fn clone(&self) -> SchemaName
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 SchemaName
impl Debug for SchemaName
Source§impl Display for SchemaName
impl Display for SchemaName
Source§impl FromStr for SchemaName
impl FromStr for SchemaName
Source§type Err = DatabaseNameError
type Err = DatabaseNameError
The associated error which can be returned from parsing.
Source§fn from_str(input: &str) -> Result<SchemaName, <SchemaName as FromStr>::Err>
fn from_str(input: &str) -> Result<SchemaName, <SchemaName as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for SchemaName
impl Hash for SchemaName
Source§impl Ord for SchemaName
impl Ord for SchemaName
Source§fn cmp(&self, other: &SchemaName) -> Ordering
fn cmp(&self, other: &SchemaName) -> 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 SchemaName
impl PartialEq for SchemaName
Source§fn eq(&self, other: &SchemaName) -> bool
fn eq(&self, other: &SchemaName) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for SchemaName
impl PartialOrd for SchemaName
Source§impl TryFrom<&str> for SchemaName
impl TryFrom<&str> for SchemaName
Source§type Error = DatabaseNameError
type Error = DatabaseNameError
The type returned in the event of a conversion error.
Source§fn try_from(
value: &str,
) -> Result<SchemaName, <SchemaName as TryFrom<&str>>::Error>
fn try_from( value: &str, ) -> Result<SchemaName, <SchemaName as TryFrom<&str>>::Error>
Performs the conversion.
impl Eq for SchemaName
impl StructuralPartialEq for SchemaName
Auto Trait Implementations§
impl Freeze for SchemaName
impl RefUnwindSafe for SchemaName
impl Send for SchemaName
impl Sync for SchemaName
impl Unpin for SchemaName
impl UnsafeUnpin for SchemaName
impl UnwindSafe for SchemaName
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