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
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
sourceimpl 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
sourceimpl Clone for P2pNetworkId
impl Clone for P2pNetworkId
sourcefn clone(&self) -> P2pNetworkId
fn clone(&self) -> P2pNetworkId
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 P2pNetworkId
impl Debug for P2pNetworkId
sourceimpl Display for P2pNetworkId
impl Display for P2pNetworkId
sourceimpl From<Network> for P2pNetworkId
impl From<Network> for P2pNetworkId
sourceimpl From<P2pNetworkId> for P2pMagicNumber
impl From<P2pNetworkId> for P2pMagicNumber
sourcefn from(network: P2pNetworkId) -> Self
fn from(network: P2pNetworkId) -> Self
Converts to this type from the input type.
sourceimpl From<u32> for P2pNetworkId
impl From<u32> for P2pNetworkId
sourcefn from(magic: P2pMagicNumber) -> Self
fn from(magic: P2pMagicNumber) -> Self
Converts to this type from the input type.
sourceimpl Hash for P2pNetworkId
impl Hash for P2pNetworkId
sourceimpl Ord for P2pNetworkId
impl Ord for P2pNetworkId
sourceimpl PartialEq<P2pNetworkId> for P2pNetworkId
impl PartialEq<P2pNetworkId> for P2pNetworkId
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &P2pNetworkId) -> bool
fn ne(&self, other: &P2pNetworkId) -> bool
This method tests for !=
.
sourceimpl PartialOrd<P2pNetworkId> for P2pNetworkId
impl PartialOrd<P2pNetworkId> for P2pNetworkId
sourcefn partial_cmp(&self, other: &P2pNetworkId) -> Option<Ordering>
fn partial_cmp(&self, other: &P2pNetworkId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
sourceimpl StrictDecode for P2pNetworkId
impl StrictDecode for P2pNetworkId
sourcefn 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. Read more
sourcefn 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. Read more
sourcefn 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. Read more
sourceimpl StrictEncode for P2pNetworkId
impl StrictEncode for P2pNetworkId
sourcefn 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. Read more
sourcefn 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
function Read more
sourceimpl 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.
sourcefn try_from(bn: P2pNetworkId) -> Result<Self, Self::Error>
fn try_from(bn: P2pNetworkId) -> Result<Self, Self::Error>
Performs the conversion.
impl Copy for P2pNetworkId
impl Eq for P2pNetworkId
impl StructuralEq for P2pNetworkId
impl StructuralPartialEq for P2pNetworkId
Auto Trait Implementations
impl RefUnwindSafe for P2pNetworkId
impl Send for P2pNetworkId
impl Sync for P2pNetworkId
impl Unpin for P2pNetworkId
impl UnwindSafe for P2pNetworkId
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