Struct uhppote_rs::Uhppoted
source · [−]pub struct Uhppoted { /* private fields */ }
Implementations
sourceimpl Uhppoted
impl Uhppoted
sourcepub fn new(bind: SocketAddr, broadcast: Ipv4Addr, timeout: Duration) -> Uhppoted
pub fn new(bind: SocketAddr, broadcast: Ipv4Addr, timeout: Duration) -> Uhppoted
Create a new Uhppote struct
Example:
use uhppote_rs::Uhppoted;
let uhppoted = UUhppoted::new(
"0.0.0.0:0".parse().unwrap(),
"255.255.255.255".parse().unwrap(),
Duration::new(5, 0),
Vec::new(),
false,
)
sourcepub fn get_device_configs(&self) -> Result<Vec<DeviceConfig>>
pub fn get_device_configs(&self) -> Result<Vec<DeviceConfig>>
Get all the available DeviceConfig
s on the local network. This broadcasts a discovery message
and waits Uhppoted::timeout
for responses.
sourcepub fn get_devices(&self) -> Result<Vec<Device<'_>>>
pub fn get_devices(&self) -> Result<Vec<Device<'_>>>
Get all the available Device
s on the local network. This broadcasts a discovery message
and waits Uhppoted::timeout
for responses.
sourcepub fn get_device(&self, id: u32, ip_address: Option<Ipv4Addr>) -> Device<'_>
pub fn get_device(&self, id: u32, ip_address: Option<Ipv4Addr>) -> Device<'_>
Get a Device
by its device ID. This does not check if the device actually exists, but
merely represents a device to interact with.
When ip_address
is specified, communication will happen directly with the device. Otherwise,
communication to the device will happen via local network broadcast.
Specify an ip_address
when the device is not on the local network.
sourcepub fn listen(&self, address: SocketAddr, handler: fn(_: Status)) -> Result<()>
pub fn listen(&self, address: SocketAddr, handler: fn(_: Status)) -> Result<()>
Listen for incoming Status
messages from the UHPPOTE system on a specific address
.
Example:
use uhppote_rs::Uhppoted;
let uhppoted = Uhppoted::default();
let device = uhppoted.get_device(423196779);
let listener_address: SocketAddr = "192.168.0.10:12345".parse().unwrap();
device.set_listener(listener_address).unwrap();
uhppoted.listen(listener_address, |status| {
println!("{:?}", status);
});
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Uhppoted
impl Send for Uhppoted
impl Sync for Uhppoted
impl Unpin for Uhppoted
impl UnwindSafe for Uhppoted
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more