Enum lnpbp_chain::P2pNetworkId
source · #[non_exhaustive]
#[repr(u32)]
pub enum P2pNetworkId {
Mainnet,
Testnet,
Regtest,
Signet,
Other(P2pMagicNumber),
}
Expand description
P2P network magic number: prefix identifying network on which node operates. This enum defines known magic network numbers, plus adds support to arbitrary unknown with P2pNetworkId::Other variant. This enum differs from bitcoin::Network in its ability to support non-standard and non-predefined networks
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Mainnet
Bitcoin magic number for mainnet P2P communications
Testnet
Bitcoin magic number for testnet P2P communications
Regtest
Bitcoin magic number for regtest P2P communications
Signet
Bitcoin magic number for signet P2P communications
Other(P2pMagicNumber)
Other magic number, implying some unknown network
Implementations§
source§impl P2pNetworkId
impl P2pNetworkId
sourcepub fn from_magic(magic: P2pMagicNumber) -> Self
pub fn from_magic(magic: P2pMagicNumber) -> Self
Constructs P2pNetworkId
from a given network magic number defined
by P2pMagicNumber
sourcepub fn as_magic(&self) -> P2pMagicNumber
pub fn as_magic(&self) -> P2pMagicNumber
Returns representation in form of network magic number
P2pMagicNumber
Trait Implementations§
source§impl Clone for P2pNetworkId
impl Clone for P2pNetworkId
source§fn clone(&self) -> P2pNetworkId
fn clone(&self) -> P2pNetworkId
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for P2pNetworkId
impl Debug for P2pNetworkId
source§impl Display for P2pNetworkId
impl Display for P2pNetworkId
source§impl From<Network> for P2pNetworkId
impl From<Network> for P2pNetworkId
source§impl From<P2pNetworkId> for P2pMagicNumber
impl From<P2pNetworkId> for P2pMagicNumber
source§fn from(network: P2pNetworkId) -> Self
fn from(network: P2pNetworkId) -> Self
Converts to this type from the input type.
source§impl From<u32> for P2pNetworkId
impl From<u32> for P2pNetworkId
source§fn from(magic: P2pMagicNumber) -> Self
fn from(magic: P2pMagicNumber) -> Self
Converts to this type from the input type.
source§impl Hash for P2pNetworkId
impl Hash for P2pNetworkId
source§impl Ord for P2pNetworkId
impl Ord for P2pNetworkId
source§fn cmp(&self, other: &P2pNetworkId) -> Ordering
fn cmp(&self, other: &P2pNetworkId) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<P2pNetworkId> for P2pNetworkId
impl PartialEq<P2pNetworkId> for P2pNetworkId
source§fn eq(&self, other: &P2pNetworkId) -> bool
fn eq(&self, other: &P2pNetworkId) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<P2pNetworkId> for P2pNetworkId
impl PartialOrd<P2pNetworkId> for P2pNetworkId
source§fn partial_cmp(&self, other: &P2pNetworkId) -> Option<Ordering>
fn partial_cmp(&self, other: &P2pNetworkId) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl StrictDecode for P2pNetworkId
impl StrictDecode for P2pNetworkId
source§fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
Decode with the given
std::io::Read
instance; must either
construct an instance or return implementation-specific error type.source§fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
Tries to deserialize byte array into the current type using
StrictDecode::strict_decode
. If there are some data remains in the
buffer once deserialization is completed, fails with
Error::DataNotEntirelyConsumed
. Use io::Cursor
over the buffer and
StrictDecode::strict_decode
to avoid such failures.source§fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
Reads data from file at
path
and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed
if file contains remaining
data after the object reconstruction.source§impl StrictEncode for P2pNetworkId
impl StrictEncode for P2pNetworkId
source§fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
Encode with the given
std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.source§fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
Serializes data as a byte array using
StrictEncode::strict_encode
functionsource§impl TryFrom<P2pNetworkId> for Network
impl TryFrom<P2pNetworkId> for Network
§type Error = ConversionImpossibleError
type Error = ConversionImpossibleError
The type returned in the event of a conversion error.