Skip to main content

SQLBytes

Struct SQLBytes 

Source
pub struct SQLBytes<'a>(pub Cow<'a, [u8]>);
Expand description

Bytes bound as one binary parameter (BLOB / bytea).

A Vec<u8> passed to ToSQL renders as a list, one parameter per byte. Wrap it in SQLBytes (or use SQL::bytes) to bind it as a single value.

§Examples

use drizzle_core::{SQL, SQLBytes, ToSQL};

let data = vec![1_u8, 2, 3];
let sql: SQL<'_, Value> = SQLBytes::new(&data[..]).to_sql();
assert_eq!(sql.sql(), "?");
assert_eq!(sql.params().collect::<Vec<_>>(), [&Value(vec![1, 2, 3])]);

Tuple Fields§

§0: Cow<'a, [u8]>

Implementations§

Source§

impl<'a> SQLBytes<'a>

Source

pub fn new(bytes: impl Into<Cow<'a, [u8]>>) -> Self

Wraps borrowed or owned bytes.

Trait Implementations§

Source§

impl<'a> Clone for SQLBytes<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for SQLBytes<'a>

Source§

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

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

impl<'a, V> Expr<'a, V> for SQLBytes<'a>
where V: SQLParam + 'a + From<&'a [u8]> + From<Vec<u8>> + Into<Cow<'a, V>>,

Source§

type SQLType = <<V as SQLParam>::DialectMarker as DialectTypes>::Bytes

The SQL data type this expression evaluates to.
Source§

type Nullable = NonNull

Whether this expression can be NULL.
Source§

type Aggregate = Scalar

Whether this is an aggregate (COUNT, SUM) or scalar expression.
Source§

fn to_expr_sql(&self) -> SQL<'a, V>

Renders this value as a scalar expression, borrowing it. Read more
Source§

fn into_expr_sql(self) -> SQL<'a, V>

Renders this value as a scalar expression, consuming it.
Source§

fn to_condition_sql(&self) -> Option<SQL<'a, V>>

Renders this value as one element of a ConditionList. Read more
Source§

fn into_condition_sql(self) -> Option<SQL<'a, V>>
where Self: Sized,

Consuming counterpart of Expr::to_condition_sql.
Source§

impl ExprSources for SQLBytes<'_>

Source§

type Sources = ()

Type-level tree with one Src leaf per column read.
Source§

impl<'a, V> ToSQL<'a, V> for SQLBytes<'a>
where V: SQLParam + 'a + From<&'a [u8]> + From<Vec<u8>> + Into<Cow<'a, V>>,

Source§

fn to_sql(&self) -> SQL<'a, V>

Renders self as a SQL fragment.
Source§

fn into_sql(self) -> SQL<'a, V>

Renders self as a SQL fragment, consuming it. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for SQLBytes<'a>

§

impl<'a> RefUnwindSafe for SQLBytes<'a>

§

impl<'a> Send for SQLBytes<'a>

§

impl<'a> Sync for SQLBytes<'a>

§

impl<'a> Unpin for SQLBytes<'a>

§

impl<'a> UnsafeUnpin for SQLBytes<'a>

§

impl<'a> UnwindSafe for SQLBytes<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<'a, V, L, R> ComparisonOperand<'a, V, L> for R
where V: SQLParam + 'a, L: Expr<'a, V>, R: Expr<'a, V>, <L as Expr<'a, V>>::SQLType: Compatible<<R as Expr<'a, V>>::SQLType>,

Source§

type SQLType = <R as Expr<'a, V>>::SQLType

SQL type of the operand.
Source§

type Nullable = <R as Expr<'a, V>>::Nullable

Whether the operand can be NULL.
Source§

type Aggregate = <R as Expr<'a, V>>::Aggregate

Whether the operand is an aggregate.
Source§

type Sources = <R as ExprSources>::Sources

Tables the operand reads; see ExprSources::Sources.
Source§

fn into_comparison_sql(self) -> SQL<'a, V>

Renders the operand.
Source§

impl<'a, V, E> ExprExt<'a, V> for E
where V: SQLParam, E: Expr<'a, V>,

Source§

fn eq<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

Equality comparison (=); see eq.
Source§

fn ne<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

Inequality comparison (<>); see ne.
Source§

fn gt<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

Greater-than comparison (>); see gt.
Source§

fn ge<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

Greater-than-or-equal comparison (>=); see gte.
Source§

fn lt<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

Less-than comparison (<); see lt.
Source§

fn le<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

Less-than-or-equal comparison (<=); see lte.
Source§

fn like<R>( self, pattern: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual, <R as ComparisonOperand<'a, V, Self>>::SQLType: Textual,

Pattern match (LIKE); see like.
Source§

fn not_like<R>( self, pattern: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, Arg<<R as ComparisonOperand<'a, V, Self>>::Nullable, <R as ComparisonOperand<'a, V, Self>>::Sources>)>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType> + Textual, <R as ComparisonOperand<'a, V, Self>>::SQLType: Textual,

Negated pattern match (NOT LIKE); see not_like.
Source§

fn is_null( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ScopeOnly<Self::Sources>>

NULL check (IS NULL); see is_null.
Source§

fn is_not_null( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ScopeOnly<Self::Sources>>

Non-NULL check (IS NOT NULL); see is_not_null.
Source§

fn between<L, H>( self, low: L, high: H, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggregateKind>::Or<<L as ComparisonOperand<'a, V, Self>>::Aggregate> as AggregateKind>::Or<<H as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, (Arg<<L as ComparisonOperand<'a, V, Self>>::Nullable, <L as ComparisonOperand<'a, V, Self>>::Sources>, Arg<<H as ComparisonOperand<'a, V, Self>>::Nullable, <H as ComparisonOperand<'a, V, Self>>::Sources>))>
where L: ComparisonOperand<'a, V, Self>, H: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>,

Inclusive range check (BETWEEN); see between.
Source§

fn not_between<L, H>( self, low: L, high: H, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <<Self::Aggregate as AggregateKind>::Or<<L as ComparisonOperand<'a, V, Self>>::Aggregate> as AggregateKind>::Or<<H as ComparisonOperand<'a, V, Self>>::Aggregate>, (Arg<<Self as Expr<'a, V>>::Nullable, <Self as ExprSources>::Sources>, (Arg<<L as ComparisonOperand<'a, V, Self>>::Nullable, <L as ComparisonOperand<'a, V, Self>>::Sources>, Arg<<H as ComparisonOperand<'a, V, Self>>::Nullable, <H as ComparisonOperand<'a, V, Self>>::Sources>))>
where L: ComparisonOperand<'a, V, Self>, H: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<L as ComparisonOperand<'a, V, Self>>::SQLType> + Compatible<<H as ComparisonOperand<'a, V, Self>>::SQLType>,

Negated range check (NOT BETWEEN); see not_between.
Source§

fn in_array<I, R>( self, values: I, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
where I: IntoIterator<Item = R>, R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Membership in a list of values (IN (...)); see in_array.
Source§

fn not_in_array<I, R>( self, values: I, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, (Arg<Self::Nullable, Self::Sources>, Arg<R::Nullable, R::Sources>)>
where I: IntoIterator<Item = R>, R: Expr<'a, V>, Self::SQLType: Compatible<R::SQLType>,

Non-membership in a list of values (NOT IN (...)); see not_in_array.
Source§

fn in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, (Arg<Self::Nullable, Self::Sources>, Arg<S::Nullable, S::Sources>)>
where S: Expr<'a, V>, Self::SQLType: Compatible<S::SQLType> + Compatible<Self::SQLType>,

Membership in a subquery’s rows (IN (SELECT ...)); see in_subquery.
Source§

fn not_in_subquery<S>( self, subquery: S, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, (Arg<Self::Nullable, Self::Sources>, Arg<S::Nullable, S::Sources>)>
where S: Expr<'a, V>, Self::SQLType: Compatible<S::SQLType> + Compatible<Self::SQLType>,

Non-membership in a subquery’s rows (NOT IN (SELECT ...)); see not_in_subquery.
Source§

fn is_distinct_from<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ScopeOnly<(<Self as ExprSources>::Sources, <R as ComparisonOperand<'a, V, Self>>::Sources)>>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

NULL-safe inequality (IS DISTINCT FROM); see is_distinct_from.
Source§

fn is_not_distinct_from<R>( self, other: R, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, <Self::Aggregate as AggregateKind>::Or<<R as ComparisonOperand<'a, V, Self>>::Aggregate>, ScopeOnly<(<Self as ExprSources>::Sources, <R as ComparisonOperand<'a, V, Self>>::Sources)>>
where R: ComparisonOperand<'a, V, Self>, Self::SQLType: Compatible<<R as ComparisonOperand<'a, V, Self>>::SQLType>,

NULL-safe equality (IS NOT DISTINCT FROM); see is_not_distinct_from.
Source§

fn is_true( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ScopeOnly<Self::Sources>>

Truth test (IS TRUE); see is_true.
Source§

fn is_false( self, ) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Bool, NonNull, Self::Aggregate, ScopeOnly<Self::Sources>>

Falsity test (IS FALSE); see is_false.
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<Joined, From> JoinKey<From, JoinReverse> for Joined
where From: Joinable<Joined> + ?Sized,

Source§

fn pairs() -> &'static [(&'static str, &'static str)]

(joined_column, from_column) pairs the ON condition matches, in key order, read through Self::pair.
Source§

fn pair(pair: &(&'static str, &'static str)) -> (&'static str, &'static str)

The (joined_column, from_column) names of pair.
Source§

impl<List> ListIncludes<Nil, ()> for List

Source§

impl<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> TypeEq<T> for T