Rename BorrowedValue -> ValueRef.

This commit is contained in:
John Gallagher
2016-05-24 21:34:18 -04:00
parent 308789495c
commit 2f4990dafd
8 changed files with 67 additions and 67 deletions

View File

@@ -75,7 +75,7 @@ use std::result;
use std::str;
use libc::{c_int, c_char};
use types::{ToSql, FromSql, BorrowedValue};
use types::{ToSql, FromSql, ValueRef};
use error::{error_from_sqlite_code, error_from_handle};
use raw_statement::RawStatement;
use cache::StatementCache;
@@ -1065,7 +1065,7 @@ impl<'a, 'stmt> Row<'a, 'stmt> {
/// for this row.
pub fn get_checked<I: RowIndex, T: FromSql>(&self, idx: I) -> Result<T> {
let idx = try!(idx.idx(self.stmt));
let value = unsafe { BorrowedValue::new(&self.stmt.stmt, idx) };
let value = unsafe { ValueRef::new(&self.stmt.stmt, idx) };
FromSql::column_result(value)
}
@@ -1100,16 +1100,16 @@ impl<'a> RowIndex for &'a str {
}
}
impl<'a> BorrowedValue<'a> {
unsafe fn new(stmt: &RawStatement, col: c_int) -> BorrowedValue {
impl<'a> ValueRef<'a> {
unsafe fn new(stmt: &RawStatement, col: c_int) -> ValueRef {
use std::slice::from_raw_parts;
let raw = stmt.ptr();
match stmt.column_type(col) {
ffi::SQLITE_NULL => BorrowedValue::Null,
ffi::SQLITE_INTEGER => BorrowedValue::Integer(ffi::sqlite3_column_int64(raw, col)),
ffi::SQLITE_FLOAT => BorrowedValue::Real(ffi::sqlite3_column_double(raw, col)),
ffi::SQLITE_NULL => ValueRef::Null,
ffi::SQLITE_INTEGER => ValueRef::Integer(ffi::sqlite3_column_int64(raw, col)),
ffi::SQLITE_FLOAT => ValueRef::Real(ffi::sqlite3_column_double(raw, col)),
ffi::SQLITE_TEXT => {
let text = ffi::sqlite3_column_text(raw, col);
assert!(!text.is_null(), "unexpected SQLITE_TEXT column type with NULL data");
@@ -1117,7 +1117,7 @@ impl<'a> BorrowedValue<'a> {
// sqlite3_column_text returns UTF8 data, so our unwrap here should be fine.
let s = s.to_str().expect("sqlite3_column_text returned invalid UTF-8");
BorrowedValue::Text(s)
ValueRef::Text(s)
}
ffi::SQLITE_BLOB => {
let blob = ffi::sqlite3_column_blob(raw, col);
@@ -1126,7 +1126,7 @@ impl<'a> BorrowedValue<'a> {
let len = ffi::sqlite3_column_bytes(raw, col);
assert!(len >= 0, "unexpected negative return from sqlite3_column_bytes");
BorrowedValue::Blob(from_raw_parts(blob as *const u8, len as usize))
ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize))
}
_ => unreachable!("sqlite3_column_type returned invalid value")
}