Skip to content

Commit 8c5bade

Browse files
committed
feat: 更新版本号至 0.5.3,添加 DriverGeneric 接口实现,新增 new_boxed 方法
1 parent deec623 commit 8c5bade

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

interface/rdif-serial/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rdif-serial"
3-
version = "0.5.2"
3+
version = "0.5.3"
44
edition.workspace = true
55
repository.workspace = true
66
authors = ["周睿 <zrufo747@outlook.com>"]

interface/rdif-serial/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ pub type BSender = Box<dyn TSender>;
1515
pub type BReciever = Box<dyn TReciever>;
1616
pub type BSerial = Box<dyn Interface>;
1717

18+
impl DriverGeneric for Box<dyn Interface> {
19+
fn open(&mut self) -> Result<(), KError> {
20+
self.as_mut().open()
21+
}
22+
23+
fn close(&mut self) -> Result<(), KError> {
24+
self.as_mut().close()
25+
}
26+
}
27+
1828
mod serial;
1929

2030
pub use serial::*;

interface/rdif-serial/src/serial.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ impl<T: Register> Serial<T> {
2929
}
3030
}
3131

32+
pub fn new_boxed(inner: T) -> Box<dyn crate::Interface> {
33+
Box::new(Self::new(inner)) as _
34+
}
35+
3236
fn inner_mut(&mut self) -> &mut T {
3337
unsafe { &mut *self.inner.0.get() }
3438
}

0 commit comments

Comments
 (0)