Struct easy_ffi_wrapper::StrBuilder
source · pub struct StrBuilder {
pub ptr: *const c_char,
pub len: usize,
}Expand description
A convenience structure for calling FFI interfaces to get strings
Example
use easy_ffi::{Str, StrBuilder};
enum T {}
extern "C" {
fn extern_get_str_from_my_struct(
t: *const T,
ptr_out: *mut *const c_char,
len_out: *mut usize,
);
}
impl T {
fn get_str(&self) -> Str {
let mut builder = StrBuilder::new();
unsafe {
extern_get_str_from_my_struct(self, &mut builder.ptr, &mut builder.len);
builder.build()
}
}
}Fields§
§ptr: *const c_charPointer to the first character of the string to fill in, usually as an output parameter.
len: usizeLen of the string to fill in, usually as an output parameter.
Implementations§
source§impl StrBuilder
impl StrBuilder
Trait Implementations§
source§impl Debug for StrBuilder
impl Debug for StrBuilder
Auto Trait Implementations§
impl RefUnwindSafe for StrBuilder
impl !Send for StrBuilder
impl !Sync for StrBuilder
impl Unpin for StrBuilder
impl UnwindSafe for StrBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more