pub struct NodeId(/* private fields */);Expand description
Byte representation of a node identifier.
This type is used when referring to nodes without doing cryptographic operations. It can be used in search algorithms, LN explorers, manager UIs etc. By avoiding cryptography it is significantly more performant but may make debugging harder. It is therefore recommended to perform checking at system boundaries where performance is not very important - e.g. user inputs.
Despite this not being a guaranteed point on the curve it still performs cheap basic sanity check: whether the key begins with 0x02 or 0x03.
§Example
let marvin_str = "029ef8ee0ba895e2807ac1df1987a7888116c468e70f42e7b089e06811b0e45482";
let marvin = marvin_str.parse::<ln_types::NodeId>().unwrap();
assert_eq!(marvin.to_string(), marvin_str);Implementations§
Source§impl NodeId
impl NodeId
Sourcepub fn from_raw_bytes(bytes: [u8; 33]) -> Result<Self, InvalidNodeId>
pub fn from_raw_bytes(bytes: [u8; 33]) -> Result<Self, InvalidNodeId>
Creates NodeId from raw byte representation.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NodeId
Available on crate feature serde only.NodeId is deserialized as hex from human-readable formats and as bytes from non-human-readable.
impl<'de> Deserialize<'de> for NodeId
serde only.NodeId is deserialized as hex from human-readable formats and as bytes from non-human-readable.
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'a> From<&'a NodePubkey> for NodeId
Available on crate feature secp256k1 only.
impl<'a> From<&'a NodePubkey> for NodeId
secp256k1 only.Source§fn from(value: &'a NodePubkey) -> Self
fn from(value: &'a NodePubkey) -> Self
Source§impl From<NodePubkey> for NodeId
Available on crate feature secp256k1 only.
impl From<NodePubkey> for NodeId
secp256k1 only.Source§fn from(value: NodePubkey) -> Self
fn from(value: NodePubkey) -> Self
Source§impl<'a> FromSql<'a> for NodeId
Available on crate feature postgres-types only.Supports BYTEA, TEXT, and VARCHAR.
impl<'a> FromSql<'a> for NodeId
postgres-types only.Supports BYTEA, TEXT, and VARCHAR.
Decoded as bytes if BYTEA is used, as hex string otherwise.
Source§fn from_sql(
ty: &Type,
raw: &'a [u8],
) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
fn from_sql( ty: &Type, raw: &'a [u8], ) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
Type in its binary format. Read moreSource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type.Source§impl Ord for NodeId
impl Ord for NodeId
Source§impl ParseArgFromStr for NodeId
Available on crate feature parse_arg only.
impl ParseArgFromStr for NodeId
parse_arg only.Source§impl PartialOrd for NodeId
impl PartialOrd for NodeId
Source§impl Serialize for NodeId
Available on crate feature serde only.NodeId is serialized as hex to human-readable formats and as bytes to non-human-readable.
impl Serialize for NodeId
serde only.NodeId is serialized as hex to human-readable formats and as bytes to non-human-readable.
Source§impl ToSql for NodeId
Available on crate feature postgres-types only.Supports BYTEA, TEXT, and VARCHAR.
impl ToSql for NodeId
postgres-types only.Supports BYTEA, TEXT, and VARCHAR.
Stored as bytes if BYTEA is used, as hex string otherwise.
Source§fn to_sql(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Send + Sync + 'static>>
fn to_sql( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Send + Sync + 'static>>
self into the binary format of the specified
Postgres Type, appending it to out. Read moreSource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type.Source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
Source§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
Source§impl TryFrom<Box<str>> for NodeId
Available on crate feature alloc only.Expects hex representation
impl TryFrom<Box<str>> for NodeId
alloc only.Expects hex representation
Source§impl TryFrom<NodeId> for NodePubkey
Available on crate feature secp256k1 only.
impl TryFrom<NodeId> for NodePubkey
secp256k1 only.Source§impl TryFrom<String> for NodeId
Available on crate feature alloc only.Expects hex representation
impl TryFrom<String> for NodeId
alloc only.Expects hex representation
Source§impl Value for NodeId
Available on crate feature slog only.Currently uses Display but may use emit_bytes if/when it’s implemented.
impl Value for NodeId
slog only.Currently uses Display but may use emit_bytes if/when it’s implemented.
impl Copy for NodeId
impl Eq for NodeId
impl StructuralPartialEq for NodeId
Auto Trait Implementations§
impl Freeze for NodeId
impl RefUnwindSafe for NodeId
impl Send for NodeId
impl Sync for NodeId
impl Unpin for NodeId
impl UnwindSafe for NodeId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
Source§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self as a ToSql trait object.