refactor(sdk): gate the app API under app_runtime
What changed, and why it matters
This commit is a straightforward internal code reorganization. It moves several app-facing Rust modules (error handling, crypto, UI, logging, wire protocol, etc.) under a single `app_runtime` module and re-exports them at the crate root. There is no functional change intended and no security fix or vulnerability introduced.
No security action required. Treat as a normal maintainability refactor; review for build/test breakage only.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors the trezor-app-sdk crate structure. Previously, modules such as error, crypto, ui, log, print, util, wire, and codec were conditionally compiled at the crate root under #[cfg(feature = "app")]. The patch moves these modules into app_runtime and re-exports them from lib.rs via pub use app_runtime::{...}. Doc comments and internal path references (e.g., crate::codec → crate::app_runtime::codec) are updated accordingly. The app feature gate remains the sole access control mechanism.
Changed components
sdk/crates/trezor-app-sdk/src/lib.rssdk/crates/trezor-app-sdk/src/app_runtime/mod.rssdk/crates/trezor-app-sdk/src/app_runtime/wire.rsInspect captured patch +32 / −36
### sdk/crates/trezor-app-sdk/src/app_runtime/codec.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/crypto.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/error.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/log.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/mod.rs
@@ -11,6 +11,19 @@ use crate::traits::wire::StaticWireV1;
/// The global allocator, backed by the heap Core gives the app.
pub mod allocator;
+// the app-facing API, re-exported at the crate root
+pub(crate) mod codec;
+pub mod crypto;
+/// The SDK's [`Error`](error::Error) type and helpers to add context to results.
+pub mod error;
+pub mod log;
+#[doc(hidden)]
+pub mod print;
+pub mod ui;
+/// Small helpers, such as [`util::Timeout`].
+pub mod util;
+pub(crate) mod wire;
+
static API: spin::Once<&'static TrezorApiV1Struct> = spin::Once::new();
const API_VERSION: u32 = 1;
### sdk/crates/trezor-app-sdk/src/app_runtime/print.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/ui.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/ui/constructors.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/util.rs
[binary or diff unavailable]
### sdk/crates/trezor-app-sdk/src/app_runtime/wire.rs
@@ -1,5 +1,5 @@
//! Talking to the host through Core: receive, send, call and error. The
-//! message encoding on top lives in [`crate::codec`].
+//! message encoding on top lives in [`crate::app_runtime::codec`].
use crate::app_runtime::get_wire_or_die;
use crate::traits::wire::{FailureKind, WireV1Dyn as _};
### sdk/crates/trezor-app-sdk/src/lib.rs
@@ -14,8 +14,9 @@
//! disable on stable toolchains to fall back to stable-compatible
//! implementations.
//!
-//! Without `app`, only `structs` (shared API types) are available — suitable
-//! for the core app which only needs to work with the API structs.
+//! Without `app`, only `structs` and `traits` (shared API types) are available —
+//! suitable for the core app which only needs to work with the API types. The
+//! app-facing API lives in [`app_runtime`] and is re-exported at the crate root.
#![cfg_attr(not(feature = "test"), no_std)]
#![allow(internal_features)]
@@ -31,56 +32,38 @@
extern crate alloc;
-#[cfg(feature = "app")]
-/// The SDK's [`Error`] type and helpers to add context to results.
-pub mod error;
// Always available: shared API structs used by both core app and extapps
pub mod structs;
-#[cfg(feature = "app")]
-/// The app runtime: the entry point, access to Core's API and the heap allocator.
-pub mod app_runtime;
-
/// The stable-ABI traits and types shared with Core.
pub mod traits;
#[cfg(feature = "app")]
-pub mod crypto;
-
-#[cfg(feature = "app")]
-pub mod ui;
-
-#[cfg(feature = "app")]
-pub mod log;
-
-#[doc(hidden)]
-#[cfg(feature = "app")]
-pub mod print;
-
-#[cfg(feature = "app")]
-/// Small helpers, such as [`util::Timeout`].
-pub mod util;
-
-#[cfg(feature = "app")]
-mod wire;
-
-#[cfg(feature = "app")]
-mod codec;
+/// The app runtime: the entry point, access to Core's API and the heap
+/// allocator, and the app-facing API re-exported below.
+pub mod app_runtime;
#[cfg(feature = "test")]
pub mod mock;
+// crate-internal path of the private wire module
#[cfg(feature = "app")]
-pub use app_runtime::app;
+use app_runtime::wire;
#[cfg(feature = "app")]
-pub use codec::{WireDecode, WireEncode, WireRequest, wire_request};
+#[doc(hidden)]
+pub use app_runtime::print;
#[cfg(feature = "app")]
-pub use error::{Error, IntoAppResult, Result, ResultExt, ServiceResultExt};
+pub use app_runtime::{
+ app,
+ codec::{WireDecode, WireEncode, WireRequest, wire_request},
+ crypto,
+ error::{self, Error, IntoAppResult, Result, ResultExt, ServiceResultExt},
+ log, ui, util,
+ wire::{wire_call, wire_error, wire_receive, wire_send},
+};
#[cfg(feature = "app")]
pub use traits::wire::FailureKind;
// for the log macros, see `log!`
#[cfg(feature = "app")]
#[doc(hidden)]
pub use ufmt as __ufmt;
-#[cfg(feature = "app")]
-pub use wire::{wire_call, wire_error, wire_receive, wire_send};Why this scored 13/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.