more refactoring and slightly better api
This commit is contained in:
parent
aa7b909b7b
commit
eb0598dac2
7 changed files with 588 additions and 627 deletions
|
@ -1,3 +1,9 @@
|
|||
use std::{
|
||||
ffi::{CString, OsStr},
|
||||
os::unix::prelude::OsStrExt,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::statement::{SqlType, Statement};
|
||||
|
@ -241,3 +247,20 @@ impl<T: Bind> Bind for &[T] {
|
|||
Ok(current_index)
|
||||
}
|
||||
}
|
||||
|
||||
impl Bind for &Path {
|
||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
||||
self.as_os_str().as_bytes().bind(statement, start_index)
|
||||
}
|
||||
}
|
||||
|
||||
impl Column for PathBuf {
|
||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
||||
let blob = statement.column_blob(start_index)?;
|
||||
|
||||
Ok((
|
||||
PathBuf::from(OsStr::from_bytes(blob).to_owned()),
|
||||
start_index + 1,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue