igd_next/
lib.rs

1#![deny(missing_docs)]
2
3//! This library allows you to communicate with an IGD enabled device.
4//! Use one of the `search_gateway` functions to obtain a `Gateway` object.
5//! You can then communicate with the device via this object.
6
7// data structures
8pub use self::common::parsing::PortMappingEntry;
9pub use self::common::SearchOptions;
10pub use self::errors::{
11    AddAnyPortError, AddPortError, GetExternalIpError, GetGenericPortMappingEntryError, RemovePortError, RequestError,
12    SearchError,
13};
14pub use self::errors::{Error, Result};
15pub use self::gateway::Gateway;
16
17// search of gateway
18pub use self::search::search_gateway;
19
20#[cfg(any(feature = "aio_tokio", feature = "aio_async_std"))]
21pub mod aio;
22mod common;
23mod errors;
24mod gateway;
25mod search;
26
27use std::fmt;
28
29/// Represents the protocols available for port mapping.
30#[derive(Debug, Clone, Copy, PartialEq, Eq)]
31pub enum PortMappingProtocol {
32    /// TCP protocol
33    TCP,
34    /// UDP protocol
35    UDP,
36}
37
38impl fmt::Display for PortMappingProtocol {
39    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
40        write!(
41            f,
42            "{}",
43            match *self {
44                PortMappingProtocol::TCP => "TCP",
45                PortMappingProtocol::UDP => "UDP",
46            }
47        )
48    }
49}