pub struct Gateway {
pub addr: SocketAddrV4,
pub control_url: String,
}
Expand description
This structure represents a gateway found by the search functions.
Fields
addr: SocketAddrV4
Socket address of the gateway
control_url: String
Control url of the device
Implementations
sourceimpl Gateway
impl Gateway
sourcepub fn get_external_ip(&self) -> Result<Ipv4Addr, GetExternalIpError>
pub fn get_external_ip(&self) -> Result<Ipv4Addr, GetExternalIpError>
Get the external IP address of the gateway.
sourcepub fn get_any_address(
&self,
protocol: PortMappingProtocol,
local_addr: SocketAddrV4,
lease_duration: u32,
description: &str
) -> Result<SocketAddrV4, AddAnyPortError>
pub fn get_any_address(
&self,
protocol: PortMappingProtocol,
local_addr: SocketAddrV4,
lease_duration: u32,
description: &str
) -> Result<SocketAddrV4, AddAnyPortError>
Get an external socket address with our external ip and any port. This is a convenience
function that calls get_external_ip
followed by add_any_port
The local_addr is the address where the traffic is sent to. The lease_duration parameter is in seconds. A value of 0 is infinite.
Returns
The external address that was mapped on success. Otherwise an error.
sourcepub fn add_any_port(
&self,
protocol: PortMappingProtocol,
local_addr: SocketAddrV4,
lease_duration: u32,
description: &str
) -> Result<u16, AddAnyPortError>
pub fn add_any_port(
&self,
protocol: PortMappingProtocol,
local_addr: SocketAddrV4,
lease_duration: u32,
description: &str
) -> Result<u16, AddAnyPortError>
Add a port mapping.with any external port.
The local_addr is the address where the traffic is sent to. The lease_duration parameter is in seconds. A value of 0 is infinite.
Returns
The external port that was mapped on success. Otherwise an error.
sourcepub fn add_port(
&self,
protocol: PortMappingProtocol,
external_port: u16,
local_addr: SocketAddrV4,
lease_duration: u32,
description: &str
) -> Result<(), AddPortError>
pub fn add_port(
&self,
protocol: PortMappingProtocol,
external_port: u16,
local_addr: SocketAddrV4,
lease_duration: u32,
description: &str
) -> Result<(), AddPortError>
Add a port mapping.
The local_addr is the address where the traffic is sent to. The lease_duration parameter is in seconds. A value of 0 is infinite.
sourcepub fn remove_port(
&self,
protocol: PortMappingProtocol,
external_port: u16
) -> Result<(), RemovePortError>
pub fn remove_port(
&self,
protocol: PortMappingProtocol,
external_port: u16
) -> Result<(), RemovePortError>
Remove a port mapping.
Trait Implementations
impl Eq for Gateway
impl StructuralEq for Gateway
impl StructuralPartialEq for Gateway
Auto Trait Implementations
impl RefUnwindSafe for Gateway
impl Send for Gateway
impl Sync for Gateway
impl Unpin for Gateway
impl UnwindSafe for Gateway
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more