Skip to content

Commit 4fbfc9b

Browse files
committed
nostr: add RelayMetadata::as_str method
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 648eb5c commit 4fbfc9b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
* nostr: impl `FromIterator<Tag>` for `Tags` ([Yuki Kishimoto])
9898
* nostr: add `EventDeletionRequest` struct ([Yuki Kishimoto])
9999
* nostr: add `notifications` field to NIP47 `GetInfoResponse` ([Yuki Kishimoto])
100+
* nostr: add `RelayMetadata::as_str` method ([Yuki Kishimoto])
100101
* database: add `Events::force_insert` ([Yuki Kishimoto])
101102
* pool: event verification cache ([Yuki Kishimoto])
102103
* pool: add `AdmitPolicy` trait ([Yuki Kishimoto])

crates/nostr/src/nips/nip65.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,22 @@ pub enum RelayMetadata {
3838
Write,
3939
}
4040

41-
impl fmt::Display for RelayMetadata {
42-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41+
impl RelayMetadata {
42+
/// Get as `&str`.
43+
pub fn as_str(&self) -> &str {
4344
match self {
44-
Self::Read => write!(f, "read"),
45-
Self::Write => write!(f, "write"),
45+
Self::Read => "read",
46+
Self::Write => "write",
4647
}
4748
}
4849
}
4950

51+
impl fmt::Display for RelayMetadata {
52+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53+
write!(f, "{}", self.as_str())
54+
}
55+
}
56+
5057
impl FromStr for RelayMetadata {
5158
type Err = Error;
5259

0 commit comments

Comments
 (0)