Expand description
SQL escaping utilities.
This module provides zero-cost wrapper types for safe SQL escaping.
Using the newtype pattern with std::fmt::Display ensures identifiers
and literals are properly escaped at format-time without extra allocations.
§Why Newtype + Display?
The alternative – a function like fn escape_identifier(s: &str) -> String
– allocates immediately even when the result is only used inside a larger
format!() call. The newtype pattern defers escaping to Display::fmt,
so the escaped output is written directly into the destination buffer.
This is the same approach used by std::path::Path::display().
The convenience functions escape_identifier and escape_literal are
provided for cases where a String is needed directly.
Structs§
- SqlIdentifier
- A wrapper that ensures a SQL identifier is properly escaped when formatted.
- SqlLiteral
- A wrapper that ensures a SQL string literal is properly escaped when formatted.
Functions§
- escape_
identifier - Escapes a SQL identifier (table name, column name, etc.).
- escape_
literal - Escapes a SQL string literal.
- format_
table_ name - Formats a qualified table name with proper escaping.
- is_
valid_ unquoted_ identifier - Checks if a string is a valid unquoted identifier.