Skip to content

Commit

Permalink
feat: update to embedded-io 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Lilleengen committed Oct 4, 2023
1 parent 4ba5d8b commit 0e360db
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 34 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "embedded-tls"
version = "0.15.0"
version = "0.16.0"
edition = "2021"
description = "TLS 1.3 client with no_std support and no allocator"
documentation = "https://docs.rs/embedded-tls"
Expand All @@ -23,9 +23,9 @@ digest = { version = "0.10.3", default-features = false, features = ["core-api"]
typenum = { version = "1.15.0", default-features = false }
heapless = { version = "0.7", default-features = false }
heapless_typenum = { package = "heapless", version = "0.6", default-features = false }
embedded-io = "0.5"
embedded-io-async = { version = "0.5", optional = true }
embedded-io-adapters = { version = "0.5", optional = true }
embedded-io = "0.6"
embedded-io-async = { version = "0.6", optional = true }
embedded-io-adapters = { version = "0.6", optional = true }
generic-array = { version = "0.14", default-features = false }
#webpki = { version = "0.22.0", default-features = false }
#webpki = { path = "../../webpki", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions examples/blocking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ authors = [

[dependencies]
embedded-tls = { path = "../..", features = ["log", "std", "webpki"], default-features = false }
embedded-io = { version = "0.5.0" }
embedded-io-adapters = { version = "0.5.0", features = ["std"] }
embedded-io = { version = "0.6.0" }
embedded-io-adapters = { version = "0.6.0", features = ["std"] }
pem-parser = "0.1"
env_logger = "0.10"
rand = "0.8"
Expand Down
4 changes: 2 additions & 2 deletions examples/embassy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ futures = { version = "0.3.17" }
libc = "0.2.101"
clap = { version = "3.0", features = ["derive", "color"] }
heapless = { version = "0.7.5", default-features = false }
embedded-io-async = { version = "0.5.0" }
embedded-io-adapters = { version = "0.5.0", features = ["futures-03"] }
embedded-io-async = { version = "0.6.0" }
embedded-io-adapters = { version = "0.6.0", features = ["futures-03"] }
critical-section = { version = "1.1", features = ["std"] }

[patch.crates-io]
Expand Down
2 changes: 1 addition & 1 deletion examples/nrf52/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [

[dependencies]
embedded-tls = { path = "../..", default-features = false }
embedded-io = "0.5.0"
embedded-io = "0.6.0"
defmt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }
Expand Down
4 changes: 2 additions & 2 deletions examples/tokio-psk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"

[dependencies]
embedded-tls = { path = "../..", features = ["log", "tokio"] }
embedded-io-adapters = { version = "0.5.0", features = ["tokio-1"] }
embedded-io-async = "0.5.0"
embedded-io-adapters = { version = "0.6.0", features = ["tokio-1"] }
embedded-io-async = "0.6.0"
env_logger = "0.10"
tokio = { version = "1.7", features = ["full"] }
rand = "0.8"
Expand Down
4 changes: 2 additions & 2 deletions examples/tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ authors = [

[dependencies]
embedded-tls = { path = "../..", features = ["log", "tokio"] }
embedded-io-adapters = { version = "0.5.0", features = ["tokio-1"] }
embedded-io-async = "0.5.0"
embedded-io-adapters = { version = "0.6.0", features = ["tokio-1"] }
embedded-io-async = "0.6.0"
env_logger = "0.10"
tokio = { version = "1.7", features = ["full"] }
rand = "0.8"
Expand Down
15 changes: 12 additions & 3 deletions src/asynch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ where
let key_schedule = self.key_schedule.write_state();
let slice = self.record_write_buf.close_record(key_schedule)?;

self.delegate.write_all(slice).await?;
self.delegate
.write_all(slice)
.await
.map_err(|e| TlsError::Io(e.kind()))?;

key_schedule.increment_counter();

Expand Down Expand Up @@ -213,7 +216,10 @@ where
Some(read_key_schedule),
)?;

self.delegate.write_all(slice).await?;
self.delegate
.write_all(slice)
.await
.map_err(|e| TlsError::Io(e.kind()))?;

self.key_schedule.write_state().increment_counter();

Expand Down Expand Up @@ -511,7 +517,10 @@ where
if !self.record_write_buf.is_empty() {
let slice = self.record_write_buf.close_record(&mut self.key_schedule)?;

self.delegate.write_all(slice).await?;
self.delegate
.write_all(slice)
.await
.map_err(|e| TlsError::Io(e.kind()))?;

self.key_schedule.increment_counter();

Expand Down
12 changes: 9 additions & 3 deletions src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ where
let key_schedule = self.key_schedule.write_state();
let slice = self.record_write_buf.close_record(key_schedule)?;

self.delegate.write_all(slice)?;
self.delegate
.write_all(slice)
.map_err(|e| TlsError::Io(e.kind()))?;

key_schedule.increment_counter();

Expand Down Expand Up @@ -204,7 +206,9 @@ where
Some(read_key_schedule),
)?;

self.delegate.write_all(slice)?;
self.delegate
.write_all(slice)
.map_err(|e| TlsError::Io(e.kind()))?;

self.key_schedule.write_state().increment_counter();

Expand Down Expand Up @@ -503,7 +507,9 @@ where
if !self.record_write_buf.is_empty() {
let slice = self.record_write_buf.close_record(&mut self.key_schedule)?;

self.delegate.write_all(slice)?;
self.delegate
.write_all(slice)
.map_err(|e| TlsError::Io(e.kind()))?;

self.key_schedule.increment_counter();

Expand Down
9 changes: 7 additions & 2 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ fn respond_blocking<CipherSuite>(
where
CipherSuite: TlsCipherSuite,
{
transport.write_all(tx)?;
transport
.write_all(tx)
.map_err(|e| TlsError::Io(e.kind()))?;

key_schedule.write_state().increment_counter();

Expand Down Expand Up @@ -372,7 +374,10 @@ async fn respond<CipherSuite>(
where
CipherSuite: TlsCipherSuite,
{
transport.write_all(tx).await?;
transport
.write_all(tx)
.await
.map_err(|e| TlsError::Io(e.kind()))?;

key_schedule.write_state().increment_counter();

Expand Down
13 changes: 0 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,6 @@ impl embedded_io::Error for TlsError {
}
}

use embedded_io::WriteAllError;
impl<E> From<WriteAllError<E>> for TlsError
where
E: embedded_io::Error,
{
fn from(e: WriteAllError<E>) -> Self {
match e {
WriteAllError::WriteZero => Self::IoError,
WriteAllError::Other(e) => Self::Io(e.kind()),
}
}
}

#[cfg(feature = "std")]
mod stdlib {
use crate::config::TlsClock;
Expand Down

0 comments on commit 0e360db

Please sign in to comment.