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