pub struct ColumnName(/* private fields */);Expand description
A strongly typed database identifier wrapper: ColumnName.
Implementations§
Source§impl ColumnName
impl ColumnName
Sourcepub fn new(input: impl AsRef<str>) -> Result<ColumnName, DatabaseNameError>
pub fn new(input: impl AsRef<str>) -> Result<ColumnName, 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 10)
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 ColumnName
impl AsRef<str> for ColumnName
Source§impl Clone for ColumnName
impl Clone for ColumnName
Source§fn clone(&self) -> ColumnName
fn clone(&self) -> ColumnName
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 ColumnName
impl Debug for ColumnName
Source§impl Display for ColumnName
impl Display for ColumnName
Source§impl FromStr for ColumnName
impl FromStr for ColumnName
Source§type Err = DatabaseNameError
type Err = DatabaseNameError
The associated error which can be returned from parsing.
Source§fn from_str(input: &str) -> Result<ColumnName, <ColumnName as FromStr>::Err>
fn from_str(input: &str) -> Result<ColumnName, <ColumnName as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for ColumnName
impl Hash for ColumnName
Source§impl Ord for ColumnName
impl Ord for ColumnName
Source§fn cmp(&self, other: &ColumnName) -> Ordering
fn cmp(&self, other: &ColumnName) -> 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 ColumnName
impl PartialEq for ColumnName
Source§fn eq(&self, other: &ColumnName) -> bool
fn eq(&self, other: &ColumnName) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ColumnName
impl PartialOrd for ColumnName
Source§impl TryFrom<&str> for ColumnName
impl TryFrom<&str> for ColumnName
Source§type Error = DatabaseNameError
type Error = DatabaseNameError
The type returned in the event of a conversion error.
Source§fn try_from(
value: &str,
) -> Result<ColumnName, <ColumnName as TryFrom<&str>>::Error>
fn try_from( value: &str, ) -> Result<ColumnName, <ColumnName as TryFrom<&str>>::Error>
Performs the conversion.
impl Eq for ColumnName
impl StructuralPartialEq for ColumnName
Auto Trait Implementations§
impl Freeze for ColumnName
impl RefUnwindSafe for ColumnName
impl Send for ColumnName
impl Sync for ColumnName
impl Unpin for ColumnName
impl UnsafeUnpin for ColumnName
impl UnwindSafe for ColumnName
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