pub trait Bind<'b> {
// Required methods
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>
where 'c: 'b;
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)
where 'b: 'c;
}Expand description
A type that can be bound as a SQLite prepared statement parameter, or returned from a SQL function.
squire::ffi::Bind is the low-level trait whose implementations directly
call a sqlite3_bind_* function in the C API. To make your own
user-defined types Bindable, implement Bind instead.
Squire implements ffi::Bind only for types that the SQLite C API
implements directly:
f64(viasqlite3_bind_double)i32(viasqlite3_bind_int)i64(viasqlite3_bind_int64)&str(viasqlite3_bind_text64)&[u8](viasqlite3_bind_blob64)Reservation(viasqlite3_bind_zeroblob64)None(viasqlite3_bind_null)
The lifetime parameter 'b represents the lifetime for which SQLite may
access the bound data.
Required Methods§
Sourceunsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Bind self as a SQLite prepared statement parameter.
§Safety
Implementations access the sqlite3_bind_* API’s directly. If these
API’s are used to bind a pointer non-SQLITE_TRANSIENTly, the caller is
responsible for ensuring the pointer remains valid for the duration of
the binding; and if a destructor is used, for
SQLite to call it at the end of the binding lifecycle.
Sourceunsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
Available on crate feature functions only.
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Bind self as the return value of a SQLite function.
§Safety
Implementations access the sqlite3_result_* API’s directly. If these
API’s are used to return a pointer non-SQLITE_TRANSIENTly, the caller
is responsible for ensuring the pointer remains valid for the duration
of the context; and if a destructor is used,
for SQLite to call it at the end of the function evaluation.
Implementations on Foreign Types§
Source§impl<'b> Bind<'b> for &str
Binds a &str via sqlite3_bind_text64.
impl<'b> Bind<'b> for &str
Binds a &str via sqlite3_bind_text64.
The SQLITE_TRANSIENT flag is used; SQLite will clone the string’s
bytes before bind returns. If you know the &str will outlive the
prepared statement, wrap the &str in Borrowed.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b> Bind<'b> for &[u8]
Binds a &[u8] via sqlite3_bind_blob64.
impl<'b> Bind<'b> for &[u8]
Binds a &[u8] via sqlite3_bind_blob64.
The SQLITE_TRANSIENT flag is used; SQLite will clone the bytes
before bind returns. If you know the &[u8] will outlive the prepared
statement, wrap the &[u8] in Borrowed.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b> Bind<'b> for f64
Binds an f64 via sqlite3_bind_double.
impl<'b> Bind<'b> for f64
Binds an f64 via sqlite3_bind_double.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b> Bind<'b> for i32
Binds an i32 via sqlite3_bind_int.
impl<'b> Bind<'b> for i32
Binds an i32 via sqlite3_bind_int.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b> Bind<'b> for i64
Binds an i64 via sqlite3_bind_int64.
impl<'b> Bind<'b> for i64
Binds an i64 via sqlite3_bind_int64.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b> Bind<'b> for String
Binds a String via sqlite3_bind_text64.
impl<'b> Bind<'b> for String
Binds a String via sqlite3_bind_text64.
The SQLITE_TRANSIENT flag is used; SQLite will clone the string’s
bytes before bind returns.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b> Bind<'b> for Vec<u8>
Binds a Vec<u8> via sqlite3_bind_blob64.
impl<'b> Bind<'b> for Vec<u8>
Binds a Vec<u8> via sqlite3_bind_blob64.
The SQLITE_TRANSIENT flag is used; SQLite will clone the bytes
before bind returns.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b, 'a: 'b, T: Pointee + ?Sized> Bind<'b> for &'a T
Binds a reference using the pointer passing interface.
impl<'b, 'a: 'b, T: Pointee + ?Sized> Bind<'b> for &'a T
Binds a reference using the pointer passing interface.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b, 'a: 'b, T: Pointee + ?Sized> Bind<'b> for &'a mut T
Binds a mutable reference using the pointer passing interface.
impl<'b, 'a: 'b, T: Pointee + ?Sized> Bind<'b> for &'a mut T
Binds a mutable reference using the pointer passing interface.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b, T> Bind<'b> for Option<T>where
T: Bind<'b>,
Binds an Option. Bind the Some value if the option is present,
or bind NULL via sqlite3_bind_null if None.
impl<'b, T> Bind<'b> for Option<T>where
T: Bind<'b>,
Binds an Option. Bind the Some value if the option is present,
or bind NULL via sqlite3_bind_null if None.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Source§impl<'b, T: Pointee> Bind<'b> for Box<T>
Binds an owned value using the pointer passing interface.
impl<'b, T: Pointee> Bind<'b> for Box<T>
Binds an owned value using the pointer passing interface.
unsafe fn bind_parameter<'c>(
self,
statement: &Statement<'c>,
index: BindIndex,
) -> Result<()>where
'c: 'b,
Source§unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)where
'b: 'c,
functions only.Implementors§
impl<'b> Bind<'b> for Reservation
When a Reservation is used as a prepared statement
parameter, SQLite will create a BLOB of the requested length
and set every byte in the blob to \0.
impl<'b> Bind<'b> for Bytes
The memory is transferred to SQLite, which will free it via sqlite3_free
when the binding is no longer needed.
impl<'b> Bind<'b> for squire::ffi::String
Binds a ffi::String via sqlite3_bind_text64.
The string’s memory is transferred to SQLite, which will free it via
sqlite3_free when the binding is no longer needed.
impl<'b, 'a: 'b> Bind<'b> for Borrowed<'a, str>
Binds a borrowed str via sqlite3_bind_text64.
The SQLITE_STATIC flag is used; SQLite will read the string’s bytes
without cloning them.
impl<'b, 'a: 'b> Bind<'b> for Borrowed<'a, [u8]>
Binds a borrowed [u8] via sqlite3_bind_blob64.
The SQLITE_STATIC flag is used; SQLite will read the bytes without
cloning them.