|
|
@ -2,7 +2,7 @@ use std::ffi::CStr;
|
|
|
|
use std::ptr;
|
|
|
|
use std::ptr;
|
|
|
|
use std::fmt;
|
|
|
|
use std::fmt;
|
|
|
|
use std::slice;
|
|
|
|
use std::slice;
|
|
|
|
use libc::c_void;
|
|
|
|
use libc::{c_uint, c_void};
|
|
|
|
|
|
|
|
|
|
|
|
use mongoc::bindings;
|
|
|
|
use mongoc::bindings;
|
|
|
|
use bson;
|
|
|
|
use bson;
|
|
|
@ -27,12 +27,8 @@ impl Bsonc {
|
|
|
|
let mut buffer = Vec::new();
|
|
|
|
let mut buffer = Vec::new();
|
|
|
|
try!(bson::encode_document(&mut buffer, document));
|
|
|
|
try!(bson::encode_document(&mut buffer, document));
|
|
|
|
|
|
|
|
|
|
|
|
let inner = unsafe {
|
|
|
|
let inner =
|
|
|
|
bindings::bson_new_from_data(
|
|
|
|
unsafe { bindings::bson_new_from_data(buffer[..].as_ptr(), buffer.len() as c_uint) };
|
|
|
|
buffer[..].as_ptr(),
|
|
|
|
|
|
|
|
buffer.len() as u64
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Inner will be null if there was an error converting the data.
|
|
|
|
// Inner will be null if there was an error converting the data.
|
|
|
|
// We're assuming the bson crate works and therefore assert here.
|
|
|
|
// We're assuming the bson crate works and therefore assert here.
|
|
|
|