pub struct LiteralSql(/* private fields */);Expand description
A SQL fragment emitted verbatim into the query text, not bound as a
parameter (e.g. literal key names in json_build_object).
Because the contained text bypasses parameter binding, it must never carry
untrusted user input. This newtype makes that contract explicit: a value can
only be created through LiteralSql::from_static (compile-time safe) or
LiteralSql::trusted (a deliberately-named, greppable assertion that the
caller vetted the string). The inner String is private, so an
Expr::Literal can never be built directly from a bare runtime string.
Implementations§
Source§impl LiteralSql
impl LiteralSql
Sourcepub fn from_static(text: &'static str) -> Self
pub fn from_static(text: &'static str) -> Self
Build from a compile-time string. Always safe: a &'static str baked into
the binary can never be untrusted user input.
Sourcepub fn trusted(text: impl Into<String>) -> Self
pub fn trusted(text: impl Into<String>) -> Self
Build from a runtime string the caller asserts is trusted (e.g. a schema
column name), never raw user input. Prefer Self::from_static when the
value is known at compile time.
Trait Implementations§
Source§impl Clone for LiteralSql
impl Clone for LiteralSql
Source§fn clone(&self) -> LiteralSql
fn clone(&self) -> LiteralSql
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LiteralSql
impl Debug for LiteralSql
Source§impl PartialEq for LiteralSql
impl PartialEq for LiteralSql
Source§fn eq(&self, other: &LiteralSql) -> bool
fn eq(&self, other: &LiteralSql) -> bool
self and other values to be equal, and is used by ==.