igd/
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
7extern crate attohttpc;
8#[macro_use]
9extern crate log;
10#[cfg(feature = "aio")]
11extern crate bytes;
12
13extern crate rand;
14extern crate url;
15extern crate xmltree;
16
17#[cfg(feature = "aio")]
18extern crate futures;
19#[cfg(feature = "aio")]
20extern crate http;
21#[cfg(feature = "aio")]
22extern crate hyper;
23#[cfg(feature = "aio")]
24extern crate tokio;
25
26// data structures
27pub use self::common::parsing::PortMappingEntry;
28pub use self::common::SearchOptions;
29pub use self::errors::{
30    AddAnyPortError, AddPortError, GetExternalIpError, GetGenericPortMappingEntryError, RemovePortError, RequestError,
31    SearchError,
32};
33pub use self::errors::{Error, Result};
34pub use self::gateway::Gateway;
35
36// search of gateway
37pub use self::search::search_gateway;
38
39#[cfg(feature = "aio")]
40pub mod aio;
41mod common;
42mod errors;
43mod gateway;
44mod search;
45
46use std::fmt;
47
48/// Represents the protocols available for port mapping.
49#[derive(Debug, Clone, Copy, PartialEq)]
50pub enum PortMappingProtocol {
51    /// TCP protocol
52    TCP,
53    /// UDP protocol
54    UDP,
55}
56
57impl fmt::Display for PortMappingProtocol {
58    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
59        write!(
60            f,
61            "{}",
62            match *self {
63                PortMappingProtocol::TCP => "TCP",
64                PortMappingProtocol::UDP => "UDP",
65            }
66        )
67    }
68}