Iden

Trait Iden 

pub trait Iden {
    // Required method
    fn unquoted(&self) -> &str;

    // Provided methods
    fn quoted(&self) -> Cow<'static, str> { ... }
    fn to_string(&self) -> String { ... }
}
Expand description

Identifier

Required Methods§

fn unquoted(&self) -> &str

Write a raw identifier string without quotes.

We intentionally don’t reuse Display for this, because we want to allow it to have a different logic.

Provided Methods§

fn quoted(&self) -> Cow<'static, str>

Return the to-be sanitized version of the identifier.

For example, for MySQL “hello” would have to be escaped as “hel``lo”. Note that this method doesn’t do the actual escape, as it’s backend specific. It only indicates whether the identifier needs to be escaped.

If the identifier doesn’t need to be escaped, return 'static str. This can be deduced at compile-time by the Iden macro, or using the is_static_iden function.

Cow::Owned would always be escaped.

fn to_string(&self) -> String

A shortcut for writing an unquoted identifier into a String.

We can’t reuse ToString for this, because ToString uses the Display representation. But Iden representation is distinct from Display and can be different.

Implementations on Foreign Types§

§

impl Iden for &'static str

§

fn quoted(&self) -> Cow<'static, str>

§

fn unquoted(&self) -> &str

Implementors§

§

impl Iden for MsType

§

impl Iden for MySqlType

§

impl Iden for PgLTree

§

impl Iden for Alias

§

impl Iden for NullAlias