Struct Uhppoted

Source
pub struct Uhppoted { /* private fields */ }

Implementations§

Source§

impl Uhppoted

Source

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,
)
Source

pub fn get_device_configs(&self) -> Result<Vec<DeviceConfig>>

Get all the available DeviceConfigs on the local network. This broadcasts a discovery message and waits Uhppoted::timeout for responses.

Source

pub fn get_devices(&self) -> Result<Vec<Device<'_>>>

Get all the available Devices on the local network. This broadcasts a discovery message and waits Uhppoted::timeout for responses.

Source

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.

Source

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§

Source§

impl Debug for Uhppoted

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Uhppoted

Source§

fn default() -> Uhppoted

Creates a default instance of Uhppoted. Defaults:

  • bind: 0.0.0.0:0
  • broadcast: 255.255.255.255
  • listen: None
  • timeout: Duration::new(5, 0)
  • controllers: None

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.