This commit is contained in:
nab138
2026-02-09 09:33:48 -05:00
parent 3f256be371
commit 1983e9dab7
4 changed files with 23 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ impl Display for TeamSelection {
} }
} }
/// Behavior when the maximum number of development certificates is reached
pub enum MaxCertsBehavior { pub enum MaxCertsBehavior {
/// If the maximum number of certificates is reached, revoke certs until it is possible to create a new certificate /// If the maximum number of certificates is reached, revoke certs until it is possible to create a new certificate
Revoke, Revoke,
@@ -59,26 +60,41 @@ impl SideloaderBuilder {
} }
} }
/// Set the team selection behavior
///
/// See [`TeamSelection`] for details.
pub fn team_selection(mut self, selection: TeamSelection) -> Self { pub fn team_selection(mut self, selection: TeamSelection) -> Self {
self.team_selection = Some(selection); self.team_selection = Some(selection);
self self
} }
/// Set the storage backend for sideloading data
///
/// An implementation using `keyring` is provided in the `keyring-storage` feature.
/// See [`SideloadingStorage`] for details.
///
/// If not set, either keyring storage or in memory storage (not persisted across runs) will be used depending on if the `keyring-storage` feature is enabled.
pub fn storage(mut self, storage: Box<dyn SideloadingStorage>) -> Self { pub fn storage(mut self, storage: Box<dyn SideloadingStorage>) -> Self {
self.storage = Some(storage); self.storage = Some(storage);
self self
} }
/// Set the machine name to use for the development certificate
///
/// This has no bearing on functionality but can be useful for users to identify where a certificate came from.
/// If not set, a default name of "isideload" will be used.
pub fn machine_name(mut self, machine_name: String) -> Self { pub fn machine_name(mut self, machine_name: String) -> Self {
self.machine_name = Some(machine_name); self.machine_name = Some(machine_name);
self self
} }
/// Set the behavior for when the maximum number of development certificates is reached
pub fn max_certs_behavior(mut self, behavior: MaxCertsBehavior) -> Self { pub fn max_certs_behavior(mut self, behavior: MaxCertsBehavior) -> Self {
self.max_certs_behavior = Some(behavior); self.max_certs_behavior = Some(behavior);
self self
} }
/// Build the `Sideloader` instance with the provided configuration
pub fn build(self) -> Sideloader { pub fn build(self) -> Sideloader {
Sideloader::new( Sideloader::new(
self.developer_session, self.developer_session,

View File

@@ -1,4 +1,4 @@
pub mod builder; pub mod builder;
pub mod certificate; pub mod cert_identity;
pub mod sideloader; pub mod sideloader;
pub use builder::{SideloaderBuilder, TeamSelection}; pub use builder::{SideloaderBuilder, TeamSelection};

View File

@@ -4,7 +4,7 @@ use crate::{
devices::DevicesApi, devices::DevicesApi,
teams::{DeveloperTeam, TeamsApi}, teams::{DeveloperTeam, TeamsApi},
}, },
sideload::{TeamSelection, builder::MaxCertsBehavior, certificate::CertificateIdentity}, sideload::{TeamSelection, builder::MaxCertsBehavior, cert_identity::CertificateIdentity},
util::{device::IdeviceInfo, storage::SideloadingStorage}, util::{device::IdeviceInfo, storage::SideloadingStorage},
}; };
@@ -24,6 +24,9 @@ pub struct Sideloader {
} }
impl Sideloader { impl Sideloader {
/// Construct a new `Sideloader` instance with the provided configuration
///
/// See [`crate::sideload::SideloaderBuilder`] for more details and a more convenient way to construct a `Sideloader`.
pub fn new( pub fn new(
dev_session: DeveloperSession, dev_session: DeveloperSession,
apple_email: String, apple_email: String,
@@ -42,6 +45,7 @@ impl Sideloader {
} }
} }
/// Sign and install an app
pub async fn install_app( pub async fn install_app(
&mut self, &mut self,
device_provider: &impl IdeviceProvider, device_provider: &impl IdeviceProvider,
@@ -73,6 +77,7 @@ impl Sideloader {
Ok(()) Ok(())
} }
/// Get the developer team according to the configured team selection behavior
pub async fn get_team(&mut self) -> Result<DeveloperTeam, Report> { pub async fn get_team(&mut self) -> Result<DeveloperTeam, Report> {
let teams = self.dev_session.list_teams().await?; let teams = self.dev_session.list_teams().await?;
Ok(match teams.len() { Ok(match teams.len() {