pub struct PgBytea(/* private fields */);Expand description
A PostgreSQL bytea, ordered as byteacmp orders it and printed as byteaout prints it
under the default bytea_output of hex.
use sql_values::postgres::PgBytea;
let bytea = |text| PgBytea::parse(text).unwrap();
assert_eq!(bytea(r"\x de AD "), bytea(r"\336\255"));
assert_eq!(bytea(r"a\\b").as_bytes(), b"a\\b");
assert_eq!(bytea("hi").to_string(), r"\x6869");
assert_eq!(PgBytea::from(b"hi".to_vec()), bytea(r"\x6869"));
assert_eq!(bytea(r"\150\151").into_bytes(), b"hi");
assert_eq!(bytea(r"\x00415c").escaped().to_string(), r"\000A\\");
assert!(bytea(r"\x00") < bytea(r"\x0000"));
assert!(bytea(r"\x0000") < bytea(r"\x01"));Implementations§
Source§impl PgBytea
impl PgBytea
Sourcepub fn parse(text: &str) -> Result<Self, ByteaError>
pub fn parse(text: &str) -> Result<Self, ByteaError>
Read text as byteain reads it, hex after a leading \x, else the escape format.
§Errors
The ByteaError whose message PostgreSQL raises for text.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
The bytes, owned.
Trait Implementations§
impl Eq for PgBytea
Source§impl Ord for PgBytea
impl Ord for PgBytea
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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for PgBytea
impl PartialOrd for PgBytea
impl StructuralPartialEq for PgBytea
Auto Trait Implementations§
impl Forget for PgBytea
impl Freeze for PgBytea
impl Move for PgBytea
impl RefUnwindSafe for PgBytea
impl Send for PgBytea
impl Sync for PgBytea
impl Unpin for PgBytea
impl UnsafeUnpin for PgBytea
impl UnwindSafe for PgBytea
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