Update load function
This commit is contained in:
parent
36d2ba034c
commit
7609e94025
1 changed files with 4 additions and 8 deletions
12
src/lib.rs
12
src/lib.rs
|
@ -81,12 +81,8 @@ pub struct LipcApi {
|
||||||
impl LipcApi {
|
impl LipcApi {
|
||||||
const DEFAULT_NAME: &str = "liblipc.so";
|
const DEFAULT_NAME: &str = "liblipc.so";
|
||||||
|
|
||||||
pub fn load(path: Option<&str>) -> Result<Container<Self>> {
|
pub fn load(name: Option<&str>) -> Result<Container<Self>> {
|
||||||
let name = match path {
|
let cont: Container<Self> = unsafe { Container::load(name.unwrap_or(Self::DEFAULT_NAME)) }?;
|
||||||
Some(x) => x,
|
|
||||||
None => Self::DEFAULT_NAME,
|
|
||||||
};
|
|
||||||
let cont: Container<Self> = unsafe { Container::load(name) }?;
|
|
||||||
|
|
||||||
Ok(cont)
|
Ok(cont)
|
||||||
}
|
}
|
||||||
|
@ -99,8 +95,8 @@ pub struct Lipc {
|
||||||
|
|
||||||
impl Lipc {
|
impl Lipc {
|
||||||
pub fn new(api: Container<LipcApi>) -> Result<Self> {
|
pub fn new(api: Container<LipcApi>) -> Result<Self> {
|
||||||
let lipc = unsafe { (api.lipc_open_no_name)() };
|
let lipc: *mut LipcType = unsafe { (api.lipc_open_no_name)() };
|
||||||
if lipc == (std::ptr::null_mut() as *mut c_void) {
|
if lipc == std::ptr::null_mut() {
|
||||||
bail!("Failed to create connection!");
|
bail!("Failed to create connection!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue