Skip to main content

Bind

Trait Bind 

Source
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:

The lifetime parameter 'b represents the lifetime for which SQLite may access the bound data.

Required Methods§

Source

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.

Source

unsafe fn bind_return<'c>(self, context: &ContextRef<'c>)
where 'b: 'c,

Available on crate feature 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

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.

Source§

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,

Available on crate feature functions only.
Source§

impl<'b> Bind<'b> for &[u8]

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.

Source§

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,

Available on crate feature functions only.
Source§

impl<'b> Bind<'b> for f64

Source§

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,

Available on crate feature functions only.
Source§

impl<'b> Bind<'b> for i32

Source§

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,

Available on crate feature functions only.
Source§

impl<'b> Bind<'b> for i64

Source§

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,

Available on crate feature functions only.
Source§

impl<'b> Bind<'b> for String

The SQLITE_TRANSIENT flag is used; SQLite will clone the string’s bytes before bind returns.

Source§

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,

Available on crate feature functions only.
Source§

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.

Source§

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,

Available on crate feature functions only.
Source§

impl<'b, 'a: 'b, T: Pointee + ?Sized> Bind<'b> for &'a T

Binds a reference using the pointer passing interface.

Source§

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,

Available on crate feature 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.

Source§

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,

Available on crate feature 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.

Source§

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,

Available on crate feature functions only.
Source§

impl<'b, T: Pointee> Bind<'b> for Box<T>

Binds an owned value using the pointer passing interface.

Source§

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,

Available on crate feature functions only.

Implementors§

Source§

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.

Source§

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.

Source§

impl<'b> Bind<'b> for squire::ffi::String

The string’s memory is transferred to SQLite, which will free it via sqlite3_free when the binding is no longer needed.

Source§

impl<'b, 'a: 'b> Bind<'b> for Borrowed<'a, str>

The SQLITE_STATIC flag is used; SQLite will read the string’s bytes without cloning them.

Source§

impl<'b, 'a: 'b> Bind<'b> for Borrowed<'a, [u8]>

The SQLITE_STATIC flag is used; SQLite will read the bytes without cloning them.