field_ios

In-the-field app for Radroots on iOS
git clone https://radroots.dev/git/field_ios.git
Log | Files | Refs | README | LICENSE

runtime.rs (1613B)


      1 use super::{ProtectedDataAvailability, RuntimeOpenOptions, TeraRuntime, build_runtime};
      2 use crate::backup::BackupHostAdapter;
      3 use crate::{FfiBackupManifest, FfiBackupRequest, TeraAppError, TeraBackupHost, TeraHostSigner};
      4 
      5 #[cfg_attr(not(coverage_nightly), uniffi::export(async_runtime = "tokio"))]
      6 impl TeraRuntime {
      7     /// Requires the native file owner to prepare the exact account backup root.
      8     #[cfg_attr(not(coverage_nightly), uniffi::constructor)]
      9     pub async fn with_host_signer_and_local_backups(
     10         application_support_directory: String,
     11         public_key_hex: String,
     12         source_generation_hex: String,
     13         source_generation_created_at_unix_ms: u64,
     14         protected_data: ProtectedDataAvailability,
     15         host_signer: Box<dyn TeraHostSigner>,
     16     ) -> Result<Self, TeraAppError> {
     17         build_runtime(
     18             application_support_directory,
     19             public_key_hex,
     20             source_generation_hex,
     21             source_generation_created_at_unix_ms,
     22             protected_data,
     23             Some(host_signer),
     24             RuntimeOpenOptions {
     25                 local_backups: true,
     26                 ..Default::default()
     27             },
     28         )
     29         .await
     30     }
     31 
     32     pub async fn capture_application_backup(
     33         &self,
     34         request: FfiBackupRequest,
     35         host: Box<dyn TeraBackupHost>,
     36     ) -> Result<FfiBackupManifest, TeraAppError> {
     37         let request = request.decode()?;
     38         self.inner
     39             .capture_application_backup(request, &BackupHostAdapter(host))
     40             .await?
     41             .try_into()
     42             .map_err(Into::into)
     43     }
     44 }