From 611beaebb9a80f49b541cfaed4abab3f3fb4eea0 Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Sun, 2 Aug 2015 20:15:15 -0400 Subject: [PATCH] Rename Value to Readable and Parameter to Bindable --- src/lib.rs | 6 +++--- src/statement.rs | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7904269..e8c70ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -117,9 +117,9 @@ pub type Result = std::result::Result; pub enum Type { /// The binary type. Binary, - /// The floating-point type (64-bit). + /// The floating-point type. Float, - /// The integer type (64-bit, signed). + /// The integer type. Integer, /// The null type. Null, @@ -151,7 +151,7 @@ mod connection; mod statement; pub use connection::Connection; -pub use statement::{Statement, State, Parameter, Value}; +pub use statement::{Statement, State, Bindable, Readable}; /// Open a connection to a new or existing database. #[inline] diff --git a/src/statement.rs b/src/statement.rs index 739d72d..5aa6a12 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -19,17 +19,17 @@ pub enum State { Done, } -/// A parameter of a prepared statement. -pub trait Parameter { - /// Bind the parameter at a specific location. +/// A type suitable for binding to a parameter of a prepared statement. +pub trait Bindable { + /// Bind to a particular parameter. /// - /// The leftmost location has the index 1. + /// The leftmost parameter has the index 1. fn bind(&self, &mut Statement, usize) -> Result<()>; } -/// A value stored in a prepared statement. -pub trait Value { - /// Read the value stored in a specific column. +/// A type suitable for reading from a column of a prepared statement. +pub trait Readable { + /// Read from a particular column. /// /// The leftmost column has the index 0. fn read(&Statement, usize) -> Result; @@ -61,7 +61,7 @@ impl<'l> Statement<'l> { /// /// The leftmost location has the index 1. #[inline] - pub fn bind(&mut self, i: usize, parameter: T) -> Result<()> { + pub fn bind(&mut self, i: usize, parameter: T) -> Result<()> { parameter.bind(self, i) } @@ -69,8 +69,8 @@ impl<'l> Statement<'l> { /// /// The leftmost column has the index 0. #[inline] - pub fn read(&self, i: usize) -> Result { - Value::read(self, i) + pub fn read(&self, i: usize) -> Result { + Readable::read(self, i) } /// Evaluate the statement one step at a time. @@ -100,7 +100,7 @@ impl<'l> Drop for Statement<'l> { } } -impl Parameter for f64 { +impl Bindable for f64 { #[inline] fn bind(&self, statement: &mut Statement, i: usize) -> Result<()> { debug_assert!(i > 0, "the indexing starts from 1"); @@ -112,7 +112,7 @@ impl Parameter for f64 { } } -impl Parameter for i64 { +impl Bindable for i64 { #[inline] fn bind(&self, statement: &mut Statement, i: usize) -> Result<()> { debug_assert!(i > 0, "the indexing starts from 1"); @@ -124,7 +124,7 @@ impl Parameter for i64 { } } -impl<'l> Parameter for &'l str { +impl<'l> Bindable for &'l str { #[inline] fn bind(&self, statement: &mut Statement, i: usize) -> Result<()> { debug_assert!(i > 0, "the indexing starts from 1"); @@ -136,7 +136,7 @@ impl<'l> Parameter for &'l str { } } -impl<'l> Parameter for &'l [u8] { +impl<'l> Bindable for &'l [u8] { #[inline] fn bind(&self, statement: &mut Statement, i: usize) -> Result<()> { debug_assert!(i > 0, "the indexing starts from 1"); @@ -149,21 +149,21 @@ impl<'l> Parameter for &'l [u8] { } } -impl Value for f64 { +impl Readable for f64 { #[inline] fn read(statement: &Statement, i: usize) -> Result { Ok(unsafe { ffi::sqlite3_column_double(statement.raw.0, i as c_int) as f64 }) } } -impl Value for i64 { +impl Readable for i64 { #[inline] fn read(statement: &Statement, i: usize) -> Result { Ok(unsafe { ffi::sqlite3_column_int64(statement.raw.0, i as c_int) as i64 }) } } -impl Value for String { +impl Readable for String { #[inline] fn read(statement: &Statement, i: usize) -> Result { unsafe { @@ -176,7 +176,7 @@ impl Value for String { } } -impl Value for Vec { +impl Readable for Vec { #[inline] fn read(statement: &Statement, i: usize) -> Result { use std::ptr::copy_nonoverlapping as copy;