Struct UpdateName
pub struct UpdateName(pub u64, _);
Expand description
A struct representing a name for a channel monitor update.
UpdateName
is primarily used within the MonitorUpdatingPersister
in
functions that store or retrieve partial updates to channel monitors. It
provides a consistent way to generate and parse unique identifiers for
monitor updates based on their sequence number.
The name is derived from the update’s sequence ID, which is a monotonically increasing u64 value. This format allows for easy ordering of updates and efficient storage and retrieval in key-value stores.
§Usage
While users of the Lightning Dev Kit library generally won’t need to
interact with UpdateName
directly, it still can be useful for custom
persistence implementations. The u64 value is the update_id that can be
compared with ChannelMonitor::get_latest_update_id to check if this update
has been applied to the channel monitor or not, which is useful for pruning
stale channel monitor updates off persistence.
§Examples
use lightning::util::persist::UpdateName;
let update_id: u64 = 42;
let update_name = UpdateName::from(update_id);
assert_eq!(update_name.as_str(), "42");
// Using UpdateName to generate a storage key
let monitor_name = "some_monitor_name";
let storage_key = format!("channel_monitor_updates/{}/{}", monitor_name, update_name.as_str());
Tuple Fields§
§0: u64
Implementations§
§impl UpdateName
impl UpdateName
pub fn new(name: String) -> Result<UpdateName, Error>
pub fn new(name: String) -> Result<UpdateName, Error>
Constructs an UpdateName
, after verifying that an update sequence ID
can be derived from the given name
.
pub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Convert this update name to a string slice.
This method is particularly useful when you need to use the update name as part of a key in a key-value store or when logging.
§Examples
use lightning::util::persist::UpdateName;
let update_name = UpdateName::from(42);
assert_eq!(update_name.as_str(), "42");
Trait Implementations§
§impl Debug for UpdateName
impl Debug for UpdateName
§impl From<u64> for UpdateName
impl From<u64> for UpdateName
§fn from(value: u64) -> UpdateName
fn from(value: u64) -> UpdateName
Creates an UpdateName
from a u64
.
This is typically used when you need to generate a storage key or identifier for a new channel monitor update.
§Examples
use lightning::util::persist::UpdateName;
let update_id: u64 = 42;
let update_name = UpdateName::from(update_id);
assert_eq!(update_name.as_str(), "42");
Auto Trait Implementations§
impl Freeze for UpdateName
impl Send for UpdateName
impl Sync for UpdateName
impl RefUnwindSafe for UpdateName
impl Unpin for UpdateName
impl UnwindSafe for UpdateName
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request