Skip to content

Commit 184e686

Browse files
committed
nostr: rename nip22::Comment to nip22::CommentTarget
Closes #880 Pull-Request: #882 Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
1 parent 8fcecbb commit 184e686

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
### Changed
3838

3939
- Bump `lru` from 0.13.0 to 0.14.0 ([Yuki Kishimoto])
40+
- nostr: rename `nip22::Comment` to `nip22::CommentTarget` ([Yuki Kishimoto] at https://github.com/rust-nostr/nostr/pull/882)
4041

4142
### Added
4243

crates/nostr/src/nips/nip22.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ use crate::nips::nip01::Coordinate;
1010
use crate::nips::nip73::ExternalContentId;
1111
use crate::{Alphabet, Event, EventId, Kind, PublicKey, RelayUrl, TagKind, TagStandard, Url};
1212

13-
/// Borrowed comment extracted data
14-
pub enum Comment<'a> {
13+
#[allow(missing_docs)]
14+
#[deprecated(since = "0.42.0", note = "Use `CommentTarget` instead")]
15+
pub type Comment<'a> = CommentTarget<'a>;
16+
17+
/// Comment target
18+
pub enum CommentTarget<'a> {
1519
/// Event
1620
Event {
1721
/// Event ID
@@ -41,24 +45,24 @@ pub enum Comment<'a> {
4145
},
4246
}
4347

44-
/// Extract NIP22 root data
45-
pub fn extract_root(event: &Event) -> Option<Comment> {
48+
/// Extract NIP22 root target
49+
pub fn extract_root(event: &Event) -> Option<CommentTarget> {
4650
extract_data(event, true)
4751
}
4852

49-
/// Extract NIP22 parent data
50-
pub fn extract_parent(event: &Event) -> Option<Comment> {
53+
/// Extract NIP22 parent target
54+
pub fn extract_parent(event: &Event) -> Option<CommentTarget> {
5155
extract_data(event, false)
5256
}
5357

54-
fn extract_data(event: &Event, is_root: bool) -> Option<Comment> {
58+
fn extract_data(event: &Event, is_root: bool) -> Option<CommentTarget> {
5559
if event.kind != Kind::Comment {
5660
return None;
5761
}
5862

5963
// Try to extract event
6064
if let Some((event_id, relay_hint, public_key)) = extract_event(event, is_root) {
61-
return Some(Comment::Event {
65+
return Some(CommentTarget::Event {
6266
id: event_id,
6367
relay_hint,
6468
pubkey_hint: public_key,
@@ -68,15 +72,15 @@ fn extract_data(event: &Event, is_root: bool) -> Option<Comment> {
6872

6973
// Try to extract coordinate
7074
if let Some((address, relay_hint)) = extract_coordinate(event, is_root) {
71-
return Some(Comment::Coordinate {
75+
return Some(CommentTarget::Coordinate {
7276
address,
7377
relay_hint,
7478
kind: extract_kind(event, is_root),
7579
});
7680
}
7781

7882
if let Some((content, hint)) = extract_external(event, is_root) {
79-
return Some(Comment::External { content, hint });
83+
return Some(CommentTarget::External { content, hint });
8084
}
8185

8286
None

0 commit comments

Comments
 (0)