#[non_exhaustive]
pub enum PartialNodeAddr {
Native(PublicKey, InetAddr, Option<u16>),
Udp(PublicKey, IpAddr, Option<u16>),
Posix(String),
ZmqIpc(String, ZmqType),
ZmqInproc(String, ZmqType),
ZmqTcpEncrypted(PublicKey, ZmqType, IpAddr, Option<u16>),
ZmqTcpUnencrypted(ZmqType, IpAddr, Option<u16>),
Http(PublicKey, InetAddr, Option<u16>),
Text(PublicKey),
}
Expand description
Universal Node Locator for LNP protocol (from LNPBP-19)
Type is used for visual node and specific protocol representation or parsing
It is different from NodeAddr
by the fact that it may
not contain port information for LNP-based protocols having known default
port, while NodeAddr
must always contain complete information with the
explicit porn number. To convert PartialNodeAddr
to NodeAddr
use
ToNodeAddr
trait.
NB: DNS addressing is not used since it is considered insecure in terms of censorship resistance.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Native(PublicKey, InetAddr, Option<u16>)
Native Lightning network connection: uses end-to-end encryption and runs on top of either TCP socket (which may be backed by Tor connection)
URL Scheme
lnp://
Udp(PublicKey, IpAddr, Option<u16>)
NB: Unfinished!
UDP-based connection that uses UDP packets instead of TCP. Can’t work with Tor, but may use UDP hole punching in a secure way, since the connection is still required to be encrypted.
URL Scheme
lnpu://
Posix(String)
ZmqIpc(String, ZmqType)
Local (for inter-process communication based on POSIX sockets) connection without encryption. Relies on ZMQ IPC sockets internally; specific socket pair for ZMQ is provided via query parameter
URL Schema
lnpz:
ZmqInproc(String, ZmqType)
LNP protocol supports in-process communications (between threads of the same process using Mutex’es and other sync managing routines) without encryption. It relies on ZMQ IPC sockets internally. However, such connection can be done only withing the same process, and can’t be represented in the form of URL: it requires presence of ZMQ context object, which can’t be encoded as a string (context object is taken from a global variable).
ZmqTcpEncrypted(PublicKey, ZmqType, IpAddr, Option<u16>)
SHOULD be used only for DMZ area connections; otherwise
PartialNodeAddr::Native
or [PartialNodeAddr::Websocket
]
connection MUST be used
URL Scheme
lnpz://
ZmqTcpUnencrypted(ZmqType, IpAddr, Option<u16>)
SHOULD be used only for DMZ area connections; otherwise
PartialNodeAddr::Native
or [PartialNodeAddr::Websocket
]
connection MUST be used
URL Schema
lnpz://
Http(PublicKey, InetAddr, Option<u16>)
URL Scheme
lnph://
Text(PublicKey)
Text (Bech32-based) connection for high latency or non-interactive protocols. Can work with SMPT, for mesh and satellite networks – or with other mediums of communications (chat messages, QR codes etc).
URL Scheme
lnpt://
Implementations
sourceimpl PartialNodeAddr
impl PartialNodeAddr
sourcepub fn with_default_port(self, port: u16) -> Self
pub fn with_default_port(self, port: u16) -> Self
Adds port information to the node locator, if it can contain port and
has no port information. In case if it does not, performs no action.
Returns cloned Self
with the updated data.
sourcepub fn components(
&self
) -> (Option<PublicKey>, Option<InetAddr>, Option<u16>, Option<String>, Option<ZmqType>)
pub fn components(
&self
) -> (Option<PublicKey>, Option<InetAddr>, Option<u16>, Option<String>, Option<ZmqType>)
Parses PartialNodeAddr
into it’s optional components, returned as a
single tuple of optionals:
sourcepub fn node_id(&self) -> Option<PublicKey>
pub fn node_id(&self) -> Option<PublicKey>
Returns node id for the given locator, if any, or Option::None
otherwise
sourcepub fn inet_addr(&self) -> Option<InetAddr>
pub fn inet_addr(&self) -> Option<InetAddr>
Returns InetAddr
for the given locator, if any, or Option::None
otherwise
sourcepub fn port(&self) -> Option<u16>
pub fn port(&self) -> Option<u16>
Returns port number for the given locator, if any, or Option::None
otherwise
sourcepub fn socket_name(&self) -> Option<String>
pub fn socket_name(&self) -> Option<String>
Returns socket name if for the given locator, if any, or
Option::None
otherwise
Trait Implementations
sourceimpl Clone for PartialNodeAddr
impl Clone for PartialNodeAddr
sourcefn clone(&self) -> PartialNodeAddr
fn clone(&self) -> PartialNodeAddr
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PartialNodeAddr
impl Debug for PartialNodeAddr
sourceimpl Display for PartialNodeAddr
impl Display for PartialNodeAddr
sourceimpl From<&'_ PartialNodeAddr> for Url
impl From<&'_ PartialNodeAddr> for Url
sourcefn from(addr: &PartialNodeAddr) -> Self
fn from(addr: &PartialNodeAddr) -> Self
Converts to this type from the input type.
sourceimpl From<PartialNodeAddr> for Url
impl From<PartialNodeAddr> for Url
sourcefn from(addr: PartialNodeAddr) -> Self
fn from(addr: PartialNodeAddr) -> Self
Converts to this type from the input type.
sourceimpl From<PartialNodeAddr> for NodeAddr
impl From<PartialNodeAddr> for NodeAddr
sourcefn from(locator: PartialNodeAddr) -> Self
fn from(locator: PartialNodeAddr) -> Self
Converts to this type from the input type.
sourceimpl From<RemoteNodeAddr> for PartialNodeAddr
impl From<RemoteNodeAddr> for PartialNodeAddr
sourcefn from(node_addr: RemoteNodeAddr) -> PartialNodeAddr
fn from(node_addr: RemoteNodeAddr) -> PartialNodeAddr
Converts to this type from the input type.
sourceimpl FromStr for PartialNodeAddr
impl FromStr for PartialNodeAddr
sourceimpl Hash for PartialNodeAddr
impl Hash for PartialNodeAddr
sourceimpl PartialEq<PartialNodeAddr> for PartialNodeAddr
impl PartialEq<PartialNodeAddr> for PartialNodeAddr
sourcefn eq(&self, other: &PartialNodeAddr) -> bool
fn eq(&self, other: &PartialNodeAddr) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &PartialNodeAddr) -> bool
fn ne(&self, other: &PartialNodeAddr) -> bool
This method tests for !=
.
sourceimpl ToNodeAddr for PartialNodeAddr
impl ToNodeAddr for PartialNodeAddr
sourcefn to_node_addr(&self, default_port: u16) -> Option<NodeAddr>
fn to_node_addr(&self, default_port: u16) -> Option<NodeAddr>
Constructs NodeAddr
from an internal data with a default port
put in place when the port details were not given is such structures
as PartialNodeAddr
Read more
sourceimpl ToRemoteNodeAddr for PartialNodeAddr
impl ToRemoteNodeAddr for PartialNodeAddr
sourcefn to_remote_node_addr(&self, default_port: u16) -> Option<RemoteNodeAddr>
fn to_remote_node_addr(&self, default_port: u16) -> Option<RemoteNodeAddr>
Constructs RemoteNodeAddr
from an internal data with a default port
put in place when the port details were not given is such structures
as PartialNodeAddr
Read more
sourceimpl TryFrom<PartialNodeAddr> for LocalSocketAddr
impl TryFrom<PartialNodeAddr> for LocalSocketAddr
sourceimpl TryFrom<PartialNodeAddr> for RemoteNodeAddr
impl TryFrom<PartialNodeAddr> for RemoteNodeAddr
sourceimpl TryFrom<PartialNodeAddr> for ZmqSocketAddr
impl TryFrom<PartialNodeAddr> for ZmqSocketAddr
sourceimpl TryFrom<Url> for PartialNodeAddr
impl TryFrom<Url> for PartialNodeAddr
sourceimpl UrlString for PartialNodeAddr
impl UrlString for PartialNodeAddr
sourcefn url_scheme(&self) -> &'static str
fn url_scheme(&self) -> &'static str
Returns full URL scheme string (i.e. including :
or ://
parts)
corresponding to the provided address Read more
sourcefn to_url_string(&self) -> String
fn to_url_string(&self) -> String
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). Read more
impl Eq for PartialNodeAddr
impl StructuralEq for PartialNodeAddr
impl StructuralPartialEq for PartialNodeAddr
Auto Trait Implementations
impl RefUnwindSafe for PartialNodeAddr
impl Send for PartialNodeAddr
impl Sync for PartialNodeAddr
impl Unpin for PartialNodeAddr
impl UnwindSafe for PartialNodeAddr
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
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.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more