mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
parent
214986d232
commit
4dbfdc85fe
@ -126,8 +126,6 @@ where
|
|||||||
impl<'a> ValueRef<'a> {
|
impl<'a> ValueRef<'a> {
|
||||||
pub(crate) unsafe fn from_value(value: *mut crate::ffi::sqlite3_value) -> ValueRef<'a> {
|
pub(crate) unsafe fn from_value(value: *mut crate::ffi::sqlite3_value) -> ValueRef<'a> {
|
||||||
use crate::ffi;
|
use crate::ffi;
|
||||||
use std::ffi::CStr;
|
|
||||||
use std::os::raw::c_char;
|
|
||||||
use std::slice::from_raw_parts;
|
use std::slice::from_raw_parts;
|
||||||
|
|
||||||
match ffi::sqlite3_value_type(value) {
|
match ffi::sqlite3_value_type(value) {
|
||||||
@ -136,13 +134,12 @@ impl<'a> ValueRef<'a> {
|
|||||||
ffi::SQLITE_FLOAT => ValueRef::Real(ffi::sqlite3_value_double(value)),
|
ffi::SQLITE_FLOAT => ValueRef::Real(ffi::sqlite3_value_double(value)),
|
||||||
ffi::SQLITE_TEXT => {
|
ffi::SQLITE_TEXT => {
|
||||||
let text = ffi::sqlite3_value_text(value);
|
let text = ffi::sqlite3_value_text(value);
|
||||||
|
let len = ffi::sqlite3_value_bytes(value);
|
||||||
assert!(
|
assert!(
|
||||||
!text.is_null(),
|
!text.is_null(),
|
||||||
"unexpected SQLITE_TEXT value type with NULL data"
|
"unexpected SQLITE_TEXT value type with NULL data"
|
||||||
);
|
);
|
||||||
let s = CStr::from_ptr(text as *const c_char);
|
let s = from_raw_parts(text as *const u8, len as usize);
|
||||||
|
|
||||||
let s = s.to_bytes();
|
|
||||||
ValueRef::Text(s)
|
ValueRef::Text(s)
|
||||||
}
|
}
|
||||||
ffi::SQLITE_BLOB => {
|
ffi::SQLITE_BLOB => {
|
||||||
|
Loading…
Reference in New Issue
Block a user