From f3c011f83385c75b13867c7ddff9f158e59d5edc Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 8 Dec 2023 22:24:07 +0800 Subject: [PATCH] update embassy dep and compiler --- Cargo.lock | 106 ++++++----- Cargo.toml | 32 ++-- async/rust-toolchain.toml | 2 +- embassy/demos/picow/rust-toolchain.toml | 2 +- embassy/demos/picow/src/takepipe.rs | 229 ------------------------ embassy/demos/std/rust-toolchain.toml | 2 +- embassy/rust-toolchain.toml | 2 +- rust-toolchain.toml | 2 +- src/lib.rs | 2 - 9 files changed, 83 insertions(+), 296 deletions(-) delete mode 100644 embassy/demos/picow/src/takepipe.rs diff --git a/Cargo.lock b/Cargo.lock index 1903082..cd82e46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -576,14 +576,14 @@ dependencies = [ [[package]] name = "cyw43" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "cortex-m", "cortex-m-rt", "defmt", - "embassy-futures", + "embassy-futures 0.1.0", "embassy-net-driver-channel", - "embassy-sync", + "embassy-sync 0.4.0", "embassy-time", "embedded-hal 1.0.0-rc.1", "futures", @@ -593,7 +593,7 @@ dependencies = [ [[package]] name = "cyw43-pio" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "cyw43", "embassy-rp", @@ -876,10 +876,10 @@ dependencies = [ [[package]] name = "embassy-embedded-hal" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ - "embassy-futures", - "embassy-sync", + "embassy-futures 0.1.0", + "embassy-sync 0.4.0", "embassy-time", "embedded-hal 0.2.7", "embedded-hal 1.0.0-rc.1", @@ -907,8 +907,8 @@ dependencies = [ [[package]] name = "embassy-executor" -version = "0.3.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +version = "0.3.2" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "atomic-polyfill 1.0.3", "cortex-m", @@ -916,19 +916,23 @@ dependencies = [ "defmt", "embassy-macros 0.2.1", "embassy-time", - "futures-util", - "static_cell", ] [[package]] name = "embassy-futures" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" + +[[package]] +name = "embassy-futures" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f878075b9794c1e4ac788c95b728f26aa6366d32eeb10c7051389f898f7d067" [[package]] name = "embassy-hal-internal" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "cortex-m", "critical-section 1.1.2", @@ -951,7 +955,7 @@ dependencies = [ [[package]] name = "embassy-macros" version = "0.2.1" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "darling 0.20.3", "proc-macro2", @@ -961,13 +965,13 @@ dependencies = [ [[package]] name = "embassy-net" -version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +version = "0.2.1" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "as-slice 0.2.1", "atomic-pool", "embassy-net-driver", - "embassy-sync", + "embassy-sync 0.4.0", "embassy-time", "embedded-io-async", "embedded-nal-async", @@ -983,22 +987,22 @@ dependencies = [ [[package]] name = "embassy-net-driver" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" [[package]] name = "embassy-net-driver-channel" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ - "embassy-futures", + "embassy-futures 0.1.0", "embassy-net-driver", - "embassy-sync", + "embassy-sync 0.4.0", ] [[package]] name = "embassy-net-tuntap" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "async-io", "embassy-net-driver", @@ -1009,9 +1013,9 @@ dependencies = [ [[package]] name = "embassy-net-wiznet" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ - "embassy-futures", + "embassy-futures 0.1.0", "embassy-net-driver-channel", "embassy-time", "embedded-hal 1.0.0-rc.1", @@ -1021,7 +1025,7 @@ dependencies = [ [[package]] name = "embassy-rp" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "atomic-polyfill 1.0.3", "cfg-if", @@ -1030,9 +1034,9 @@ dependencies = [ "critical-section 1.1.2", "defmt", "embassy-embedded-hal", - "embassy-futures", + "embassy-futures 0.1.0", "embassy-hal-internal", - "embassy-sync", + "embassy-sync 0.4.0", "embassy-time", "embassy-usb-driver", "embedded-hal 0.2.7", @@ -1056,7 +1060,19 @@ dependencies = [ [[package]] name = "embassy-sync" version = "0.3.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0525b466ca3ace30b57f2db868a35215dfaecd038d8668cb2db03feb7c069a0" +dependencies = [ + "cfg-if", + "critical-section 1.1.2", + "futures-util", + "heapless", +] + +[[package]] +name = "embassy-sync" +version = "0.4.0" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "cfg-if", "critical-section 1.1.2", @@ -1067,7 +1083,7 @@ dependencies = [ [[package]] name = "embassy-time" version = "0.1.5" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "cfg-if", "critical-section 1.1.2", @@ -1083,11 +1099,11 @@ dependencies = [ [[package]] name = "embassy-usb" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ - "embassy-futures", + "embassy-futures 0.1.0", "embassy-net-driver-channel", - "embassy-sync", + "embassy-sync 0.4.0", "embassy-usb-driver", "heapless", "ssmarshal", @@ -1097,7 +1113,7 @@ dependencies = [ [[package]] name = "embassy-usb-driver" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy/?rev=d496a1213c70cdabf12c802e8d39ea6abbce6720#d496a1213c70cdabf12c802e8d39ea6abbce6720" +source = "git+https://github.com/embassy-rs/embassy/?rev=78a7ee7ec48a6ed26d770165e777beb06e92777c#78a7ee7ec48a6ed26d770165e777beb06e92777c" dependencies = [ "defmt", ] @@ -2818,8 +2834,8 @@ version = "0.1.0" dependencies = [ "anyhow", "argh", - "embassy-futures", - "embassy-sync", + "embassy-futures 0.1.1", + "embassy-sync 0.3.0", "embedded-io-adapters", "embedded-io-async", "futures", @@ -2844,13 +2860,14 @@ dependencies = [ name = "sunset-demo-embassy-common" version = "0.1.0" dependencies = [ + "anyhow", "bcrypt", "defmt", "ed25519-dalek 2.0.0-rc.3", - "embassy-futures", + "embassy-futures 0.1.1", "embassy-net", "embassy-net-driver", - "embassy-sync", + "embassy-sync 0.3.0", "embassy-time", "embedded-io-async", "heapless", @@ -2861,6 +2878,7 @@ dependencies = [ "sunset", "sunset-embassy", "sunset-sshwire-derive", + "tokio", ] [[package]] @@ -2876,13 +2894,13 @@ dependencies = [ "cyw43-pio", "defmt", "defmt-rtt", - "embassy-executor 0.3.0", - "embassy-futures", + "embassy-executor 0.3.2", + "embassy-futures 0.1.1", "embassy-net", "embassy-net-driver", "embassy-net-wiznet", "embassy-rp", - "embassy-sync", + "embassy-sync 0.3.0", "embassy-time", "embassy-usb", "embassy-usb-driver", @@ -2918,10 +2936,10 @@ dependencies = [ "atomic-polyfill 0.1.11", "critical-section 1.1.2", "embassy-executor 0.1.1", - "embassy-futures", + "embassy-futures 0.1.1", "embassy-net", "embassy-net-tuntap", - "embassy-sync", + "embassy-sync 0.3.0", "embassy-time", "embedded-io-async", "env_logger", @@ -2942,8 +2960,8 @@ version = "0.2.0-alpha" dependencies = [ "atomic-polyfill 1.0.3", "defmt", - "embassy-futures", - "embassy-sync", + "embassy-futures 0.1.1", + "embassy-sync 0.3.0", "embedded-io-async", "log", "pin-utils", diff --git a/Cargo.toml b/Cargo.toml index a7d444e..5e459ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ subtle = { version = "2.4", default-features = false } ed25519-dalek = { version = "2.0.0-rc.3", default-features = false, features = ["zeroize", "rand_core", "hazmat"] } x25519-dalek = { version = "2.0.0-rc.3", default-features = false, features = ["zeroize"] } curve25519-dalek = { version = "4.0.0", default-features = false, features = ["zeroize"] } - +# p521 = { version = "0.13.2", default-features = false, features = ["ecdh", "ecdsa"] } rsa = { version = "0.8", default-features = false, optional = true, features = ["sha2"] } # TODO: getrandom feature is a workaround for missing ssh-key dependency with rsa. fixed in pending 0.6 ssh-key = { version = "0.5", default-features = false, optional = true, features = ["getrandom"] } @@ -88,22 +88,22 @@ x25519-dalek = { git = "https://github.com/mkj/curve25519-dalek", branch = "suns # ed25519-dalek = { path = "/home/matt/3rd/rs/crypto/curve25519-dalek/ed25519-dalek" } # x25519-dalek = { path = "/home/matt/3rd/rs/crypto/curve25519-dalek/x25519-dalek" } -embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-usb = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-usb-driver = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } +embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +# embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-usb = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +# embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-usb-driver = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } # for cyw43 -embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-net-tuntap = { git = "https://github.com/embassy-rs/embassy", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } - -cyw43 = { git = "https://github.com/embassy-rs/embassy/", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -cyw43-pio = { git = "https://github.com/embassy-rs/embassy/", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } -embassy-net-wiznet = { git = "https://github.com/embassy-rs/embassy/", rev = "d496a1213c70cdabf12c802e8d39ea6abbce6720" } +embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-net-tuntap = { git = "https://github.com/embassy-rs/embassy", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } + +cyw43 = { git = "https://github.com/embassy-rs/embassy/", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +cyw43-pio = { git = "https://github.com/embassy-rs/embassy/", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } +embassy-net-wiznet = { git = "https://github.com/embassy-rs/embassy/", rev = "78a7ee7ec48a6ed26d770165e777beb06e92777c" } # embassy-net = { path = "/home/matt/3rd/rs/embassy/embassy-net" } # embassy-net-driver = { path = "/home/matt/3rd/rs/embassy/embassy-net-driver" } diff --git a/async/rust-toolchain.toml b/async/rust-toolchain.toml index ea5b5ea..0c21c9b 100644 --- a/async/rust-toolchain.toml +++ b/async/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-02" +channel = "nightly-2023-11-01" components = [ "rustfmt" ] diff --git a/embassy/demos/picow/rust-toolchain.toml b/embassy/demos/picow/rust-toolchain.toml index ea5b5ea..0c21c9b 100644 --- a/embassy/demos/picow/rust-toolchain.toml +++ b/embassy/demos/picow/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-02" +channel = "nightly-2023-11-01" components = [ "rustfmt" ] diff --git a/embassy/demos/picow/src/takepipe.rs b/embassy/demos/picow/src/takepipe.rs deleted file mode 100644 index 259c05a..0000000 --- a/embassy/demos/picow/src/takepipe.rs +++ /dev/null @@ -1,229 +0,0 @@ -#[allow(unused_imports)] -#[cfg(not(feature = "defmt"))] -pub use { - log::{debug, error, info, log, trace, warn}, -}; - -#[allow(unused_imports)] -#[cfg(feature = "defmt")] -pub use defmt::{debug, info, warn, panic, error, trace}; - -use core::ops::DerefMut; - -use embedded_io_async::{Write, Read, ErrorType}; - -use embassy_sync::{pipe, mutex::Mutex, signal::Signal}; -use embassy_sync::pipe::Pipe; -use embassy_futures::select::{select, Either}; - -use sunset_embassy::SunsetRawMutex; - -pub const READ_SIZE: usize = 4000; -pub const WRITE_SIZE: usize = 64; - -// TODO: this is fairly ugly, the mutex and counter could perhaps be abstracted - -/// Allows a bidirectional pipe to be shared by many endpoints -/// -/// One end of the pipe is fixed (attached to eg a physical/virtual -/// uart), used with `.split()`. `TakePipeStorage` is the backing store, -/// the `TakePipe` struct returned by `.pipe()` has the functionality. -/// -/// The other end can be used by many clients, one at a time. -/// When a subsequent client takes the pipe (with `.take()`), the existing -/// client loses the pipe and gets EOF. -/// -/// It works a bit like `screen -r -d`. -pub(crate) struct TakePipeStorage { - fanout: Pipe, - fanin: Pipe, -} - -impl TakePipeStorage { - pub fn new() -> Self { - Default::default() - } - - pub fn build(&mut self) -> TakePipe { - let (fanout_r, fanout_w) = self.fanout.split(); - let (fanin_r, fanin_w) = self.fanin.split(); - TakePipe { - shared_read: Mutex::new((0, fanout_r)), - shared_write: Mutex::new((0, fanin_w)), - reader: fanin_r, - writer: fanout_w, - wake: Signal::new(), - } - } -} - -impl Default for TakePipeStorage { - fn default() -> Self { - Self { - fanout: Pipe::new(), - fanin: Pipe::new(), - } - } -} - -pub(crate) struct TakePipe<'a> { - // fanout - shared_read: Mutex)>, - writer: pipe::Writer<'a, SunsetRawMutex, READ_SIZE>, - // fanin - reader: pipe::Reader<'a, SunsetRawMutex, WRITE_SIZE>, - shared_write: Mutex)>, - wake: Signal, -} - -impl<'a> TakePipe<'a> { - pub async fn take(&'a self) -> (TakeRead<'a>, TakeWrite<'a>) { - - self.wake.signal(()); - let mut lr = self.shared_read.lock().await; - let (cr, _r) = lr.deref_mut(); - let mut lw = self.shared_write.lock().await; - let (cw, _w) = lw.deref_mut(); - *cr += 1; - *cw += 1; - debug_assert!(*cr == *cw); - // We could .clear() the pipes, but - // that wouldn't deal with data that has already progressed - // further along out the SSH channel etc. So we leave that - // for high levels to deal with if needed. - self.wake.reset(); - - let r = TakeRead { - pipe: Some(self), - counter: *cr, - }; - let w = TakeWrite { - pipe: Some(self), - counter: *cw, - }; - (r, w) - } - - pub fn is_in_use(&self) -> bool { - self.shared_read.try_lock().is_err() - } - - pub fn split(&'a self) -> (TakePipeRead<'a>, TakePipeWrite<'a>) { - let r = TakePipeRead { - pipe: self, - }; - let w = TakePipeWrite { - pipe: self, - }; - (r, w) - } -} - -pub(crate) struct TakePipeRead<'a> { - pipe: &'a TakePipe<'a>, -} - -pub(crate) struct TakePipeWrite<'a> { - pipe: &'a TakePipe<'a>, -} - -impl<'a> Read for TakePipeRead<'a> { - async fn read(&mut self, buf: &mut [u8]) -> sunset::Result { - let r = self.pipe.reader.read(buf).await; - Ok(r) - } -} - -impl<'a> Write for TakePipeWrite<'a> { - async fn write(&mut self, buf: &[u8]) -> sunset::Result { - let r = self.pipe.writer.write(buf).await; - Ok(r) - } -} - -impl ErrorType for TakePipeRead<'_> { - type Error = sunset::Error; -} - -impl ErrorType for TakePipeWrite<'_> { - type Error = sunset::Error; -} - -pub(crate) struct TakeRead<'a> { - pipe: Option<&'a TakePipe<'a>>, - counter: u64, -} - -impl Read for TakeRead<'_> { - - async fn read(&mut self, buf: &mut [u8]) -> sunset::Result { - let p = self.pipe.ok_or(sunset::Error::ChannelEOF)?; - - let op = async { - let mut p = p.shared_read.lock().await; - let (c, o) = p.deref_mut(); - if *c != self.counter { - return Err(sunset::Error::ChannelEOF); - } - Ok(o.read(buf).await) - }; - - let r = select( - op, - p.wake.wait(), - ); - - match r.await { - // read completed - Either::First(l) => l, - // lost the pipe - Either::Second(()) => { - self.pipe = None; - Err(sunset::Error::ChannelEOF) - } - } - } -} - -impl ErrorType for TakeRead<'_> { - type Error = sunset::Error; -} - -pub(crate) struct TakeWrite<'a> { - pipe: Option<&'a TakePipe<'a>>, - counter: u64, -} - -impl Write for TakeWrite<'_> { - async fn write(&mut self, buf: &[u8]) -> sunset::Result { - let p = self.pipe.ok_or(sunset::Error::ChannelEOF)?; - - let op = async { - let mut p = p.shared_write.lock().await; - let (c, o) = p.deref_mut(); - if *c != self.counter { - return Err(sunset::Error::ChannelEOF); - } - Ok(o.write(buf).await) - }; - - let r = select( - op, - p.wake.wait(), - ); - - match r.await { - // write completed - Either::First(l) => l, - // lost the pipe - Either::Second(_) => { - self.pipe = None; - Err(sunset::Error::ChannelEOF) - } - } - } -} - -impl ErrorType for TakeWrite<'_> { - type Error = sunset::Error; -} diff --git a/embassy/demos/std/rust-toolchain.toml b/embassy/demos/std/rust-toolchain.toml index ea5b5ea..0c21c9b 100644 --- a/embassy/demos/std/rust-toolchain.toml +++ b/embassy/demos/std/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-02" +channel = "nightly-2023-11-01" components = [ "rustfmt" ] diff --git a/embassy/rust-toolchain.toml b/embassy/rust-toolchain.toml index ea5b5ea..0c21c9b 100644 --- a/embassy/rust-toolchain.toml +++ b/embassy/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-02" +channel = "nightly-2023-11-01" components = [ "rustfmt" ] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ea5b5ea..0c21c9b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-10-02" +channel = "nightly-2023-11-01" components = [ "rustfmt" ] diff --git a/src/lib.rs b/src/lib.rs index c484b8a..b433b6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,6 @@ // XXX unused_imports only during dev churn #![allow(unused_imports)] -#![feature(async_fn_in_trait)] - // XXX decide what is public pub mod conn; pub mod encrypt;