mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Moves ZeroBlob from types to blob module.
This commit is contained in:
parent
f488277373
commit
43613a0020
17
src/blob.rs
17
src/blob.rs
@ -17,7 +17,7 @@
|
|||||||
//! extern crate rusqlite;
|
//! extern crate rusqlite;
|
||||||
//!
|
//!
|
||||||
//! use rusqlite::{Connection, DatabaseName};
|
//! use rusqlite::{Connection, DatabaseName};
|
||||||
//! use rusqlite::types::ZeroBlob;
|
//! use rusqlite::blob::ZeroBlob;
|
||||||
//! use std::io::{Read, Write, Seek, SeekFrom};
|
//! use std::io::{Read, Write, Seek, SeekFrom};
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
@ -52,8 +52,10 @@ use std::io;
|
|||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use libc::c_int;
|
||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
|
use super::types::ToSql;
|
||||||
use {Result, Connection, DatabaseName};
|
use {Result, Connection, DatabaseName};
|
||||||
|
|
||||||
/// Handle to an open BLOB.
|
/// Handle to an open BLOB.
|
||||||
@ -233,6 +235,19 @@ impl<'conn> Drop for Blob<'conn> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// BLOB of length N that is filled with zeroes.
|
||||||
|
/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is later written using incremental BLOB I/O routines.
|
||||||
|
/// A negative value for the zeroblob results in a zero-length BLOB.
|
||||||
|
#[derive(Copy,Clone)]
|
||||||
|
pub struct ZeroBlob(pub i32);
|
||||||
|
|
||||||
|
impl ToSql for ZeroBlob {
|
||||||
|
unsafe fn bind_parameter(&self, stmt: *mut ffi::sqlite3_stmt, col: c_int) -> c_int {
|
||||||
|
let ZeroBlob(length) = *self;
|
||||||
|
ffi::sqlite3_bind_zeroblob(stmt, col, length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::io::{BufReader, BufRead, BufWriter, Read, Write, Seek, SeekFrom};
|
use std::io::{BufReader, BufRead, BufWriter, Read, Write, Seek, SeekFrom};
|
||||||
|
15
src/types.rs
15
src/types.rs
@ -194,21 +194,6 @@ impl ToSql for Null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// BLOB of length N that is filled with zeroes.
|
|
||||||
/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is later written using incremental BLOB I/O routines.
|
|
||||||
/// A negative value for the zeroblob results in a zero-length BLOB.
|
|
||||||
#[cfg(feature = "blob")]
|
|
||||||
#[derive(Copy,Clone)]
|
|
||||||
pub struct ZeroBlob(pub i32);
|
|
||||||
|
|
||||||
#[cfg(feature = "blob")]
|
|
||||||
impl ToSql for ZeroBlob {
|
|
||||||
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
|
|
||||||
let ZeroBlob(length) = *self;
|
|
||||||
ffi::sqlite3_bind_zeroblob(stmt, col, length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! raw_from_impl(
|
macro_rules! raw_from_impl(
|
||||||
($t:ty, $f:ident, $c:expr) => (
|
($t:ty, $f:ident, $c:expr) => (
|
||||||
impl FromSql for $t {
|
impl FromSql for $t {
|
||||||
|
Loading…
Reference in New Issue
Block a user