Skip to content
1,097 changes: 629 additions & 468 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ arbitrary = { version = "1.4", features = ["derive_arbitrary"] }
[dependencies]
sunset-sshwire-derive = { workspace = true }

snafu = { version = "0.8", default-features = false, features = ["rust_1_65"] }
snafu = { version = "0.8", default-features = false, features = ["rust_1_81"] }
log = { version = "0.4" }
heapless = "0.8"
heapless = "0.9"

# allows avoiding utf8 for SSH identifier names
ascii = { version = "1.0", default-features = false }
Expand Down Expand Up @@ -62,7 +62,8 @@ rsa = { version = "0.9", default-features = false, optional = true, features = [
# TODO: getrandom feature is a workaround for missing ssh-key dependency with rsa. fixed in pending 0.6
ssh-key = { version = "0.6", default-features = false, optional = true, features = ["getrandom"] }

embedded-io = { version = "0.6", optional = true }
embedded-io = { version = "0.7", optional = true }
embedded-io-async = { version = "0.7", optional = true }

# for debug printing
pretty-hex = { version = "0.4", default-features = false }
Expand All @@ -87,7 +88,7 @@ larger = []
[dev-dependencies]
# examples want std::error
snafu = { version = "0.8", default-features = true }
anyhow = { version = "1.0" }
anyhow = { version = "1" }
pretty-hex = "0.4"
simplelog = { version = "0.12", features = ["test"] }

Expand Down
2 changes: 1 addition & 1 deletion async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Async for Sunset SSH"
[dependencies]
embassy-sync = { version = "0.7" }
embassy-futures = { version = "0.1" }
embedded-io-async = "0.6"
embedded-io-async = "0.7"
portable-atomic.workspace = true

sunset = { workspace = true, features = ["embedded-io"] }
Expand Down
51 changes: 42 additions & 9 deletions async/src/async_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,33 @@ impl ErrorType for ChanIO<'_> {
}

impl Read for ChanIO<'_> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, sunset::Error> {
poll_fn(|cx| self.sunset.poll_read_channel(cx, self.num, self.dt, buf)).await
async fn read(
&mut self,
buf: &mut [u8],
) -> core::result::Result<usize, sunset::Error> {
poll_fn(|cx| self.sunset.poll_read_channel(cx, self.num, self.dt, buf))
.await
.map_err(Into::into)
}
}

impl Write for ChanIO<'_> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, sunset::Error> {
async fn write(
&mut self,
buf: &[u8],
) -> core::result::Result<usize, sunset::Error> {
poll_fn(|cx| self.sunset.poll_write_channel(cx, self.num, self.dt, buf))
.await
.map_err(Into::into)
}

// TODO: not sure how easy end-to-end flush is
// async fn flush(&mut self) -> Result<(), Self::Error> {
// }
async fn flush(&mut self) -> core::result::Result<(), sunset::Error> {
// No-op flush: underlying SSH channel does not expose an explicit
// flush operation via the sunset ChanCore API, so treat flush as
// immediately successful.
Ok(())
}
}

// Public wrappers for In only
Expand Down Expand Up @@ -238,25 +251,45 @@ impl ErrorType for ChanOut<'_> {
}

impl Read for ChanInOut<'_> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, sunset::Error> {
async fn read(
&mut self,
buf: &mut [u8],
) -> core::result::Result<usize, sunset::Error> {
self.0.read(buf).await
}
}

impl Write for ChanInOut<'_> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, sunset::Error> {
async fn write(
&mut self,
buf: &[u8],
) -> core::result::Result<usize, sunset::Error> {
self.0.write(buf).await
}

async fn flush(&mut self) -> core::result::Result<(), sunset::Error> {
self.0.flush().await
}
}

impl Read for ChanIn<'_> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, sunset::Error> {
async fn read(
&mut self,
buf: &mut [u8],
) -> core::result::Result<usize, sunset::Error> {
self.0.read(buf).await
}
}

impl Write for ChanOut<'_> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, sunset::Error> {
async fn write(
&mut self,
buf: &[u8],
) -> core::result::Result<usize, sunset::Error> {
self.0.write(buf).await
}

async fn flush(&mut self) -> core::result::Result<(), sunset::Error> {
self.0.flush().await
}
}
2 changes: 1 addition & 1 deletion demo/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ embassy-time = { version = "0.4" }
heapless = "0.8"
# using local fork
# menu = "0.3"
embedded-io-async = "0.6"
embedded-io-async = "0.7"
sha2 = { version = "0.10", default-features = false }
hmac = { version = "0.12", default-features = false }

Expand Down
4 changes: 2 additions & 2 deletions demo/picow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ rtt-target = { version = "0.6", features = ["log"] }

pretty-hex = { version = "0.4", default-features = false }

snafu = { version = "0.8", default-features = false, features = ["rust_1_65"] }
snafu = { version = "0.8", default-features = false, features = ["rust_1_81"] }

cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.0"
Expand All @@ -43,7 +43,7 @@ embedded-hal = "1.0"
embedded-hal-async = "1.0"
# embedded-hal-bus need to match embassy-net-wiznet's version
embedded-hal-bus = { version = "0.1", features = ["async"], optional = true }
embedded-io-async = "0.6"
embedded-io-async = "0.7"
embedded-storage-async = "0.4"
heapless = "0.8"

Expand Down
4 changes: 2 additions & 2 deletions demo/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ log = { version = "0.4" }
# default regex feature is huge
env_logger = { version = "0.11", default-features=false, features = ["auto-color", "humantime"] }

embedded-io-async = "0.6"
heapless = "0.8"
embedded-io-async = "0.7"
heapless = "0.9"

# for tuntap
libc = "0.2.101"
Expand Down
13 changes: 10 additions & 3 deletions src/namelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use ascii::{AsciiChar::Comma, AsciiStr};
use sunset_sshwire_derive::{SSHDecode, SSHEncode};

use crate::*;
use heapless::Vec;
use heapless::{CapacityError, Vec};
use sshwire::{SSHDecode, SSHEncode, SSHSink, SSHSource, WireResult};

// Used for lists of:
Expand Down Expand Up @@ -100,11 +100,18 @@ impl<'a> TryFrom<&'a str> for NameList<'a> {

// for tests
impl TryFrom<&[&'static str]> for LocalNames {
type Error = ();
fn try_from(s: &[&'static str]) -> Result<Self, ()> {
type Error = sunset::error::Error;
fn try_from(s: &[&'static str]) -> Result<Self, Error> {
Ok(Self(Vec::from_slice(s)?))
}
}

impl From<CapacityError> for Error {
fn from(_e: CapacityError) -> Error {
error::NoRoom.build()
}
}

impl<'a> From<&'a LocalNames> for NameList<'a> {
fn from(s: &'a LocalNames) -> Self {
NameList::Local(s)
Expand Down
8 changes: 3 additions & 5 deletions stdasync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sunset-sshwire-derive.workspace = true
sunset-async.workspace = true

log = { version = "0.4", features = ["release_max_level_trace"] }
heapless = "0.9"
rpassword = "7.2"
argh = "0.1"

Expand All @@ -20,7 +21,7 @@ ssh-key = { version = "0.6", default-features = false, features = [ "std"] }
embassy-sync = { version = "0.7" }
embassy-futures = { version = "0.1" }

embedded-io-async = "0.6"
embedded-io-async = "0.7"

# "net" for AsyncFd on unix
tokio = { version = "1.25", features = ["net", "io-util", "signal"] }
Expand All @@ -29,9 +30,6 @@ futures = "0.3"
libc = "0.2"
nix = "0.26"

heapless = "0.8"

# TODO
pretty-hex = "0.4"

[features]
Expand All @@ -46,7 +44,7 @@ zeroize = "1.5"
tokio = { version = "1.25", features = ["full"] }

# adapters for tokio and async-std
embedded-io-adapters = { version = "0.6", features = ["tokio-1"] }
embedded-io-adapters = { version = "0.7", features = ["tokio-1"] }

simplelog = "0.12"
# for simplelog
Expand Down
2 changes: 1 addition & 1 deletion stdasync/src/cmdline_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use sunset_async::*;

use embassy_sync::channel::Channel;
use embassy_sync::signal::Signal;
use embedded_io_async::{Read as _, Write as _};
use embedded_io_async::{Read, Write};
use std::collections::VecDeque;

use tokio::io::AsyncReadExt;
Expand Down
Loading