mirror of
https://github.com/isar/rusqlite.git
synced 2025-12-18 09:22:25 +08:00
Rework ToSql to be implementable without unsafe.
This commit is contained in:
@@ -52,10 +52,9 @@ use std::io;
|
||||
use std::cmp::min;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use libc::c_int;
|
||||
|
||||
use super::ffi;
|
||||
use super::types::ToSql;
|
||||
use super::types::{ToSql, ToSqlOutput};
|
||||
use {Result, Connection, DatabaseName};
|
||||
|
||||
/// Handle to an open BLOB.
|
||||
@@ -244,9 +243,9 @@ impl<'conn> Drop for Blob<'conn> {
|
||||
pub struct ZeroBlob(pub i32);
|
||||
|
||||
impl ToSql for ZeroBlob {
|
||||
unsafe fn bind_parameter(&self, stmt: *mut ffi::sqlite3_stmt, col: c_int) -> c_int {
|
||||
fn to_sql(&self) -> Result<ToSqlOutput> {
|
||||
let ZeroBlob(length) = *self;
|
||||
ffi::sqlite3_bind_zeroblob(stmt, col, length)
|
||||
Ok(ToSqlOutput::ZeroBlob(length))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user