Add connect_tcp for std feature

This commit is contained in:
Jackson Coxson
2025-01-10 15:35:54 -07:00
parent 629dd2b538
commit e6459ac652
2 changed files with 17 additions and 0 deletions

View File

@@ -37,3 +37,6 @@ openssl = { version = "0.10" }
# Binary dependencies
sha2 = { version = "0.10", optional = true }
ureq = { version = "2.12", optional = true }
[features]
std-tcp = []

View File

@@ -26,6 +26,20 @@ impl Idevice {
label: label.into(),
}
}
#[cfg(feature = "std-tcp")]
pub fn connect_tcp(
addr: std::net::SocketAddr,
label: impl Into<String>,
) -> Result<Self, std::io::Error> {
let socket = std::net::TcpStream::connect(addr)?;
let label = label.into();
Ok(Self {
socket: Some(Box::new(socket)),
label,
})
}
pub fn get_type(&mut self) -> Result<String, IdeviceError> {
let mut req = plist::Dictionary::new();
req.insert("Label".into(), self.label.clone().into());