pub struct IpConnectionRequestSender { /* private fields */ }
Expand description

The IP connection request sender is a cloneable object created by a IP connection. The sender can send requests to connected devices and can be shared across threads by cloning.

Implementations§

source§

impl IpConnectionRequestSender

source

pub fn connect<T: ToSocketAddrs>( &self, addr: T ) -> Receiver<Result<(), ConnectError>>

Creates a TCP/IP connection to the given addr. addr can be any object which implements ToSocketAddrs, for example a tuple of a hostname and a port. The address can refer to a Brick Daemon or to a WIFI/Ethernet Extension.

Devices can only be controlled when the connection was established successfully.

Returns a receiver, which will receive either () or an ConnectError if there is no Brick Daemon or WIFI/Ethernet Extension listening at the given host and port.

source

pub fn disconnect(&self) -> Receiver<Result<(), DisconnectErrorNotConnected>>

Disconnects the TCP/IP connection from the Brick Daemon or the WIFI/Ethernet Extension.

source

pub fn get_connect_callback_receiver(&self) -> Receiver<ConnectReason>

This event is triggered whenever the IP Connection got connected to a Brick Daemon or to a WIFI/Ethernet Extension.

source

pub fn get_disconnect_callback_receiver(&self) -> Receiver<DisconnectReason>

This event is triggered whenever the IP Connection got disconnected from a Brick Daemon or to a WIFI/Ethernet Extension.

source

pub fn get_timeout(&self) -> Duration

Returns the timeout as set by set_timeout

source

pub fn set_timeout(&mut self, timeout: Duration)

Sets the timeout for getters and for setters for which the response expected flag is activated.

Default timeout is 2,5s.

source

pub fn get_connection_state(&self) -> ConnectionState

Queries the current connection state.

source

pub fn get_auto_reconnect(&self) -> bool

Returns true if auto-reconnect is enabled, false otherwise.

source

pub fn set_auto_reconnect(&mut self, auto_reconnect_enabled: bool)

Enables or disables auto-reconnect. If auto-reconnect is enabled, the IP Connection will try to reconnect to the previously given host and port, if the currently existing connection is lost. Therefore, auto-reconnect only does something after a successful connect call.

Default value is true.

source

pub fn enumerate(&self)

Broadcasts an enumerate request. All devices will respond with an enumerate event.

source

pub fn get_enumerate_callback_receiver( &self ) -> ConvertingCallbackReceiver<EnumerateResponse>

This receiver receives enumerate events, as described here.

source

pub fn authenticate( &self, secret: &str ) -> Result<ConvertingReceiver<()>, AuthenticateError>

Performs an authentication handshake with the connected Brick Daemon or WIFI/Ethernet Extension. If the handshake succeeds the connection switches from non-authenticated to authenticated state and communication can continue as normal. If the handshake fails then the connection gets closed. Authentication can fail if the wrong secret was used or if authentication is not enabled at all on the Brick Daemon or the WIFI/Ethernet Extension.

See the authentication tutorial for more information.

New in version 2.1.0.

Trait Implementations§

source§

impl Clone for IpConnectionRequestSender

source§

fn clone(&self) -> IpConnectionRequestSender

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for IpConnectionRequestSender

source§

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

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

impl GetRequestSender for &IpConnectionRequestSender

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V