Switch external-facing APIs from CString to &str
This commit is contained in:
parent
8184164d14
commit
98183712f9
1 changed files with 15 additions and 12 deletions
27
src/lib.rs
27
src/lib.rs
|
@ -165,9 +165,9 @@ pub enum Error {
|
||||||
pub struct Device {
|
pub struct Device {
|
||||||
file: File,
|
file: File,
|
||||||
ty: Types,
|
ty: Types,
|
||||||
name: Option<CString>,
|
name: Option<String>,
|
||||||
phys: Option<CString>,
|
phys: Option<String>,
|
||||||
uniq: Option<CString>,
|
uniq: Option<String>,
|
||||||
id: input_id,
|
id: input_id,
|
||||||
props: Props,
|
props: Props,
|
||||||
driver_version: (u8, u8, u8),
|
driver_version: (u8, u8, u8),
|
||||||
|
@ -330,16 +330,16 @@ impl Device {
|
||||||
self.ty
|
self.ty
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &Option<CString> {
|
pub fn name(&self) -> Option<&str> {
|
||||||
&self.name
|
self.name.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn physical_path(&self) -> &Option<CString> {
|
pub fn physical_path(&self) -> Option<&str> {
|
||||||
&self.phys
|
self.phys.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unique_name(&self) -> &Option<CString> {
|
pub fn unique_name(&self) -> Option<&str> {
|
||||||
&self.uniq
|
self.uniq.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn input_id(&self) -> input_id {
|
pub fn input_id(&self) -> input_id {
|
||||||
|
@ -410,9 +410,12 @@ impl Device {
|
||||||
unsafe { eviocgbit_type(file.as_raw_fd(), &mut ty)? };
|
unsafe { eviocgbit_type(file.as_raw_fd(), &mut ty)? };
|
||||||
let ty = Types::from_bits(ty).expect("evdev: unexpected type bits! report a bug");
|
let ty = Types::from_bits(ty).expect("evdev: unexpected type bits! report a bug");
|
||||||
|
|
||||||
let name = ioctl_get_cstring(eviocgname, file.as_raw_fd());
|
let name = ioctl_get_cstring(eviocgname, file.as_raw_fd())
|
||||||
let phys = ioctl_get_cstring(eviocgphys, file.as_raw_fd());
|
.map(|s| s.to_string_lossy().into_owned());
|
||||||
let uniq = ioctl_get_cstring(eviocguniq, file.as_raw_fd());
|
let phys = ioctl_get_cstring(eviocgphys, file.as_raw_fd())
|
||||||
|
.map(|s| s.to_string_lossy().into_owned());
|
||||||
|
let uniq = ioctl_get_cstring(eviocguniq, file.as_raw_fd())
|
||||||
|
.map(|s| s.to_string_lossy().into_owned());
|
||||||
|
|
||||||
let id = unsafe {
|
let id = unsafe {
|
||||||
let mut id = MaybeUninit::uninit();
|
let mut id = MaybeUninit::uninit();
|
||||||
|
|
Loading…
Reference in a new issue