use crate::{Idevice, IdeviceError, IdeviceService, obf};
#[derive(Debug)]
pub struct SyslogRelayClient {
pub idevice: Idevice,
}
impl IdeviceService for SyslogRelayClient {
fn service_name() -> std::borrow::Cow<'static, str> {
obf!("com.apple.syslog_relay")
}
async fn from_stream(idevice: Idevice) -> Result<Self, crate::IdeviceError> {
Ok(Self::new(idevice))
}
}
impl SyslogRelayClient {
pub fn new(idevice: Idevice) -> Self {
Self { idevice }
}
pub async fn next(&mut self) -> Result<String, IdeviceError> {
let res = self.idevice.read_until_delim(b"\n\x00").await?;
match res {
Some(res) => Ok(String::from_utf8_lossy(&res).to_string()),
None => Err(IdeviceError::UnexpectedResponse(
"syslog relay returned EOF".into(),
)),
}
}
}
#[cfg(feature = "rsd")]
impl crate::RsdService for SyslogRelayClient {
fn rsd_service_name() -> std::borrow::Cow<'static, str> {
crate::obf!("com.apple.syslog_relay.shim.remote")
}
async fn from_stream(stream: Box<dyn crate::ReadWrite>) -> Result<Self, crate::IdeviceError> {
let mut idevice = crate::Idevice::new(stream, "");
idevice.rsd_checkin().await?;
Ok(Self::new(idevice))
}
}