1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// LNP/BP Core Library implementing LNPBP specifications & standards
// Written in 2019 by
//     Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//
// You should have received a copy of the MIT License
// along with this software.
// If not, see <https://opensource.org/licenses/MIT>.

#![recursion_limit = "256"]
// Coding conventions
#![deny(
    warnings,
    //dead_code,
    //missing_docs
)]
#![allow(unused_variables, dead_code)]
#![allow(clippy::needless_borrow)] // Caused by a bug in amplify_derive::Display
                                   // TODO: when we will be ready for the release #![deny(missing_docs, dead_code)]

#[macro_use]
extern crate amplify;
#[macro_use]
extern crate strict_encoding;

extern crate chacha20poly1305;
#[cfg(feature = "url")]
extern crate url_crate as url;

#[cfg(feature = "serde")]
extern crate serde_crate as serde;

#[cfg(feature = "derive")]
pub extern crate inet2_derive as derive;

pub extern crate inet2_addr as addr;

#[cfg(feature = "derive")]
pub use inet2_derive::Api;

pub mod presentation;
pub mod session;
pub mod transport;

pub use presentation::{
    sphinx, tlv, CreateUnmarshaller, Payload, TypeId, TypedEnum,
    UnknownTypeError, Unmarshall, UnmarshallFn, Unmarshaller,
};
pub use session::{
    noise, Decrypt, Encrypt, NoiseDecryptor, NoiseEncryptor, NoiseTranscoder,
    PlainTranscoder, SendRecvMessage, Session, Split, Transcode,
};
#[cfg(feature = "zmq")]
pub use transport::zeromq;
pub use transport::{DuplexConnection, RoutedFrame};
#[cfg(feature = "zmq")]
pub use transport::{ZmqConnectionType, ZmqSocketType};

/// Maximum message (packet payload) length for Brontide protocol
pub const BRONTIDE_MSG_MAX_LEN: usize = u16::MAX as usize;
/// Maximum message (packet payload) length for Brontozaur protocol
pub const BRONTOZAUR_MSG_MAX_LEN: usize = 0xFFFFFF;

/// Trait used by different address types (transport-, session- and
/// presentation-based) for getting scheme part of the URL
pub trait UrlString {
    /// Returns full URL scheme string (i.e. including `:` or `://` parts)
    /// corresponding to the provided address
    fn url_scheme(&self) -> &'static str;

    /// Returns URL string representation for a given node or socket address. If
    /// you need full URL address, please use `Url::from()` instead (this
    /// will require `url` feature for LNP/BP Core Library).
    fn to_url_string(&self) -> String;
}