use crate::{Idevice, IdeviceError, IdeviceService, ReadWrite, obf};
use super::{RemotePairingClient, RpPairingSocket};
#[derive(Debug)]
pub struct RemotePairingLockdownService {
pub idevice: Idevice,
}
impl IdeviceService for RemotePairingLockdownService {
fn service_name() -> std::borrow::Cow<'static, str> {
obf!("com.apple.dt.remotepairingdeviced.lockdown")
}
async fn from_stream(idevice: Idevice) -> Result<Self, IdeviceError> {
Ok(Self { idevice })
}
}
impl RemotePairingLockdownService {
pub fn new(idevice: Idevice) -> Self {
Self { idevice }
}
pub fn into_client(
self,
sending_host: &str,
) -> Result<RemotePairingClient<RpPairingSocket<Box<dyn ReadWrite>>>, IdeviceError> {
let socket = self
.idevice
.get_socket()
.ok_or(IdeviceError::NoEstablishedConnection)?;
Ok(RemotePairingClient::new(
RpPairingSocket::new(socket),
sending_host,
))
}
}