pub struct Tag { /* private fields */ }
Expand description
Tag
Implementations§
Source§impl Tag
impl Tag
Sourcepub fn from_standardized(standardized: TagStandard) -> Self
pub fn from_standardized(standardized: TagStandard) -> Self
Construct from standardized tag
Sourcepub fn from_standardized_without_cell(standardized: TagStandard) -> Self
pub fn from_standardized_without_cell(standardized: TagStandard) -> Self
Construct from standardized tag without initialize cell (avoid a clone)
Sourcepub fn single_letter_tag(&self) -> Option<SingleLetterTag>
pub fn single_letter_tag(&self) -> Option<SingleLetterTag>
Get SingleLetterTag
Sourcepub fn as_standardized(&self) -> Option<&TagStandard>
pub fn as_standardized(&self) -> Option<&TagStandard>
Get reference of standardized tag
Sourcepub fn to_standardized(self) -> Option<TagStandard>
pub fn to_standardized(self) -> Option<TagStandard>
Consume tag and get standardized tag
Sourcepub fn push<S>(&mut self, value: S)
pub fn push<S>(&mut self, value: S)
Appends a value to the back of the Tag
.
Check Vec::push
doc to learn more.
This erases the TagStandard
cell, if any.
Sourcepub fn pop(&mut self) -> Option<String>
pub fn pop(&mut self) -> Option<String>
Removes the last value and returns it.
If the Tag
has only one value, returns None
, since it can’t be empty.
Check Vec::pop
doc to learn more.
This erases the TagStandard
cell, if any.
Sourcepub fn insert<S>(&mut self, index: usize, value: S) -> bool
pub fn insert<S>(&mut self, index: usize, value: S) -> bool
Inserts a value at position index
within the vector,
shifting all other values after it to the right.
The value at index 0
and 1
can’t be empty.
If an empty string is passed for those indexes, false
is returned.
Returns true
if the value has been inserted or updated successfully.
Returns false
if index > len
.
Check Vec::insert
doc to learn more.
This erases the TagStandard
cell, if any.
Sourcepub fn extend<I, S>(&mut self, iter: I)
pub fn extend<I, S>(&mut self, iter: I)
Extends the collection.
Check Vec::extend
doc to learn more.
This erases the TagStandard
cell, if any.
Sourcepub fn public_key(public_key: PublicKey) -> Self
pub fn public_key(public_key: PublicKey) -> Self
Compose ["p", "<public-key>"]
tag
Sourcepub fn identifier<T>(identifier: T) -> Self
pub fn identifier<T>(identifier: T) -> Self
Compose ["d", "<identifier>"]
tag
Sourcepub fn coordinate(coordinate: Coordinate, relay_url: Option<RelayUrl>) -> Self
pub fn coordinate(coordinate: Coordinate, relay_url: Option<RelayUrl>) -> Self
Compose ["a", "<coordinate>", "<optional-relay-url>"]
tag
Sourcepub fn pow(nonce: u128, difficulty: u8) -> Self
pub fn pow(nonce: u128, difficulty: u8) -> Self
Compose ["nonce", "<nonce>", "<difficulty>"]
tag
Sourcepub fn expiration(timestamp: Timestamp) -> Self
pub fn expiration(timestamp: Timestamp) -> Self
Compose ["expiration", "<timestamp>"]
tag
Sourcepub fn event_report(event_id: EventId, report: Report) -> Self
pub fn event_report(event_id: EventId, report: Report) -> Self
Compose ["e", "<event-id>", "<report>"]
tag
Sourcepub fn public_key_report(public_key: PublicKey, report: Report) -> Self
pub fn public_key_report(public_key: PublicKey, report: Report) -> Self
Compose ["p", "<public-key>", "<report>"]
tag
Sourcepub fn relay_metadata(
relay_url: RelayUrl,
metadata: Option<RelayMetadata>,
) -> Self
pub fn relay_metadata( relay_url: RelayUrl, metadata: Option<RelayMetadata>, ) -> Self
Compose ["r", "<relay-url>", "<metadata>"]
tag
Sourcepub fn relays<I>(urls: I) -> Selfwhere
I: IntoIterator<Item = RelayUrl>,
pub fn relays<I>(urls: I) -> Selfwhere
I: IntoIterator<Item = RelayUrl>,
Relay URLs
JSON: ["relays", "<relay-url>", "<relay-url>"]
Sourcepub fn all_relays() -> Self
pub fn all_relays() -> Self
Sourcepub fn hashtag<T>(hashtag: T) -> Self
pub fn hashtag<T>(hashtag: T) -> Self
Compose ["t", "<hashtag>"]
tag
This will convert the hashtag to lowercase.
Sourcepub fn image(url: Url, dimensions: Option<ImageDimensions>) -> Self
pub fn image(url: Url, dimensions: Option<ImageDimensions>) -> Self
Compose image tag
Sourcepub fn description<T>(description: T) -> Self
pub fn description<T>(description: T) -> Self
Compose ["description", "<description>"]
tag
Sourcepub fn alt<T>(summary: T) -> Self
pub fn alt<T>(summary: T) -> Self
A short human-readable plaintext summary of what that event is about
JSON: ["alt", "<summary>"]
Sourcepub fn custom<I, S>(kind: TagKind<'_>, values: I) -> Self
pub fn custom<I, S>(kind: TagKind<'_>, values: I) -> Self
Compose custom tag
JSON: ["<kind>", "<value-1>", "<value-2>", ...]
Sourcepub fn is_protected(&self) -> bool
pub fn is_protected(&self) -> bool
Check if it’s a protected event tag
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tag
impl<'de> Deserialize<'de> for Tag
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 From<Coordinate> for Tag
impl From<Coordinate> for Tag
Source§fn from(coordinate: Coordinate) -> Self
fn from(coordinate: Coordinate) -> Self
Source§impl From<TagStandard> for Tag
impl From<TagStandard> for Tag
Source§fn from(standard: TagStandard) -> Self
fn from(standard: TagStandard) -> Self
Source§impl FromIterator<Tag> for Tags
impl FromIterator<Tag> for Tags
Source§impl IntoIterator for Tag
impl IntoIterator for Tag
Source§impl Ord for Tag
impl Ord for Tag
Source§impl PartialOrd for Tag
impl PartialOrd for Tag
impl Eq for Tag
Auto Trait Implementations§
impl !Freeze for Tag
impl RefUnwindSafe for Tag
impl Send for Tag
impl Sync for Tag
impl Unpin for Tag
impl UnwindSafe for Tag
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<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> 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 more