1#![cfg_attr(docsrs, feature(doc_cfg))]
4#![cfg_attr(not(any(test, doctest, feature = "std")), no_std)]
5#![warn(missing_docs)]
6
7mod tests;
8
9use core::convert::Infallible;
10
11use aranya_crypto::DeviceId;
12use aranya_policy_vm::{CommandContext, ffi::ffi};
13
14pub struct FfiDevice {
16 id: DeviceId,
17}
18
19#[ffi(module = "device")]
20impl FfiDevice {
21 #[ffi_export(def = r#"function current_device_id() id"#)]
23 pub(crate) fn current_device_id<E: aranya_crypto::Engine>(
24 &self,
25 _ctx: &CommandContext,
26 _eng: &E,
27 ) -> Result<DeviceId, Infallible> {
28 Ok(self.id)
29 }
30}
31
32impl FfiDevice {
33 pub const fn new(id: DeviceId) -> Self {
35 Self { id }
36 }
37}