Skip to content

Commit c80baa0

Browse files
committed
fixup! feat(truapi-server): add Rust host runtime
1 parent 80892b2 commit c80baa0

12 files changed

Lines changed: 263 additions & 334 deletions

File tree

rust/crates/truapi-server/src/host_logic/features.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use truapi::v01::{GenericError, HostFeatureSupportedRequest, HostFeatureSupporte
88
use truapi_platform::Features;
99

1010
/// Forward a feature-support query to the platform implementation.
11-
pub async fn feature_supported<P: Features>(
11+
pub async fn feature_supported<P: Features + ?Sized>(
1212
platform: &P,
1313
request: HostFeatureSupportedRequest,
1414
) -> Result<HostFeatureSupportedResponse, GenericError> {
@@ -21,6 +21,7 @@ mod tests {
2121

2222
struct AlwaysSupported;
2323

24+
#[truapi_platform::async_trait]
2425
impl Features for AlwaysSupported {
2526
async fn feature_supported(
2627
&self,
@@ -33,6 +34,7 @@ mod tests {
3334

3435
struct AlwaysUnsupported;
3536

37+
#[truapi_platform::async_trait]
3638
impl Features for AlwaysUnsupported {
3739
async fn feature_supported(
3840
&self,

rust/crates/truapi-server/src/host_logic/permissions.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ impl From<bool> for StoredAuthorizationStatus {
5151

5252
/// Coordinator that inspects persisted state first, falls back to the
5353
/// platform's prompt callback, and writes the authorization back so future
54-
/// calls short-circuit. Generic over the concrete `CoreStorage` + `Permissions` impls
55-
/// so callers (e.g. `PlatformRuntimeHost<P>`) can stay non-`dyn`.
56-
pub struct PermissionsService<'a, S: CoreStorage, P: Permissions> {
54+
/// calls short-circuit.
55+
pub struct PermissionsService<'a, S: CoreStorage + ?Sized, P: Permissions + ?Sized> {
5756
storage: &'a S,
5857
prompt: &'a P,
5958
product_id: &'a str,
6059
}
6160

62-
impl<'a, S: CoreStorage, P: Permissions> PermissionsService<'a, S, P> {
61+
impl<'a, S: CoreStorage + ?Sized, P: Permissions + ?Sized> PermissionsService<'a, S, P> {
6362
/// Construct a service backed by the given storage + prompt callbacks.
6463
pub fn new(storage: &'a S, prompt: &'a P, product_id: &'a str) -> Self {
6564
Self {
@@ -194,7 +193,7 @@ impl<'a, S: CoreStorage, P: Permissions> PermissionsService<'a, S, P> {
194193
}
195194
}
196195

197-
async fn authorization_status<S: CoreStorage>(
196+
async fn authorization_status<S: CoreStorage + ?Sized>(
198197
storage: &S,
199198
key: CoreStorageKey,
200199
) -> Result<PermissionAuthorizationStatus, GenericError> {
@@ -204,7 +203,7 @@ async fn authorization_status<S: CoreStorage>(
204203
.unwrap_or(PermissionAuthorizationStatus::NotDetermined))
205204
}
206205

207-
async fn peek_stored<S: CoreStorage>(
206+
async fn peek_stored<S: CoreStorage + ?Sized>(
208207
storage: &S,
209208
key: CoreStorageKey,
210209
) -> Result<Option<StoredAuthorizationStatus>, GenericError> {
@@ -214,7 +213,7 @@ async fn peek_stored<S: CoreStorage>(
214213
Ok(StoredAuthorizationStatus::decode(&mut &*raw).ok())
215214
}
216215

217-
async fn set_authorization_status<S: CoreStorage>(
216+
async fn set_authorization_status<S: CoreStorage + ?Sized>(
218217
storage: &S,
219218
key: CoreStorageKey,
220219
status: PermissionAuthorizationStatus,
@@ -281,6 +280,7 @@ mod tests {
281280
inner: Mutex<HashMap<String, Vec<u8>>>,
282281
}
283282

283+
#[truapi_platform::async_trait]
284284
impl CoreStorage for MemStorage {
285285
async fn read_core_storage(
286286
&self,
@@ -324,6 +324,7 @@ mod tests {
324324
}
325325
}
326326

327+
#[truapi_platform::async_trait]
327328
impl Permissions for ScriptedPrompt {
328329
async fn device_permission(
329330
&self,
@@ -588,6 +589,7 @@ mod tests {
588589
/// path (fail closed for the current call, but do not persist the error).
589590
struct FailingPrompt;
590591

592+
#[truapi_platform::async_trait]
591593
impl Permissions for FailingPrompt {
592594
async fn device_permission(
593595
&self,
@@ -663,6 +665,7 @@ mod tests {
663665
#[derive(Default)]
664666
struct FailingStorage;
665667

668+
#[truapi_platform::async_trait]
666669
impl CoreStorage for FailingStorage {
667670
async fn read_core_storage(
668671
&self,

0 commit comments

Comments
 (0)