Skip to content

Commit 0688603

Browse files
committed
nostr: impl From<&Event> for Nip19Event
Closes nostr:nevent1qvzqqqqx25pzpepndn2jthmelfxn4umylktqp493ph8yy9d2fse76al2ppprgjcsqqsrfryl8ar2s6x0cr0jwc03cakazcxmq9m74ts6dn0lqxpac3xf8fqwtrrrf Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 91c8f0a commit 0688603

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

crates/nostr/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
- Add NIP-C7 support (https://github.com/rust-nostr/nostr/pull/1067)
4545
- Add NIP-60 support (https://github.com/rust-nostr/nostr/pull/1092)
4646
- Implement `ToBech32` trait for `Nip21`
47+
- Implement `From<&Event>` for `Nip19Event`
4748
- Add `CowTag::kind` and `CowTag::content`
4849
- Add `Timestamp::as_secs`
4950
- Add `Kind::CashuNutZapInfo` (10019) and `Kind::CashuNutZap` (9321) variants
@@ -74,6 +75,7 @@
7475
### Deprecated
7576

7677
- Deprecate `Timestamp::as_u64`
78+
- Deprecate `Nip19Event::from_event`
7779
- Deprecate `kind` field in `CommentTarget::Coordinate` variant (https://github.com/rust-nostr/nostr/pull/1035)
7880

7981
### Breaking changes

crates/nostr/src/nips/nip19.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ impl Nip19Event {
397397
}
398398

399399
/// Construct new NIP19 event from [`Event`].
400+
#[deprecated(since = "0.44.0", note = "Use `from` instead.")]
400401
pub fn from_event(event: &Event) -> Self {
401-
Self::new(event.id).author(event.pubkey).kind(event.kind)
402+
Self::from(event)
402403
}
403404

404405
/// Add author
@@ -481,6 +482,12 @@ impl Nip19Event {
481482
}
482483
}
483484

485+
impl From<&Event> for Nip19Event {
486+
fn from(event: &Event) -> Self {
487+
Self::new(event.id).author(event.pubkey).kind(event.kind)
488+
}
489+
}
490+
484491
impl FromBech32 for Nip19Event {
485492
type Err = Error;
486493

0 commit comments

Comments
 (0)