pub struct BoundedNote(/* private fields */);Expand description
A length-bounded note string (max 200 chars / 512 bytes).
Used for note (personal) and payer_note (payer-provided) fields on
payments. Construction validates that the string is within limits;
deserialization rejects strings that exceed either limit.
For untrusted external input that should be silently truncated rather than
rejected, use BoundedNote::truncate.
Implementations§
Source§impl BoundedNote
impl BoundedNote
Sourcepub fn new(s: String) -> Result<BoundedNote, NoteTooLong>
pub fn new(s: String) -> Result<BoundedNote, NoteTooLong>
Constructs a note, returning NoteTooLong if it’s empty or invalid.
Sourcepub fn truncate(s: String) -> Option<BoundedNote>
pub fn truncate(s: String) -> Option<BoundedNote>
Silently truncate a string to fit within note limits.
Truncates by character count first, then by byte count. Returns None
if the result is empty after truncation.
Use this for untrusted external input (e.g. inbound LNURL comments, BOLT12 payer notes) where rejecting would cause payment failures.
Sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consumes the note and returns the inner string.
Trait Implementations§
Source§impl Clone for BoundedNote
impl Clone for BoundedNote
Source§fn clone(&self) -> BoundedNote
fn clone(&self) -> BoundedNote
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoundedNote
impl Debug for BoundedNote
Source§impl<'de> Deserialize<'de> for BoundedNote
impl<'de> Deserialize<'de> for BoundedNote
Source§fn deserialize<D>(
deserializer: D,
) -> Result<BoundedNote, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<BoundedNote, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for BoundedNote
impl Display for BoundedNote
Source§impl FromStr for BoundedNote
impl FromStr for BoundedNote
Source§type Err = NoteTooLong
type Err = NoteTooLong
Source§fn from_str(s: &str) -> Result<BoundedNote, <BoundedNote as FromStr>::Err>
fn from_str(s: &str) -> Result<BoundedNote, <BoundedNote as FromStr>::Err>
s to return a value of this type. Read moreSource§impl Hash for BoundedNote
impl Hash for BoundedNote
Source§impl PartialEq for BoundedNote
impl PartialEq for BoundedNote
Source§impl Serialize for BoundedNote
impl Serialize for BoundedNote
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<String> for BoundedNote
impl TryFrom<String> for BoundedNote
Source§type Error = NoteTooLong
type Error = NoteTooLong
Source§fn try_from(
s: String,
) -> Result<BoundedNote, <BoundedNote as TryFrom<String>>::Error>
fn try_from( s: String, ) -> Result<BoundedNote, <BoundedNote as TryFrom<String>>::Error>
impl Eq for BoundedNote
impl StructuralPartialEq for BoundedNote
Auto Trait Implementations§
impl Freeze for BoundedNote
impl RefUnwindSafe for BoundedNote
impl Send for BoundedNote
impl Sync for BoundedNote
impl Unpin for BoundedNote
impl UnsafeUnpin for BoundedNote
impl UnwindSafe for BoundedNote
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.