pub struct ChannelMetadata {
pub name: Option<String>,
pub about: Option<String>,
pub picture: Option<String>,
pub relays: Vec<RelayUrl>,
pub extra: IndexMap<String, Value>,
}Expand description
JSON .content body for kinds 40 and 41.
The four spec-named fields (name, about, picture,
relays) are first-class. Any other JSON property the
originating app stamps on the metadata object survives via
Self::extra.
Fields§
§name: Option<String>Channel name (kind 40 / 41 §“name”).
about: Option<String>Long-form description (kind 40 / 41 §“about”).
picture: Option<String>URL of channel picture. Spec leaves the value unconstrained
so we keep it as String; callers that need URL validation
should round-trip through crate::Url themselves.
relays: Vec<RelayUrl>Relays where the channel events are broadcast.
extra: IndexMap<String, Value>Forward-compatible passthrough of every other JSON property.
Implementations§
Source§impl ChannelMetadata
impl ChannelMetadata
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Set Self::name.
Sourcepub fn about(self, about: impl Into<String>) -> Self
pub fn about(self, about: impl Into<String>) -> Self
Set Self::about.
Sourcepub fn picture(self, picture: impl Into<String>) -> Self
pub fn picture(self, picture: impl Into<String>) -> Self
Set Self::picture.
Sourcepub fn relays<I>(self, relays: I) -> Selfwhere
I: IntoIterator<Item = RelayUrl>,
pub fn relays<I>(self, relays: I) -> Selfwhere
I: IntoIterator<Item = RelayUrl>,
Append several relay hints.
Sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Render to JSON ready for use as .content.
§Errors
Forwarded from serde_json — the only failure modes are
non-UTF-8 strings inside Self::extra, which Rust strings
cannot represent in the first place, or numeric overflow in
callers that put serde_json::Number::from_f64(f64::NAN) in
extra. Both are degenerate.
Sourcepub fn from_json(json: &str) -> Result<Self, ChannelMetadataError>
pub fn from_json(json: &str) -> Result<Self, ChannelMetadataError>
Parse a JSON .content string into the typed bundle.
§Errors
ChannelMetadataError::InvalidJsonwhen the input is not a JSON object.ChannelMetadataError::InvalidRelayUrlwhen arelays[i]string failsRelayUrl::parse.
Trait Implementations§
Source§impl Clone for ChannelMetadata
impl Clone for ChannelMetadata
Source§fn clone(&self) -> ChannelMetadata
fn clone(&self) -> ChannelMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelMetadata
impl Debug for ChannelMetadata
Source§impl Default for ChannelMetadata
impl Default for ChannelMetadata
Source§fn default() -> ChannelMetadata
fn default() -> ChannelMetadata
Source§impl<'de> Deserialize<'de> for ChannelMetadata
impl<'de> Deserialize<'de> for ChannelMetadata
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>,
impl Eq for ChannelMetadata
Source§impl PartialEq for ChannelMetadata
impl PartialEq for ChannelMetadata
Source§impl Serialize for ChannelMetadata
impl Serialize for ChannelMetadata
impl StructuralPartialEq for ChannelMetadata
Auto Trait Implementations§
impl Freeze for ChannelMetadata
impl RefUnwindSafe for ChannelMetadata
impl Send for ChannelMetadata
impl Sync for ChannelMetadata
impl Unpin for ChannelMetadata
impl UnsafeUnpin for ChannelMetadata
impl UnwindSafe for ChannelMetadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.