From 7f3a3f39baca016e99976b91f58effbcc37c5983 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 27 Aug 2026 18:40:28 +0530 Subject: [PATCH] Enable unreachable_pub lint in the scheduler Removes the scheduler from the unreachable_pub exclusion list in scripts/sync.sh, adds the lint to crates/scheduler/Cargo.toml, and restricts crate-internal items to pub(crate). The crate's public API (lib.rs) is unchanged. Continues the incremental work of #565, following #1139 (interpreter). Verified on host: cargo check across all feature/target combinations from crates/scheduler/test.sh (host wasm/std, i686 native, and thumbv7em wasm/pulley/native with and without defmt) reports zero unreachable_pub warnings; cargo test --lib, cargo clippy, and cargo fmt --check pass. --- crates/scheduler/CHANGELOG.md | 1 + crates/scheduler/Cargo.toml | 1 + crates/scheduler/src/applet.rs | 60 +++++++++---------- crates/scheduler/src/applet/store.rs | 8 +-- crates/scheduler/src/applet/store/native.rs | 4 +- crates/scheduler/src/applet/store/pulley.rs | 24 ++++---- crates/scheduler/src/applet/store/wasm.rs | 14 ++--- crates/scheduler/src/call.rs | 2 +- crates/scheduler/src/call/button.rs | 2 +- crates/scheduler/src/call/clock.rs | 2 +- crates/scheduler/src/call/crypto.rs | 2 +- crates/scheduler/src/call/crypto/cbc.rs | 2 +- crates/scheduler/src/call/crypto/ccm.rs | 2 +- crates/scheduler/src/call/crypto/ec.rs | 2 +- crates/scheduler/src/call/crypto/ecdh.rs | 2 +- crates/scheduler/src/call/crypto/ecdsa.rs | 2 +- crates/scheduler/src/call/crypto/ed25519.rs | 2 +- crates/scheduler/src/call/crypto/gcm.rs | 2 +- crates/scheduler/src/call/crypto/hash.rs | 2 +- crates/scheduler/src/call/debug.rs | 2 +- crates/scheduler/src/call/fingerprint.rs | 2 +- .../scheduler/src/call/fingerprint/matcher.rs | 2 +- .../scheduler/src/call/fingerprint/sensor.rs | 2 +- crates/scheduler/src/call/gpio.rs | 2 +- crates/scheduler/src/call/led.rs | 2 +- crates/scheduler/src/call/platform.rs | 2 +- .../scheduler/src/call/platform/protocol.rs | 2 +- crates/scheduler/src/call/platform/update.rs | 2 +- crates/scheduler/src/call/rng.rs | 2 +- crates/scheduler/src/call/scheduling.rs | 2 +- crates/scheduler/src/call/store.rs | 2 +- crates/scheduler/src/call/store/fragment.rs | 2 +- crates/scheduler/src/call/timer.rs | 2 +- crates/scheduler/src/call/uart.rs | 2 +- crates/scheduler/src/call/usb.rs | 2 +- crates/scheduler/src/call/usb/ctap.rs | 2 +- crates/scheduler/src/call/usb/serial.rs | 2 +- crates/scheduler/src/call/vendor.rs | 2 +- crates/scheduler/src/event.rs | 28 ++++----- crates/scheduler/src/event/button.rs | 6 +- crates/scheduler/src/event/fingerprint.rs | 10 ++-- .../src/event/fingerprint/matcher.rs | 6 +- .../scheduler/src/event/fingerprint/sensor.rs | 6 +- crates/scheduler/src/event/gpio.rs | 6 +- crates/scheduler/src/event/platform.rs | 8 +-- .../scheduler/src/event/platform/protocol.rs | 6 +- crates/scheduler/src/event/timer.rs | 6 +- crates/scheduler/src/event/uart.rs | 6 +- crates/scheduler/src/event/usb.rs | 10 ++-- crates/scheduler/src/event/usb/ctap.rs | 6 +- crates/scheduler/src/event/usb/serial.rs | 6 +- crates/scheduler/src/event/vendor.rs | 6 +- crates/scheduler/src/perf.rs | 8 +-- crates/scheduler/src/protocol.rs | 10 ++-- scripts/sync.sh | 2 +- 55 files changed, 158 insertions(+), 152 deletions(-) diff --git a/crates/scheduler/CHANGELOG.md b/crates/scheduler/CHANGELOG.md index d70387639..3ea7366a5 100644 --- a/crates/scheduler/CHANGELOG.md +++ b/crates/scheduler/CHANGELOG.md @@ -9,6 +9,7 @@ ### Patch +- Enable `unreachable_pub` lint - Disable `unused-features` lint - Use heterogeneous try blocks when needed - Update dependencies diff --git a/crates/scheduler/Cargo.toml b/crates/scheduler/Cargo.toml index 9e5cc5804..d0ffb79fc 100644 --- a/crates/scheduler/Cargo.toml +++ b/crates/scheduler/Cargo.toml @@ -346,4 +346,5 @@ internal-hash-context = [] clippy.mod_module_files = "warn" clippy.uninlined_format_args = "allow" clippy.unit_arg = "allow" +rust.unreachable_pub = "warn" rust.unused_crate_dependencies = "warn" diff --git a/crates/scheduler/src/applet.rs b/crates/scheduler/src/applet.rs index b06e29ff2..c0441965d 100644 --- a/crates/scheduler/src/applet.rs +++ b/crates/scheduler/src/applet.rs @@ -30,10 +30,10 @@ use crate::Trap; use crate::event::InstId; use crate::event::{Handler, Key}; -pub mod store; +pub(crate) mod store; #[allow(clippy::large_enum_variant)] -pub enum Slot { +pub(crate) enum Slot { #[cfg(any(feature = "pulley", feature = "wasm"))] Empty, Running(Applet), @@ -41,7 +41,7 @@ pub enum Slot { } impl Slot { - pub fn get(&mut self) -> Option<&mut Applet> { + pub(crate) fn get(&mut self) -> Option<&mut Applet> { match self { Slot::Running(x) => Some(x), _ => None, @@ -50,7 +50,7 @@ impl Slot { } #[cfg_attr(not(feature = "pulley"), derive_where(Default))] -pub struct Applet { +pub(crate) struct Applet { pub store: self::store::Store, pub events: Events, @@ -67,7 +67,7 @@ pub struct Applet { } #[derive_where(Default)] -pub struct Events { +pub(crate) struct Events { /// Pending events. pending: VecDeque>, @@ -76,7 +76,7 @@ pub struct Events { } #[cfg(feature = "board-api-vendor")] -pub struct Handlers<'a, B: Board> { +pub(crate) struct Handlers<'a, B: Board> { inst: Option, events: &'a mut Events, } @@ -93,7 +93,7 @@ enum Protocol { /// Currently alive hash contexts. #[cfg(feature = "internal-hash-context")] -pub struct AppletHashes([Option>; 4]); +pub(crate) struct AppletHashes([Option>; 4]); // We have to implement manually because derive is not able to find the correct bounds. #[cfg(feature = "internal-hash-context")] @@ -104,7 +104,7 @@ impl Default for AppletHashes { } #[cfg(feature = "internal-hash-context")] -pub enum HashContext { +pub(crate) enum HashContext { #[cfg(feature = "board-api-crypto-sha256")] Sha256(board::crypto::HashApi>), #[cfg(feature = "board-api-crypto-sha384")] @@ -118,17 +118,17 @@ pub enum HashContext { #[cfg(feature = "internal-hash-context")] impl AppletHashes { - pub fn insert(&mut self, hash: HashContext) -> Result { + pub(crate) fn insert(&mut self, hash: HashContext) -> Result { let id = self.0.iter().position(|x| x.is_none()).ok_or(Trap)?; self.0[id] = Some(hash); Ok(id) } - pub fn get_mut(&mut self, id: usize) -> Result<&mut HashContext, Trap> { + pub(crate) fn get_mut(&mut self, id: usize) -> Result<&mut HashContext, Trap> { self.0.get_mut(id).ok_or(Trap)?.as_mut().ok_or(Trap) } - pub fn take(&mut self, id: usize) -> Result, Trap> { + pub(crate) fn take(&mut self, id: usize) -> Result, Trap> { self.0.get_mut(id).ok_or(Trap)?.take().ok_or(Trap) } } @@ -157,7 +157,7 @@ impl Events { } #[cfg(feature = "board-api-vendor")] - pub fn handlers(&mut self, inst: Option) -> Handlers<'_, B> { + pub(crate) fn handlers(&mut self, inst: Option) -> Handlers<'_, B> { Handlers { inst, events: self } } } @@ -178,7 +178,7 @@ impl<'a, B: Board> board::applet::Handlers> for Handlers<' impl Applet { #[cfg(feature = "pulley")] - pub fn new(store: self::store::Store) -> Self { + pub(crate) fn new(store: self::store::Store) -> Self { Applet { store, events: Events::default(), @@ -190,16 +190,16 @@ impl Applet { } } - pub fn store_mut(&mut self) -> &mut Store { + pub(crate) fn store_mut(&mut self) -> &mut Store { &mut self.store } #[allow(dead_code)] // in case no API uses memory - pub fn memory(&mut self) -> Memory<'_> { + pub(crate) fn memory(&mut self) -> Memory<'_> { self.store.memory() } - pub fn push(&mut self, event: Event) { + pub(crate) fn push(&mut self, event: Event) { const MAX_EVENTS: usize = 5; #[allow(clippy::if_same_then_else)] if !self.events.handlers.contains(&Key::from(&event)) { @@ -217,7 +217,7 @@ impl Applet { } /// Returns the next event action. - pub fn pop(&mut self) -> EventAction { + pub(crate) fn pop(&mut self) -> EventAction { #[cfg(any(feature = "pulley", feature = "wasm"))] if core::mem::replace(&mut self.done, false) { return EventAction::Reply; @@ -229,27 +229,27 @@ impl Applet { } #[cfg(any(feature = "pulley", feature = "wasm"))] - pub fn done(&mut self) { + pub(crate) fn done(&mut self) { self.done = true; } #[allow(dead_code)] // in case there are no events - pub fn enable(&mut self, handler: Handler) -> Result<(), Trap> { + pub(crate) fn enable(&mut self, handler: Handler) -> Result<(), Trap> { self.events.enable(handler) } - pub fn disable(&mut self, key: Key) -> Result<(), Trap> { + pub(crate) fn disable(&mut self, key: Key) -> Result<(), Trap> { self.events.disable(key) } #[cfg_attr(not(feature = "board-api-fingerprint-matcher"), allow(dead_code))] - pub fn disable_noerror(&mut self, key: Key) { + pub(crate) fn disable_noerror(&mut self, key: Key) { if self.disable(key).is_err() { log::warn!("Failed disabling {:?}", key); } } - pub fn free(&mut self) { + pub(crate) fn free(&mut self) { self.events.pending.clear(); for &Handler { key, .. } in &self.events.handlers { if let Err(error) = key.disable() { @@ -258,21 +258,21 @@ impl Applet { } } - pub fn get(&self, key: Key) -> Option<&Handler> { + pub(crate) fn get(&self, key: Key) -> Option<&Handler> { self.events.handlers.get(&key) } #[cfg(any(feature = "pulley", feature = "wasm"))] - pub fn has_handlers(&self) -> bool { + pub(crate) fn has_handlers(&self) -> bool { !self.events.handlers.is_empty() } - pub fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { self.events.pending.len() } #[cfg(feature = "applet-api-platform-protocol")] - pub fn put_request(&mut self, event: Event, request: &[u8]) -> Result<(), Error> { + pub(crate) fn put_request(&mut self, event: Event, request: &[u8]) -> Result<(), Error> { self.get(Key::from(&event)).ok_or(Error::world(Code::InvalidState))?; // If the applet is processing a request, we'll send the event when they respond. if !matches!(self.protocol, Protocol::Processing) { @@ -284,7 +284,7 @@ impl Applet { } #[cfg(feature = "applet-api-platform-protocol")] - pub fn get_request(&mut self) -> Result>, Error> { + pub(crate) fn get_request(&mut self) -> Result>, Error> { let (update, result) = match core::mem::take(&mut self.protocol) { x @ (Protocol::Empty | Protocol::Response(_)) => (x, Ok(None)), Protocol::Request(x) => (Protocol::Processing, Ok(Some(x))), @@ -295,7 +295,7 @@ impl Applet { } #[cfg(feature = "applet-api-platform-protocol")] - pub fn put_response(&mut self, response: Box<[u8]>) -> Result<(), Error> { + pub(crate) fn put_response(&mut self, response: Box<[u8]>) -> Result<(), Error> { match &self.protocol { Protocol::Processing => self.protocol = Protocol::Response(response), // We use World:InvalidState to know that there is a new request. @@ -306,7 +306,7 @@ impl Applet { } #[cfg(feature = "applet-api-platform-protocol")] - pub fn get_response(&mut self) -> Result>, Error> { + pub(crate) fn get_response(&mut self) -> Result>, Error> { let (update, result) = match core::mem::take(&mut self.protocol) { x @ (Protocol::Processing | Protocol::Request(_)) => (x, Ok(None)), Protocol::Response(x) => (Protocol::Empty, Ok(Some(x))), @@ -319,7 +319,7 @@ impl Applet { /// Action when waiting for callbacks. #[derive(Debug)] -pub enum EventAction { +pub(crate) enum EventAction { /// Should handle the event. Handle(Event), diff --git a/crates/scheduler/src/applet/store.rs b/crates/scheduler/src/applet/store.rs index 9a5c8a35a..28f790678 100644 --- a/crates/scheduler/src/applet/store.rs +++ b/crates/scheduler/src/applet/store.rs @@ -14,18 +14,18 @@ use wasefire_board_api::applet::Memory as AppletMemory; -pub use self::impl_::Store; +pub(crate) use self::impl_::Store; #[cfg(feature = "pulley")] -pub use self::impl_::{PreStore, RunResult}; +pub(crate) use self::impl_::{PreStore, RunResult}; #[cfg_attr(feature = "native", path = "store/native.rs")] #[cfg_attr(feature = "pulley", path = "store/pulley.rs")] #[cfg_attr(feature = "wasm", path = "store/wasm.rs")] mod impl_; -pub type Memory<'a> = ::Memory<'a>; +pub(crate) type Memory<'a> = ::Memory<'a>; -pub trait StoreApi { +pub(crate) trait StoreApi { type Memory<'a>: AppletMemory where Self: 'a; diff --git a/crates/scheduler/src/applet/store/native.rs b/crates/scheduler/src/applet/store/native.rs index 0f7fe1532..1b1d802bd 100644 --- a/crates/scheduler/src/applet/store/native.rs +++ b/crates/scheduler/src/applet/store/native.rs @@ -20,9 +20,9 @@ use super::StoreApi; use crate::Trap; #[derive(Debug, Default)] -pub struct Store(()); +pub(crate) struct Store(()); -pub struct Memory; +pub(crate) struct Memory; impl StoreApi for Store { type Memory<'a> diff --git a/crates/scheduler/src/applet/store/pulley.rs b/crates/scheduler/src/applet/store/pulley.rs index b652d3c5e..1bd778524 100644 --- a/crates/scheduler/src/applet/store/pulley.rs +++ b/crates/scheduler/src/applet/store/pulley.rs @@ -33,7 +33,7 @@ use wasmtime::{ use super::StoreApi; use crate::Trap; -pub struct PreStore { +pub(crate) struct PreStore { engine: Engine, store: WtStore<()>, linker: Linker<()>, @@ -57,7 +57,7 @@ impl Default for PreStore { } impl PreStore { - pub fn link_func(&mut self, id: usize, name: &str, params: usize) -> Result<(), Error> { + pub(crate) fn link_func(&mut self, id: usize, name: &str, params: usize) -> Result<(), Error> { let item = match params { 0 => Func::wrap_async(&mut self.store, move |caller, ()| call(caller, id, vec![])), 1 => Func::wrap_async(&mut self.store, move |caller, args: (u32,)| { @@ -109,7 +109,9 @@ impl PreStore { } // Safety: the slice must outlive the store. - pub unsafe fn instantiate(mut self, pulley: &'static [u8], id: usize) -> Result { + pub(crate) unsafe fn instantiate( + mut self, pulley: &'static [u8], id: usize, + ) -> Result { let Ok(module) = (unsafe { Module::deserialize_raw(&self.engine, pulley.into()) }) else { log::warn!("Failed to deserialize pulley module."); return Err(Error::user(Code::InvalidArgument)); @@ -154,7 +156,7 @@ impl PreStore { } } -pub struct Store { +pub(crate) struct Store { instance: Instance, // Owned Box if threads is empty, otherwise the first thread exclusively owns it. store: *mut WtStore<()>, @@ -188,14 +190,16 @@ impl Drop for Store { } } -pub enum RunResult { +pub(crate) enum RunResult { Done(Vec), Host, Trap, } impl Store { - pub fn invoke(&mut self, name: &str, args: &[u32], nres: usize) -> Result { + pub(crate) fn invoke( + &mut self, name: &str, args: &[u32], nres: usize, + ) -> Result { let mut context = self.context(); let Some(func) = self.instance.get_func(&mut context, name) else { return Err(Error::internal(Code::NotFound)); @@ -211,14 +215,14 @@ impl Store { Ok(self.execute()) } - pub fn resume(&mut self, result: u32) -> Result { + pub(crate) fn resume(&mut self, result: u32) -> Result { assert_eq!(self.calls.len(), self.threads.len()); self.calls.pop(); STATE.put(State::Reply(result)); Ok(self.execute()) } - pub fn last_call(&self) -> Option<&Call> { + pub(crate) fn last_call(&self) -> Option<&Call> { self.calls.last() } @@ -255,7 +259,7 @@ impl Store { } } -pub struct Call { +pub(crate) struct Call { // This is an owned box. The lifetime is bound to the thread of this call (the one at the same // index in the store). caller: ExclusivePtr>, @@ -304,7 +308,7 @@ impl StoreApi for Store { } } -pub struct Memory<'a> { +pub(crate) struct Memory<'a> { store: *mut Store, memory: SliceCell<'a, u8>, } diff --git a/crates/scheduler/src/applet/store/wasm.rs b/crates/scheduler/src/applet/store/wasm.rs index 5899d645f..f199a6d7b 100644 --- a/crates/scheduler/src/applet/store/wasm.rs +++ b/crates/scheduler/src/applet/store/wasm.rs @@ -26,13 +26,13 @@ use super::StoreApi; use crate::Trap; #[derive(Debug, Default)] -pub struct Store { +pub(crate) struct Store { inst: Option, store: InterpreterStore<'static>, } impl Store { - pub fn instantiate( + pub(crate) fn instantiate( &mut self, module: Module<'static>, memory: &'static mut [u8], ) -> Result { // We assume a single module per applet. @@ -42,23 +42,23 @@ impl Store { Ok(inst) } - pub fn link_func( + pub(crate) fn link_func( &mut self, module: &'static str, name: &'static str, params: usize, results: usize, ) -> Result<(), Error> { self.store.link_func(module, name, params, results) } - pub fn link_func_default(&mut self, module: &'static str) -> Result<(), Error> { + pub(crate) fn link_func_default(&mut self, module: &'static str) -> Result<(), Error> { self.store.link_func_default(module) } - pub fn invoke<'a>( + pub(crate) fn invoke<'a>( &'a mut self, inst: InstId, name: &str, args: Vec, ) -> Result, Error> { self.store.invoke(inst, name, args) } - pub fn last_call(&mut self) -> Option> { + pub(crate) fn last_call(&mut self) -> Option> { self.store.last_call() } } @@ -76,7 +76,7 @@ impl StoreApi for Store { } } -pub struct Memory<'a> { +pub(crate) struct Memory<'a> { store: *mut Store, memory: SliceCell<'a, u8>, } diff --git a/crates/scheduler/src/call.rs b/crates/scheduler/src/call.rs index 8013811e4..6fa37f7b8 100644 --- a/crates/scheduler/src/call.rs +++ b/crates/scheduler/src/call.rs @@ -76,7 +76,7 @@ mod usb; #[cfg(feature = "applet-api-vendor")] mod vendor; -pub fn process(call: Api>) { +pub(crate) fn process(call: Api>) { match call { #[cfg(feature = "applet-api-button")] Api::Button(call) => button::process(call), diff --git a/crates/scheduler/src/call/button.rs b/crates/scheduler/src/call/button.rs index b7fbeb11e..55cb26ee5 100644 --- a/crates/scheduler/src/call/button.rs +++ b/crates/scheduler/src/call/button.rs @@ -23,7 +23,7 @@ use wasefire_error::{Code, Error}; use crate::event::{Handler, button::Key}; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Count(call) => count(call), Api::Register(call) => or_fail!("board-api-button", register(call)), diff --git a/crates/scheduler/src/call/clock.rs b/crates/scheduler/src/call/clock.rs index e239118ad..739785a70 100644 --- a/crates/scheduler/src/call/clock.rs +++ b/crates/scheduler/src/call/clock.rs @@ -25,7 +25,7 @@ use crate::DispatchSchedulerCall; #[cfg(feature = "board-api-clock")] use crate::SchedulerCall; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::UptimeUs(call) => or_fail!("board-api-clock", uptime_us(call)), } diff --git a/crates/scheduler/src/call/crypto.rs b/crates/scheduler/src/call/crypto.rs index 79060a2f0..8a9056284 100644 --- a/crates/scheduler/src/call/crypto.rs +++ b/crates/scheduler/src/call/crypto.rs @@ -34,7 +34,7 @@ use wasefire_board_api::Api as Board; use crate::DispatchSchedulerCall; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { #[cfg(feature = "applet-api-crypto-cbc")] Api::Cbc(call) => cbc::process(call), diff --git a/crates/scheduler/src/call/crypto/cbc.rs b/crates/scheduler/src/call/crypto/cbc.rs index 3d655c91d..17129aa74 100644 --- a/crates/scheduler/src/call/crypto/cbc.rs +++ b/crates/scheduler/src/call/crypto/cbc.rs @@ -25,7 +25,7 @@ use wasefire_board_api::{self as board, Support}; use crate::Trap; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::Encrypt(call) => or_fail!("board-api-crypto-aes256-cbc", encrypt(call)), diff --git a/crates/scheduler/src/call/crypto/ccm.rs b/crates/scheduler/src/call/crypto/ccm.rs index af3e6baa5..71f57ce12 100644 --- a/crates/scheduler/src/call/crypto/ccm.rs +++ b/crates/scheduler/src/call/crypto/ccm.rs @@ -25,7 +25,7 @@ use wasefire_board_api::{self as board, Support}; use crate::Trap; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::Encrypt(call) => or_fail!("board-api-crypto-aes128-ccm", encrypt(call)), diff --git a/crates/scheduler/src/call/crypto/ec.rs b/crates/scheduler/src/call/crypto/ec.rs index aae255af9..d5878e11a 100644 --- a/crates/scheduler/src/call/crypto/ec.rs +++ b/crates/scheduler/src/call/crypto/ec.rs @@ -25,7 +25,7 @@ use wasefire_board_api::{self as board, Support}; use crate::{DispatchSchedulerCall, SchedulerCall, Trap}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::IsValidScalar(call) => { diff --git a/crates/scheduler/src/call/crypto/ecdh.rs b/crates/scheduler/src/call/crypto/ecdh.rs index 84ff19b8f..66c5bb470 100644 --- a/crates/scheduler/src/call/crypto/ecdh.rs +++ b/crates/scheduler/src/call/crypto/ecdh.rs @@ -30,7 +30,7 @@ use wasefire_error::{Code, Error}; use crate::applet::store::Memory; use crate::{DispatchSchedulerCall, Failure, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::GetLayout(call) => or_fail!("internal-board-api-crypto-ecdh", get_layout(call)), diff --git a/crates/scheduler/src/call/crypto/ecdsa.rs b/crates/scheduler/src/call/crypto/ecdsa.rs index 2c56f0ac5..fb70d91ed 100644 --- a/crates/scheduler/src/call/crypto/ecdsa.rs +++ b/crates/scheduler/src/call/crypto/ecdsa.rs @@ -30,7 +30,7 @@ use wasefire_error::{Code, Error}; use crate::applet::store::Memory; use crate::{DispatchSchedulerCall, Failure, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::GetLayout(call) => or_fail!("internal-board-api-crypto-ecdsa", get_layout(call)), diff --git a/crates/scheduler/src/call/crypto/ed25519.rs b/crates/scheduler/src/call/crypto/ed25519.rs index 0a8f984bc..76dc580a0 100644 --- a/crates/scheduler/src/call/crypto/ed25519.rs +++ b/crates/scheduler/src/call/crypto/ed25519.rs @@ -31,7 +31,7 @@ use crate::Failure; use crate::applet::store::Memory; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::GetLayout(call) => or_fail!("board-api-crypto-ed25519", get_layout(call)), diff --git a/crates/scheduler/src/call/crypto/gcm.rs b/crates/scheduler/src/call/crypto/gcm.rs index a1dfdf162..cfac8c1ac 100644 --- a/crates/scheduler/src/call/crypto/gcm.rs +++ b/crates/scheduler/src/call/crypto/gcm.rs @@ -25,7 +25,7 @@ use wasefire_board_api::{self as board, Support as _}; use crate::Trap; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Support(call) => support(call), Api::TagLength(call) => or_fail!("board-api-crypto-aes256-gcm", tag_length(call)), diff --git a/crates/scheduler/src/call/crypto/hash.rs b/crates/scheduler/src/call/crypto/hash.rs index 5b9d3d011..9c1bee5cd 100644 --- a/crates/scheduler/src/call/crypto/hash.rs +++ b/crates/scheduler/src/call/crypto/hash.rs @@ -26,7 +26,7 @@ use crate::applet::HashContext; use crate::applet::store::StoreApi; use crate::{DispatchSchedulerCall, Failure, SchedulerCall, Trap}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { #[cfg(feature = "applet-api-crypto-hash")] Api::IsSupported(call) => is_supported(call), diff --git a/crates/scheduler/src/call/debug.rs b/crates/scheduler/src/call/debug.rs index 7567bf274..380906ec1 100644 --- a/crates/scheduler/src/call/debug.rs +++ b/crates/scheduler/src/call/debug.rs @@ -19,7 +19,7 @@ use wasefire_board_api::{self as board, Api as Board}; use crate::{DispatchSchedulerCall, SchedulerCall, Trap}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Println(call) => println(call), Api::Time(call) => time(call), diff --git a/crates/scheduler/src/call/fingerprint.rs b/crates/scheduler/src/call/fingerprint.rs index a63d80213..bb3310dc8 100644 --- a/crates/scheduler/src/call/fingerprint.rs +++ b/crates/scheduler/src/call/fingerprint.rs @@ -32,7 +32,7 @@ mod matcher; #[cfg(feature = "applet-api-fingerprint-sensor")] mod sensor; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { #[cfg(feature = "applet-api-fingerprint-matcher")] Api::Matcher(call) => matcher::process(call), diff --git a/crates/scheduler/src/call/fingerprint/matcher.rs b/crates/scheduler/src/call/fingerprint/matcher.rs index c5cd65a22..b1829fabb 100644 --- a/crates/scheduler/src/call/fingerprint/matcher.rs +++ b/crates/scheduler/src/call/fingerprint/matcher.rs @@ -26,7 +26,7 @@ use wasefire_board_api::{self as board, Support}; use crate::event::{Handler, fingerprint::matcher::Key}; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::TemplateLength(call) => { diff --git a/crates/scheduler/src/call/fingerprint/sensor.rs b/crates/scheduler/src/call/fingerprint/sensor.rs index d61a75449..0118e1439 100644 --- a/crates/scheduler/src/call/fingerprint/sensor.rs +++ b/crates/scheduler/src/call/fingerprint/sensor.rs @@ -24,7 +24,7 @@ use wasefire_board_api::{self as board, Support}; use crate::event::{Handler, fingerprint::sensor::Key}; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::IsSupported(call) => is_supported(call), Api::Capture(call) => or_fail!("board-api-fingerprint-sensor", capture(call)), diff --git a/crates/scheduler/src/call/gpio.rs b/crates/scheduler/src/call/gpio.rs index d688fdad7..86c8d9b16 100644 --- a/crates/scheduler/src/call/gpio.rs +++ b/crates/scheduler/src/call/gpio.rs @@ -25,7 +25,7 @@ use wasefire_error::{Code, Error}; use crate::event::{Handler, gpio::Key}; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Count(call) => count(call), Api::Configure(call) => or_fail!("board-api-gpio", configure(call)), diff --git a/crates/scheduler/src/call/led.rs b/crates/scheduler/src/call/led.rs index 916532434..2152fac6c 100644 --- a/crates/scheduler/src/call/led.rs +++ b/crates/scheduler/src/call/led.rs @@ -21,7 +21,7 @@ use wasefire_board_api::{self as board, Id, Support}; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Count(call) => count(call), Api::Get(call) => or_fail!("board-api-led", get(call)), diff --git a/crates/scheduler/src/call/platform.rs b/crates/scheduler/src/call/platform.rs index a08cbf293..78b1a35e5 100644 --- a/crates/scheduler/src/call/platform.rs +++ b/crates/scheduler/src/call/platform.rs @@ -34,7 +34,7 @@ mod protocol; #[cfg(feature = "applet-api-platform-update")] mod update; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { #[cfg(feature = "applet-api-platform-protocol")] Api::Protocol(call) => protocol::process(call), diff --git a/crates/scheduler/src/call/platform/protocol.rs b/crates/scheduler/src/call/platform/protocol.rs index 0e84c0d1b..22c99802a 100644 --- a/crates/scheduler/src/call/platform/protocol.rs +++ b/crates/scheduler/src/call/platform/protocol.rs @@ -21,7 +21,7 @@ use crate::event::Handler; use crate::event::platform::protocol::Key; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Read(call) => read(call), Api::Write(call) => write(call), diff --git a/crates/scheduler/src/call/platform/update.rs b/crates/scheduler/src/call/platform/update.rs index cf008e37a..45b5fb2c4 100644 --- a/crates/scheduler/src/call/platform/update.rs +++ b/crates/scheduler/src/call/platform/update.rs @@ -19,7 +19,7 @@ use wasefire_board_api::{self as board, Api as Board}; use crate::{DispatchSchedulerCall, SchedulerCall, Trap}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Initialize(call) => initialize(call), Api::Process(call) => process_(call), diff --git a/crates/scheduler/src/call/rng.rs b/crates/scheduler/src/call/rng.rs index eb7172ff1..67ed06e4e 100644 --- a/crates/scheduler/src/call/rng.rs +++ b/crates/scheduler/src/call/rng.rs @@ -27,7 +27,7 @@ use crate::DispatchSchedulerCall; #[cfg(feature = "board-api-rng")] use crate::SchedulerCall; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::FillBytes(call) => or_fail!("board-api-rng", fill_bytes(call)), } diff --git a/crates/scheduler/src/call/scheduling.rs b/crates/scheduler/src/call/scheduling.rs index 333799e39..09ca07497 100644 --- a/crates/scheduler/src/call/scheduling.rs +++ b/crates/scheduler/src/call/scheduling.rs @@ -17,7 +17,7 @@ use wasefire_board_api::Api as Board; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::WaitForCallback(call) => wait_for_callback(call), Api::NumPendingCallbacks(call) => num_pending_callbacks(call), diff --git a/crates/scheduler/src/call/store.rs b/crates/scheduler/src/call/store.rs index deaa87d43..5eef037dd 100644 --- a/crates/scheduler/src/call/store.rs +++ b/crates/scheduler/src/call/store.rs @@ -30,7 +30,7 @@ use crate::SchedulerCall; #[cfg(feature = "applet-api-store-fragment")] mod fragment; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { #[cfg(feature = "applet-api-store")] Api::MaxKey(call) => or_fail!("board-api-store", max_key(call)), diff --git a/crates/scheduler/src/call/store/fragment.rs b/crates/scheduler/src/call/store/fragment.rs index 28471a1f2..3c83d37ef 100644 --- a/crates/scheduler/src/call/store/fragment.rs +++ b/crates/scheduler/src/call/store/fragment.rs @@ -27,7 +27,7 @@ use crate::DispatchSchedulerCall; #[cfg(feature = "board-api-store-fragment")] use crate::SchedulerCall; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Insert(call) => or_fail!("board-api-store-fragment", insert(call)), Api::Remove(call) => or_fail!("board-api-store-fragment", remove(call)), diff --git a/crates/scheduler/src/call/timer.rs b/crates/scheduler/src/call/timer.rs index 0162dce90..80a984042 100644 --- a/crates/scheduler/src/call/timer.rs +++ b/crates/scheduler/src/call/timer.rs @@ -27,7 +27,7 @@ use crate::{DispatchSchedulerCall, SchedulerCall}; #[cfg(feature = "board-api-timer")] use crate::{Scheduler, Timer}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Allocate(call) => allocate(call), Api::Start(call) => or_fail!("board-api-timer", start(call)), diff --git a/crates/scheduler/src/call/uart.rs b/crates/scheduler/src/call/uart.rs index 2f919ff36..cd9999639 100644 --- a/crates/scheduler/src/call/uart.rs +++ b/crates/scheduler/src/call/uart.rs @@ -27,7 +27,7 @@ use crate::Failure; use crate::event::{Handler, uart::Key}; use crate::{DispatchSchedulerCall, SchedulerCall}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Count(call) => count(call), Api::SetBaudrate(call) => or_fail!("board-api-uart", set_baudrate(call)), diff --git a/crates/scheduler/src/call/usb.rs b/crates/scheduler/src/call/usb.rs index 44e2f1e04..cd57ca9af 100644 --- a/crates/scheduler/src/call/usb.rs +++ b/crates/scheduler/src/call/usb.rs @@ -22,7 +22,7 @@ mod ctap; #[cfg(feature = "applet-api-usb-serial")] mod serial; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { #[cfg(feature = "applet-api-usb-ctap")] Api::Ctap(call) => ctap::process(call), diff --git a/crates/scheduler/src/call/usb/ctap.rs b/crates/scheduler/src/call/usb/ctap.rs index bedc77c4a..dfb42bd5e 100644 --- a/crates/scheduler/src/call/usb/ctap.rs +++ b/crates/scheduler/src/call/usb/ctap.rs @@ -29,7 +29,7 @@ use crate::event::{Handler, usb::ctap::Key}; #[cfg(feature = "board-api-usb-ctap")] use crate::{SchedulerCall, Trap}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Read(call) => or_fail!("board-api-usb-ctap", read(call)), Api::Write(call) => or_fail!("board-api-usb-ctap", write(call)), diff --git a/crates/scheduler/src/call/usb/serial.rs b/crates/scheduler/src/call/usb/serial.rs index 5b6a940c4..28f4d8767 100644 --- a/crates/scheduler/src/call/usb/serial.rs +++ b/crates/scheduler/src/call/usb/serial.rs @@ -29,7 +29,7 @@ use crate::event::{Handler, usb::serial::Key}; #[cfg(feature = "board-api-usb-serial")] use crate::{SchedulerCall, Trap}; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Read(call) => or_fail!("board-api-usb-serial", read(call)), Api::Write(call) => or_fail!("board-api-usb-serial", write(call)), diff --git a/crates/scheduler/src/call/vendor.rs b/crates/scheduler/src/call/vendor.rs index 831ac7b62..b195d4fb6 100644 --- a/crates/scheduler/src/call/vendor.rs +++ b/crates/scheduler/src/call/vendor.rs @@ -25,7 +25,7 @@ use crate::SchedulerCall; #[cfg(feature = "board-api-vendor")] use crate::applet::store::StoreApi as _; -pub fn process(call: Api>) { +pub(super) fn process(call: Api>) { match call { Api::Syscall(call) => or_fail!("board-api-vendor", syscall(call)), } diff --git a/crates/scheduler/src/event.rs b/crates/scheduler/src/event.rs index 1afafd7c5..73ef65291 100644 --- a/crates/scheduler/src/event.rs +++ b/crates/scheduler/src/event.rs @@ -19,35 +19,35 @@ use derive_where::derive_where; use wasefire_board_api::{Api as Board, Event, Impossible}; use wasefire_error::Error; #[cfg(feature = "wasm")] -pub use wasefire_interpreter::InstId; +pub(crate) use wasefire_interpreter::InstId; use wasefire_logger as log; use crate::Scheduler; #[cfg(feature = "board-api-button")] -pub mod button; +pub(crate) mod button; #[cfg(feature = "internal-board-api-fingerprint")] -pub mod fingerprint; +pub(crate) mod fingerprint; #[cfg(feature = "board-api-gpio")] -pub mod gpio; -pub mod platform; +pub(crate) mod gpio; +pub(crate) mod platform; #[cfg(feature = "board-api-timer")] -pub mod timer; +pub(crate) mod timer; #[cfg(feature = "board-api-uart")] -pub mod uart; +pub(crate) mod uart; #[cfg(feature = "internal-board-api-usb")] -pub mod usb; +pub(crate) mod usb; #[cfg(feature = "board-api-vendor")] -pub mod vendor; +pub(crate) mod vendor; #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg(any(feature = "native", feature = "pulley"))] -pub struct InstId; +pub(crate) struct InstId; // TODO: This could be encoded into a u32 for performance/footprint. #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive_where(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { #[cfg(feature = "board-api-button")] Button(button::Key), #[cfg(feature = "internal-board-api-fingerprint")] @@ -125,7 +125,7 @@ impl<'a, B: Board> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { match self { #[cfg(feature = "board-api-button")] Key::Button(x) => x.disable(), @@ -148,7 +148,7 @@ impl Key { } #[derive_where(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] -pub struct Handler { +pub(crate) struct Handler { pub key: Key, pub inst: InstId, pub func: u32, @@ -162,7 +162,7 @@ impl Borrow> for Handler { } #[cfg_attr(feature = "native", allow(clippy::needless_pass_by_ref_mut))] -pub fn process(scheduler: &mut Scheduler, event: Event) { +pub(crate) fn process(scheduler: &mut Scheduler, event: Event) { let applet = scheduler.applet.get().unwrap(); let (inst, func, data) = match applet.get(Key::from(&event)) { Some(x) => (x.inst, x.func, x.data), diff --git a/crates/scheduler/src/event/button.rs b/crates/scheduler/src/event/button.rs index a2e9dbe9d..c47c70b69 100644 --- a/crates/scheduler/src/event/button.rs +++ b/crates/scheduler/src/event/button.rs @@ -21,7 +21,7 @@ use wasefire_error::Error; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive_where(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct Key { +pub(crate) struct Key { pub button: Id>, } @@ -38,12 +38,12 @@ impl<'a, B: Board> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::button::Api as _; board::Button::::disable(self.button) } } -pub fn process(event: Event, params: &mut Vec) { +pub(crate) fn process(event: Event, params: &mut Vec) { params.push(event.pressed as u32); } diff --git a/crates/scheduler/src/event/fingerprint.rs b/crates/scheduler/src/event/fingerprint.rs index cb1a7004d..e15085cfa 100644 --- a/crates/scheduler/src/event/fingerprint.rs +++ b/crates/scheduler/src/event/fingerprint.rs @@ -21,13 +21,13 @@ use wasefire_error::Error; use crate::applet::Applet; #[cfg(feature = "board-api-fingerprint-matcher")] -pub mod matcher; +pub(crate) mod matcher; #[cfg(feature = "board-api-fingerprint-sensor")] -pub mod sensor; +pub(crate) mod sensor; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { #[cfg(feature = "board-api-fingerprint-matcher")] Matcher(matcher::Key), @@ -56,7 +56,7 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { match self { #[cfg(feature = "board-api-fingerprint-matcher")] Key::Matcher(x) => x.disable::(), @@ -67,7 +67,7 @@ impl Key { } } -pub fn process(event: Event, params: &mut Vec, applet: &mut Applet) { +pub(crate) fn process(event: Event, params: &mut Vec, applet: &mut Applet) { match event { #[cfg(feature = "board-api-fingerprint-matcher")] Event::Matcher(event) => matcher::process(event, params, applet), diff --git a/crates/scheduler/src/event/fingerprint/matcher.rs b/crates/scheduler/src/event/fingerprint/matcher.rs index 0a979a300..5ab8a1141 100644 --- a/crates/scheduler/src/event/fingerprint/matcher.rs +++ b/crates/scheduler/src/event/fingerprint/matcher.rs @@ -23,7 +23,7 @@ use crate::applet::Applet; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { Enroll, EnrollStep, Identify, @@ -46,7 +46,7 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::fingerprint::matcher::Api as _; match self { Key::Enroll => board::fingerprint::Matcher::::abort_enroll(), @@ -56,7 +56,7 @@ impl Key { } } -pub fn process(event: Event, params: &mut Vec, applet: &mut Applet) { +pub(crate) fn process(event: Event, params: &mut Vec, applet: &mut Applet) { match event { Event::EnrollStep { remaining } => params.push(remaining as u32), Event::EnrollDone => { diff --git a/crates/scheduler/src/event/fingerprint/sensor.rs b/crates/scheduler/src/event/fingerprint/sensor.rs index 86792b6cc..50c301c39 100644 --- a/crates/scheduler/src/event/fingerprint/sensor.rs +++ b/crates/scheduler/src/event/fingerprint/sensor.rs @@ -23,7 +23,7 @@ use crate::applet::Applet; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { Capture, } @@ -42,7 +42,7 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::fingerprint::sensor::Api as _; match self { Key::Capture => board::fingerprint::Sensor::::abort_capture(), @@ -50,7 +50,7 @@ impl Key { } } -pub fn process(event: Event, params: &mut Vec, applet: &mut Applet) { +pub(crate) fn process(event: Event, params: &mut Vec, applet: &mut Applet) { match event { Event::CaptureDone => { let width = board::fingerprint::Sensor::::IMAGE_WIDTH as u32; diff --git a/crates/scheduler/src/event/gpio.rs b/crates/scheduler/src/event/gpio.rs index 0483bcdfb..d91c0ea71 100644 --- a/crates/scheduler/src/event/gpio.rs +++ b/crates/scheduler/src/event/gpio.rs @@ -19,7 +19,7 @@ use wasefire_error::Error; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive_where(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct Key { +pub(crate) struct Key { pub gpio: Id>, } @@ -36,10 +36,10 @@ impl<'a, B: Board> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::gpio::Api as _; board::Gpio::::disable(self.gpio) } } -pub fn process() {} +pub(crate) fn process() {} diff --git a/crates/scheduler/src/event/platform.rs b/crates/scheduler/src/event/platform.rs index 84470a049..2b3c9ac69 100644 --- a/crates/scheduler/src/event/platform.rs +++ b/crates/scheduler/src/event/platform.rs @@ -16,11 +16,11 @@ use wasefire_board_api::Api as Board; use wasefire_board_api::platform::Event; use wasefire_error::Error; -pub mod protocol; +pub(crate) mod protocol; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { Protocol(protocol::Key), } @@ -39,14 +39,14 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { match self { Key::Protocol(x) => x.disable(), } } } -pub fn process(event: Event) { +pub(crate) fn process(event: Event) { match event { Event::Protocol(_) => protocol::process(), } diff --git a/crates/scheduler/src/event/platform/protocol.rs b/crates/scheduler/src/event/platform/protocol.rs index f6cc59feb..65dfa2a96 100644 --- a/crates/scheduler/src/event/platform/protocol.rs +++ b/crates/scheduler/src/event/platform/protocol.rs @@ -18,7 +18,7 @@ use wasefire_error::Error; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { Request, } @@ -37,10 +37,10 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { // We need to process non-applet requests. Ok(()) } } -pub fn process() {} +pub(crate) fn process() {} diff --git a/crates/scheduler/src/event/timer.rs b/crates/scheduler/src/event/timer.rs index e9fe1af01..982ddc415 100644 --- a/crates/scheduler/src/event/timer.rs +++ b/crates/scheduler/src/event/timer.rs @@ -19,7 +19,7 @@ use wasefire_error::Error; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive_where(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct Key { +pub(crate) struct Key { pub timer: Id>, } @@ -36,10 +36,10 @@ impl<'a, B: Board> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::timer::Api as _; board::Timer::::disarm(self.timer) } } -pub fn process() {} +pub(crate) fn process() {} diff --git a/crates/scheduler/src/event/uart.rs b/crates/scheduler/src/event/uart.rs index 99167ce3f..d4e439c81 100644 --- a/crates/scheduler/src/event/uart.rs +++ b/crates/scheduler/src/event/uart.rs @@ -19,7 +19,7 @@ use wasefire_error::Error; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive_where(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct Key { +pub(crate) struct Key { pub uart: Id>, pub direction: Direction, } @@ -37,10 +37,10 @@ impl<'a, B: Board> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::uart::Api as _; board::Uart::::disable(self.uart, self.direction) } } -pub fn process() {} +pub(crate) fn process() {} diff --git a/crates/scheduler/src/event/usb.rs b/crates/scheduler/src/event/usb.rs index 29d7d1629..64017c20a 100644 --- a/crates/scheduler/src/event/usb.rs +++ b/crates/scheduler/src/event/usb.rs @@ -17,13 +17,13 @@ use wasefire_board_api::usb::Event; use wasefire_error::Error; #[cfg(feature = "board-api-usb-ctap")] -pub mod ctap; +pub(crate) mod ctap; #[cfg(feature = "board-api-usb-serial")] -pub mod serial; +pub(crate) mod serial; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { #[cfg(feature = "board-api-usb-ctap")] Ctap(ctap::Key), @@ -49,7 +49,7 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { match self { #[cfg(feature = "board-api-usb-ctap")] Key::Ctap(x) => x.disable::(), @@ -59,7 +59,7 @@ impl Key { } } -pub fn process(event: Event) { +pub(crate) fn process(event: Event) { match event { #[cfg(feature = "board-api-usb-ctap")] Event::Ctap(_) => ctap::process(), diff --git a/crates/scheduler/src/event/usb/ctap.rs b/crates/scheduler/src/event/usb/ctap.rs index ac20abe1d..d19b88d34 100644 --- a/crates/scheduler/src/event/usb/ctap.rs +++ b/crates/scheduler/src/event/usb/ctap.rs @@ -18,7 +18,7 @@ use wasefire_error::Error; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { Read, Write, } @@ -39,7 +39,7 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::usb::ctap::Api as _; let event = match self { Key::Read => Event::Read, @@ -49,4 +49,4 @@ impl Key { } } -pub fn process() {} +pub(crate) fn process() {} diff --git a/crates/scheduler/src/event/usb/serial.rs b/crates/scheduler/src/event/usb/serial.rs index 8c5266d26..4e6adb0b5 100644 --- a/crates/scheduler/src/event/usb/serial.rs +++ b/crates/scheduler/src/event/usb/serial.rs @@ -18,7 +18,7 @@ use wasefire_error::Error; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub enum Key { +pub(crate) enum Key { Read, Write, } @@ -39,7 +39,7 @@ impl<'a> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { use wasefire_board_api::usb::serial::Api as _; let event = match self { Key::Read => Event::Read, @@ -49,4 +49,4 @@ impl Key { } } -pub fn process() {} +pub(crate) fn process() {} diff --git a/crates/scheduler/src/event/vendor.rs b/crates/scheduler/src/event/vendor.rs index be75da936..ce0419bf2 100644 --- a/crates/scheduler/src/event/vendor.rs +++ b/crates/scheduler/src/event/vendor.rs @@ -24,7 +24,7 @@ use crate::applet::store::StoreApi as _; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive_where(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct Key { +pub(crate) struct Key { pub key: board::vendor::Key, } @@ -41,12 +41,12 @@ impl<'a, B: Board> From<&'a Event> for Key { } impl Key { - pub fn disable(self) -> Result<(), Error> { + pub(crate) fn disable(self) -> Result<(), Error> { board::Vendor::::disable(self.key) } } -pub fn process(event: Event, params: &mut Vec, applet: &mut Applet) { +pub(crate) fn process(event: Event, params: &mut Vec, applet: &mut Applet) { let memory = applet.store.memory(); let handlers = applet.events.handlers(None); board::Vendor::::callback(memory, handlers, event.0, params) diff --git a/crates/scheduler/src/perf.rs b/crates/scheduler/src/perf.rs index 33678f201..d2e7e3b98 100644 --- a/crates/scheduler/src/perf.rs +++ b/crates/scheduler/src/perf.rs @@ -19,7 +19,7 @@ use wasefire_applet_api::debug as api; use wasefire_board_api::debug::Api as _; use wasefire_board_api::{self as board, Api as Board}; -pub struct Perf { +pub(crate) struct Perf { start: u64, value: api::Perf, board: PhantomData, @@ -32,7 +32,7 @@ impl Default for Perf { } impl Perf { - pub fn record(&mut self, slot: Slot) { + pub(crate) fn record(&mut self, slot: Slot) { let end = board::Debug::::time(); let start = core::mem::replace(&mut self.start, end); let value = match slot { @@ -44,13 +44,13 @@ impl Perf { if end < start { board::Debug::::MAX_TIME - start + end + 1 } else { end - start }; } - pub fn read(&mut self) -> api::Perf { + pub(crate) fn read(&mut self) -> api::Perf { self.value } } #[derive(Debug)] -pub enum Slot { +pub(crate) enum Slot { Platform, Applets, Waiting, diff --git a/crates/scheduler/src/protocol.rs b/crates/scheduler/src/protocol.rs index 4fdd12e85..236fff348 100644 --- a/crates/scheduler/src/protocol.rs +++ b/crates/scheduler/src/protocol.rs @@ -32,19 +32,19 @@ use wasefire_protocol::{self as service, Api, ApiResult, Request, Service, VERSI use crate::Scheduler; #[derive(Debug, Default)] -pub struct State(StateImpl); +pub(crate) struct State(StateImpl); -pub fn enable() { +pub(crate) fn enable() { if let Err(error) = board::platform::Protocol::::enable() { log::warn!("Failed to enable platform protocol: {}", error); } } -pub fn should_process_event(event: &board::Event) -> bool { +pub(crate) fn should_process_event(event: &board::Event) -> bool { *event == board::Event::from(board::platform::protocol::Event) } -pub fn process_event(scheduler: &mut Scheduler, event: board::Event) { +pub(crate) fn process_event(scheduler: &mut Scheduler, event: board::Event) { let request = match board::platform::Protocol::::read() { Ok(Some(x)) => x, Ok(None) => return log::warn!("Expected platform protocol request, but found none."), @@ -181,7 +181,7 @@ fn process_event_( } #[cfg(feature = "applet-api-platform-protocol")] -pub fn put_response( +pub(crate) fn put_response( call: &mut crate::SchedulerCall, response: Box<[u8]>, ) -> Result<(), Error> { match call.applet().put_response(response) { diff --git a/scripts/sync.sh b/scripts/sync.sh index 8d7b0436a..cdbdfbda4 100755 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -37,7 +37,7 @@ for dir in $(find crates examples/rust -name Cargo.toml -printf '%h\n' | sort); esac # TODO: Enable for all crates. case $crate in - runner-*|scheduler|xtask|*/fuzz) ;; + runner-*|xtask|*/fuzz) ;; examples/rust/exercises/part-*) ;; *) add_lint $file warn rust.unreachable_pub ;; esac