mirror of
https://github.com/rust-embedded/embedded-hal.git
synced 2025-10-02 15:14:38 +00:00
io-adapters: forward seek_relative in std adapter and require Rust 1.81
This commit is contained in:
parent
dfb092da41
commit
050e8827d3
@ -2,7 +2,7 @@
|
||||
name = "embedded-io-adapters"
|
||||
version = "0.6.2"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
rust-version = "1.81"
|
||||
description = "Adapters between the `embedded-io` traits and other I/O traits"
|
||||
repository = "https://github.com/rust-embedded/embedded-hal"
|
||||
readme = "README.md"
|
||||
|
@ -102,6 +102,10 @@ impl<T: std::io::Seek + ?Sized> embedded_io::Seek for FromStd<T> {
|
||||
fn stream_position(&mut self) -> Result<u64, Self::Error> {
|
||||
self.inner.stream_position()
|
||||
}
|
||||
|
||||
fn seek_relative(&mut self, offset: i64) -> Result<(), Self::Error> {
|
||||
self.inner.seek_relative(offset)
|
||||
}
|
||||
}
|
||||
|
||||
/// Adapter to `std::io` traits.
|
||||
@ -167,10 +171,9 @@ impl<T: embedded_io::Write + ?Sized> std::io::Write for ToStd<T> {
|
||||
fn write_fmt(&mut self, fmt: core::fmt::Arguments<'_>) -> Result<(), std::io::Error> {
|
||||
match self.inner.write_fmt(fmt) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(e @ embedded_io::WriteFmtError::FmtError) => Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("{e:?}"),
|
||||
)),
|
||||
Err(e @ embedded_io::WriteFmtError::FmtError) => {
|
||||
Err(std::io::Error::other(format!("{e:?}")))
|
||||
}
|
||||
Err(embedded_io::WriteFmtError::Other(e)) => Err(to_std_error(e)),
|
||||
}
|
||||
}
|
||||
@ -192,6 +195,10 @@ impl<T: embedded_io::Seek + ?Sized> std::io::Seek for ToStd<T> {
|
||||
fn stream_position(&mut self) -> Result<u64, std::io::Error> {
|
||||
self.inner.stream_position().map_err(to_std_error)
|
||||
}
|
||||
|
||||
fn seek_relative(&mut self, offset: i64) -> std::io::Result<()> {
|
||||
self.inner.seek_relative(offset).map_err(to_std_error)
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a embedded-io error to a [`std::io::Error`]
|
||||
|
Loading…
x
Reference in New Issue
Block a user