pub struct EscapedLiteral { /* private fields */ }Expand description
A PostgreSQL string literal that has been safely escaped.
The value is escaped at construction time using PostgreSQL’s quote_literal rules:
- Wrapped in single quotes
- Any embedded single quotes are doubled
- If backslashes are present, prefixed with
Eand backslashes are doubled
§Example
use spawn_db::escape::EscapedLiteral;
let value = EscapedLiteral::new("hello");
assert_eq!(value.as_str(), "'hello'");
let quoted = EscapedLiteral::new("it's");
assert_eq!(quoted.as_str(), "'it''s'");Implementations§
Source§impl EscapedLiteral
impl EscapedLiteral
Sourcepub fn new(raw: &str) -> Self
pub fn new(raw: &str) -> Self
Creates a new escaped literal from a raw string.
The input is immediately escaped using PostgreSQL’s literal escaping rules.
Trait Implementations§
Source§impl Clone for EscapedLiteral
impl Clone for EscapedLiteral
Source§fn clone(&self) -> EscapedLiteral
fn clone(&self) -> EscapedLiteral
Returns a duplicate of the value. Read more
1.0.0 · 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 EscapedLiteral
impl Debug for EscapedLiteral
Source§impl Display for EscapedLiteral
impl Display for EscapedLiteral
Source§impl Hash for EscapedLiteral
impl Hash for EscapedLiteral
Source§impl PartialEq for EscapedLiteral
impl PartialEq for EscapedLiteral
Source§impl SqlSafe for EscapedLiteral
impl SqlSafe for EscapedLiteral
impl Eq for EscapedLiteral
impl StructuralPartialEq for EscapedLiteral
Auto Trait Implementations§
impl Freeze for EscapedLiteral
impl RefUnwindSafe for EscapedLiteral
impl Send for EscapedLiteral
impl Sync for EscapedLiteral
impl Unpin for EscapedLiteral
impl UnsafeUnpin for EscapedLiteral
impl UnwindSafe for EscapedLiteral
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.