SqlServerLiteralForValueListWrapper

Struct SqlServerLiteralForValueListWrapper 

Source
pub struct SqlServerLiteralForValueListWrapper<T: SqlServerLiteralForValueList>(/* private fields */);
Expand description

A wrapper type for any value implementing SqlServerLiteralForValueList.

This type allows you to easily convert a value into one that implements both Display and serde::Serialize, enabling it to exhibit SQL Server literal value list behavior.

§Examples

use mssql_value_serializer::{SqlServerLiteral, SqlServerLiteralForValueListWrapper};

let needles: &[&str] = &["Some text", "Foo", "Bar"];

let mut sql = format!(
    "
        SELECT
            *
        FROM
            [TABLE]
        WHERE
            name IN ({value})
    ",
    value = SqlServerLiteralForValueListWrapper::new(needles)
);

assert_eq!(
    "
        SELECT
            *
        FROM
            [TABLE]
        WHERE
            name IN (N'Some text', N'Foo', N'Bar')
    ",
    sql
);

Implementations§

Source§

impl<T: SqlServerLiteralForValueList> SqlServerLiteralForValueListWrapper<T>

Source

pub const fn new(value: T) -> Self

Source

pub fn into_inner(self) -> T

Consumes the wrapper and returns the inner value.

Trait Implementations§

Source§

impl<T: SqlServerLiteralForValueList> Debug for SqlServerLiteralForValueListWrapper<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: SqlServerLiteralForValueList> Deref for SqlServerLiteralForValueListWrapper<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: SqlServerLiteralForValueList> Display for SqlServerLiteralForValueListWrapper<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the wrapped value as a SQL Server literal.

Source§

impl<T: SqlServerLiteralForValueList> From<T> for SqlServerLiteralForValueListWrapper<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<T: SqlServerLiteralForValueList> Serialize for SqlServerLiteralForValueListWrapper<T>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: SqlServerLiteralForValueList> SqlServerLiteralForValueList for SqlServerLiteralForValueListWrapper<T>

Source§

fn append_sql_literal_for_value_list( &self, out: &mut String, ) -> Result<(), SqlLiteralError>

Appends a comma-separated list of SQL Server literals representing the elements of this collection to the provided output string.
Source§

fn append_sql_literal_for_value_list_fmt( &self, out: &mut Formatter<'_>, ) -> Result<(), SqlLiteralError>

Appends a comma-separated list of SQL Server literals representing the elements of this collection to the provided output writer.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.