pub struct Gateway {
pub addr: SocketAddr,
pub root_url: String,
pub control_url: String,
pub control_schema_url: String,
pub control_schema: HashMap<String, Vec<String>>,
}
Expand description
This structure represents a gateway found by the search functions.
Fields§
§addr: SocketAddr
Socket address of the gateway
root_url: String
Root url of the device
control_url: String
Control url of the device
control_schema_url: String
Url to get schema data from
control_schema: HashMap<String, Vec<String>>
Control schema for all actions
Implementations§
source§impl Gateway
impl Gateway
sourcepub fn get_external_ip(&self) -> Result<IpAddr, GetExternalIpError>
pub fn get_external_ip(&self) -> Result<IpAddr, GetExternalIpError>
Get the external IP address of the gateway.
sourcepub fn get_any_address(
&self,
protocol: PortMappingProtocol,
local_addr: SocketAddr,
lease_duration: u32,
description: &str
) -> Result<SocketAddr, AddAnyPortError>
pub fn get_any_address( &self, protocol: PortMappingProtocol, local_addr: SocketAddr, lease_duration: u32, description: &str ) -> Result<SocketAddr, 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: SocketAddr,
lease_duration: u32,
description: &str
) -> Result<u16, AddAnyPortError>
pub fn add_any_port( &self, protocol: PortMappingProtocol, local_addr: SocketAddr, 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: SocketAddr,
lease_duration: u32,
description: &str
) -> Result<(), AddPortError>
pub fn add_port( &self, protocol: PortMappingProtocol, external_port: u16, local_addr: SocketAddr, 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.
sourcepub fn get_generic_port_mapping_entry(
&self,
index: u32
) -> Result<PortMappingEntry, GetGenericPortMappingEntryError>
pub fn get_generic_port_mapping_entry( &self, index: u32 ) -> Result<PortMappingEntry, GetGenericPortMappingEntryError>
Get one port mapping entry
Gets one port mapping entry by its index. Not all existing port mappings might be visible to this client. If the index is out of bound, GetGenericPortMappingEntryError::SpecifiedArrayIndexInvalid will be returned