pub struct Client(_);
Expand description
Less unsafe door client (compared to raw file descriptors)
Clients are automatically closed when they go out of scope. Errors detected
on closing are ignored by the implementation of Drop
, just like in
File
.
Implementations§
source§impl Client
impl Client
sourcepub fn call(&self, arg: DoorArgument) -> Result<DoorArgument, DoorCallError>
pub fn call(&self, arg: DoorArgument) -> Result<DoorArgument, DoorCallError>
Issue a door call
You are responsible for managing this memory. See DOOR_CALL(3C)
.
Particularly, if, after a door_call
, the rbuf
property of
door_arg_t
is different than what it was before the door_call
, you
are responsible for reclaiming this area with MUNMAP(2)
when you are
done with it.
This crate cannot yet handle this for you. See Issue #11.
sourcepub fn call_with_data(&self, data: &[u8]) -> Result<DoorArgument, DoorCallError>
pub fn call_with_data(&self, data: &[u8]) -> Result<DoorArgument, DoorCallError>
Issue a door call with Data only
Example
use doors::Client;
use std::ffi::CString;
use std::ffi::CStr;
let capitalize = Client::open("/tmp/barebones_capitalize.door")
.unwrap();
let text = CString::new("Hello, World!").unwrap();
let response = capitalize.call_with_data(text.as_bytes()).unwrap();
let caps = unsafe {
CStr::from_ptr(response.data().as_ptr() as *const i8)
};
assert_eq!(caps.to_str(), Ok("HELLO, WORLD!"));
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
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