pub struct Parameter {
pub len: i32,
pub data: Vec<u8>,
}
Expand description
Prepared statement bound parameter.
Fields§
§len: i32
Parameter data length.
data: Vec<u8>
Parameter data.
Use Self::decode
to read this value.
Implementations§
Source§impl Parameter
impl Parameter
Sourcepub fn decode(&self, format: ParameterFormat) -> Option<ParameterValue<'_>>
pub fn decode(&self, format: ParameterFormat) -> Option<ParameterValue<'_>>
Decode parameter given the provided format. If the parameter is encoded using text encoding (default), a UTF-8 string is returned. If encoded using binary encoding, a slice of bytes.
If the parameter is NULL
or the encoding doesn’t match the data, None
is returned.
§Example
use pgdog_plugin::prelude::*;
let parameter = Parameter {
len: -1,
data: vec![],
};
assert!(parameter.decode(ParameterFormat::Text).is_none());
let parameter = Parameter {
len: 5,
data: "hello".as_bytes().to_vec(),
};
assert_eq!(parameter.decode(ParameterFormat::Text), Some(ParameterValue::Text("hello")));
Trait Implementations§
impl Eq for Parameter
impl StructuralPartialEq for Parameter
Auto Trait Implementations§
impl Freeze for Parameter
impl RefUnwindSafe for Parameter
impl Send for Parameter
impl Sync for Parameter
impl Unpin for Parameter
impl UnwindSafe for Parameter
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more