mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-06-11 14:41:21 +00:00
Move a macro
This commit is contained in:
@ -126,13 +126,6 @@ extern fn process_callback<F>(callback: *mut c_void, count: c_int, values: *mut
|
||||
columns: *mut *mut c_char) -> c_int
|
||||
where F: FnMut(&[(&str, Option<&str>)]) -> bool
|
||||
{
|
||||
use std::str;
|
||||
use std::ffi::CStr;
|
||||
|
||||
macro_rules! c_str_to_str(
|
||||
($string:expr) => (str::from_utf8(CStr::from_ptr($string).to_bytes()));
|
||||
);
|
||||
|
||||
unsafe {
|
||||
let mut pairs = Vec::with_capacity(count as usize);
|
||||
|
||||
|
18
src/lib.rs
18
src/lib.rs
@ -66,6 +66,17 @@ macro_rules! path_to_c_str(
|
||||
});
|
||||
);
|
||||
|
||||
macro_rules! c_str_to_str(
|
||||
($string:expr) => (::std::str::from_utf8(::std::ffi::CStr::from_ptr($string).to_bytes()));
|
||||
);
|
||||
|
||||
macro_rules! c_str_to_string(
|
||||
($string:expr) => (
|
||||
String::from_utf8_lossy(::std::ffi::CStr::from_ptr($string as *const _).to_bytes())
|
||||
.into_owned()
|
||||
);
|
||||
);
|
||||
|
||||
macro_rules! str_to_c_str(
|
||||
($string:expr) => (
|
||||
match ::std::ffi::CString::new($string) {
|
||||
@ -75,13 +86,6 @@ macro_rules! str_to_c_str(
|
||||
);
|
||||
);
|
||||
|
||||
macro_rules! c_str_to_string(
|
||||
($cstr:expr) => (
|
||||
String::from_utf8_lossy(::std::ffi::CStr::from_ptr($cstr as *const _).to_bytes())
|
||||
.into_owned()
|
||||
);
|
||||
);
|
||||
|
||||
mod database;
|
||||
mod error;
|
||||
mod statement;
|
||||
|
Reference in New Issue
Block a user