better-duck-core 0.1.0-beta.3

Rust DuckDB client with Diesel ORM support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::error::Result;
use std::{ffi::CString, path::Path};

#[cfg(unix)]
pub fn path_to_cstring(p: &Path) -> Result<CString> {
    use std::os::unix::ffi::OsStrExt;
    Ok(CString::new(p.as_os_str().as_bytes())?)
}

#[cfg(not(unix))]
pub fn path_to_cstring(p: &Path) -> Result<CString> {
    use crate::error::Error;

    let s = p.to_str().ok_or_else(|| Error::InvalidPath(p.to_owned()))?;
    Ok(CString::new(s)?)
}