Skip to content

Commit 173942a

Browse files
committed
zephyr: device: uart: irq: Add accessors for async read
The result from the async_write holds the buffer, but the fields are private. Provide two accessors to make this result useful: - as_slice: returns a slice of the useful part of the buffer - into_inner: Transforms into the buffer, so it can be reused. Signed-off-by: David Brown <[email protected]>
1 parent e5c8fc7 commit 173942a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

zephyr/src/device/uart/irq.rs

+10
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ pub struct ReadResult {
9797
len: usize,
9898
}
9999

100+
impl ReadResult {
101+
pub fn as_slice(&self) -> &[u8] {
102+
&self.data[..self.len]
103+
}
104+
105+
pub fn into_inner(self) -> Vec<u8> {
106+
self.data
107+
}
108+
}
109+
100110
/// The error type from write requests. Used to return the buffer.
101111
pub struct WriteError(pub Vec<u8>);
102112

0 commit comments

Comments
 (0)