mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Add connect_tcp for std feature
This commit is contained in:
@@ -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 = []
|
||||
|
||||
14
src/lib.rs
14
src/lib.rs
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user