1#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5#[repr(transparent)]
6pub struct CanInterface {
7 pub(crate) inner: crate::sys::CanInterface,
9}
10
11impl CanInterface {
12 pub fn from_index(index: u32) -> Self {
16 Self {
17 inner: crate::sys::CanInterface::from_index(index),
18 }
19 }
20
21 pub fn from_name(name: &str) -> std::io::Result<Self> {
23 Ok(Self {
24 inner: crate::sys::CanInterface::from_name(name)?,
25 })
26 }
27
28 pub fn index(&self) -> u32 {
30 self.inner.index()
31 }
32
33 pub fn get_name(&self) -> std::io::Result<String> {
35 self.inner.get_name()
36 }
37}
38
39impl std::fmt::Debug for CanInterface {
40 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
41 let name = self.get_name();
42 let mut debug = f.debug_struct("CanInterface");
43 debug.field("index", &self.index());
44 if let Ok(name) = &name {
45 debug.field("name", name);
46 }
47 debug.finish()
48 }
49}