diff --git a/.github/actions/ci-checks/action.yml b/.github/actions/ci-checks/action.yml index 6fe92971..f0df138c 100644 --- a/.github/actions/ci-checks/action.yml +++ b/.github/actions/ci-checks/action.yml @@ -9,7 +9,9 @@ inputs: runs: using: composite steps: - - if: ${{ contains(fromJSON(inputs.checks), 'changelog') }} + - if: >- + ${{ contains(fromJSON(inputs.checks), 'changelog') + || contains(fromJSON(inputs.checks), 'sync') }} uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 81480bc2..ef39b246 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -4,6 +4,8 @@ on: push: branches: - main + paths: + - 'book/**' permissions: {} diff --git a/crates/protocol/CHANGELOG.md b/crates/protocol/CHANGELOG.md index 757b0b53..57aca747 100644 --- a/crates/protocol/CHANGELOG.md +++ b/crates/protocol/CHANGELOG.md @@ -2,4 +2,4 @@ ## 0.1.0-git - + diff --git a/crates/protocol/crates/schema/src/main.rs b/crates/protocol/crates/schema/src/main.rs index 6479fdc9..0e5c4b74 100644 --- a/crates/protocol/crates/schema/src/main.rs +++ b/crates/protocol/crates/schema/src/main.rs @@ -42,14 +42,11 @@ fn check(old: &View, new: &View) -> Result<()> { for (_, tag, api) in get_enum(&old).context("in old")? { ensure!(old_map.insert(tag, api).is_none(), "duplicate tag {tag}"); } - for (name, tag, new_api) in get_enum(&new).context("in new")? { + for (_, tag, new_api) in get_enum(&new).context("in new")? { if let Some(old_api) = old_map.remove(tag) { let old_api = ViewFields(old_api); let new_api = ViewFields(new_api); - ensure!( - old_api == new_api, - "incompatible API for {name}={tag}: {old_api} vs {new_api}" - ); + ensure!(old_api == new_api, "incompatible API for {tag}: {old_api} != {new_api}"); } } #[cfg(feature = "full")] diff --git a/crates/protocol/src/lib.rs b/crates/protocol/src/lib.rs index 606e51e2..1061b4cd 100644 --- a/crates/protocol/src/lib.rs +++ b/crates/protocol/src/lib.rs @@ -26,11 +26,11 @@ #![no_std] #![feature(doc_auto_cfg)] +#![feature(never_type)] extern crate alloc; use alloc::boxed::Box; -use core::convert::Infallible; use wasefire_error::Error; use wasefire_wire::Wire; @@ -105,7 +105,7 @@ api! { /// Errors reported by the device. /// /// This may be returned regardless of the request type. - 0 DeviceError: Infallible => Error, + 0 DeviceError: ! => Error, /// Sends a request to an applet. 1 AppletRequest: applet::Request<'a> => (), @@ -114,8 +114,7 @@ api! { 2 AppletResponse: applet::AppletId => applet::Response<'a>, /// Reboots the platform. - // TODO: Should return unit. Device should always respond. - 3 PlatformReboot: () => Infallible, + 3 PlatformReboot: () => !, /// Starts a direct tunnel with an applet. 4 AppletTunnel: applet::Tunnel<'a> => (), diff --git a/crates/wire/CHANGELOG.md b/crates/wire/CHANGELOG.md index 7bcc0814..6faacf76 100644 --- a/crates/wire/CHANGELOG.md +++ b/crates/wire/CHANGELOG.md @@ -2,4 +2,4 @@ ## 0.1.0-git - + diff --git a/crates/wire/src/lib.rs b/crates/wire/src/lib.rs index 148801ff..cc22b2b8 100644 --- a/crates/wire/src/lib.rs +++ b/crates/wire/src/lib.rs @@ -37,6 +37,7 @@ #![no_std] #![feature(array_try_from_fn)] #![feature(doc_auto_cfg)] +#![feature(never_type)] #![feature(try_blocks)] extern crate alloc; @@ -298,6 +299,21 @@ impl<'a> internal::Wire<'a> for Error { } } +impl<'a> internal::Wire<'a> for ! { + #[cfg(feature = "schema")] + type Static = !; + #[cfg(feature = "schema")] + fn schema(rules: &mut Rules) { + if rules.enum_::(Vec::new()) {} + } + fn encode(&self, _: &mut Writer<'a>) -> Result<(), Error> { + match *self {} + } + fn decode(_: &mut Reader<'a>) -> Result { + Err(Error::user(Code::InvalidArgument)) + } +} + #[internal_wire] #[wire(crate = crate)] enum Infallible {} diff --git a/scripts/sync.sh b/scripts/sync.sh index c48cce40..fdeea46d 100755 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -49,6 +49,11 @@ for dir in $(find crates -name Cargo.toml -printf '%h\n' | sort); do # add_lint $file warn rust.unused-results done +( cd crates/protocol/crates/schema + cargo run --features=full + cargo run +) + book_example() { local src=book/src/applet/prelude/$1.rs local dst=examples/rust/$2/src/lib.rs