pub struct UnsignedEvent { /* private fields */ }Expand description
An event that has not been signed yet: kind, tags, content and creation time.
Sign it with NostrSecretKey::sign_event.
§Examples
use stratum_node_core::{NostrSecretKey, UnixTime, UnsignedEvent};
let key = NostrSecretKey::from_hex(&"01".repeat(32))?;
let unsigned = UnsignedEvent::new(30078, UnixTime::from_secs(1_700_000_000))
.with_tag(["d", "stratum/backup"])
.with_content("{}");
let event = key.sign_event(&unsigned, &[0u8; 32])?;
assert_eq!(event.author(), key.public());
assert_eq!(event.kind(), 30078);Implementations§
Source§impl UnsignedEvent
impl UnsignedEvent
Sourcepub fn new(kind: u16, created_at: UnixTime) -> Self
pub fn new(kind: u16, created_at: UnixTime) -> Self
Starts an event of kind created at created_at, with no tags and
empty content.
Sourcepub fn with_tag<I, S>(self, tag: I) -> Self
pub fn with_tag<I, S>(self, tag: I) -> Self
Appends one tag, given as its elements in order.
NIP-01 requires every tag to have at least one element. An empty tag
is kept here, but NostrSecretKey::sign_event refuses to sign the
event with SignError::EmptyTag.
Sourcepub fn with_content(self, content: impl Into<String>) -> Self
pub fn with_content(self, content: impl Into<String>) -> Self
Replaces the content.
Sourcepub fn created_at(&self) -> UnixTime
pub fn created_at(&self) -> UnixTime
Returns the creation time.
Returns the tags in order.
Trait Implementations§
Source§impl Clone for UnsignedEvent
impl Clone for UnsignedEvent
Source§impl Debug for UnsignedEvent
impl Debug for UnsignedEvent
impl Eq for UnsignedEvent
Source§impl PartialEq for UnsignedEvent
impl PartialEq for UnsignedEvent
impl StructuralPartialEq for UnsignedEvent
Auto Trait Implementations§
impl Forget for UnsignedEvent
impl Freeze for UnsignedEvent
impl Move for UnsignedEvent
impl RefUnwindSafe for UnsignedEvent
impl Send for UnsignedEventwhere
RawVecInner: Send,
impl Sync for UnsignedEventwhere
RawVecInner: Sync,
impl Unpin for UnsignedEvent
impl UnsafeUnpin for UnsignedEventwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Vec<String>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for UnsignedEventwhere
RawVecInner: UnwindSafe,
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
Mutably borrows from an owned value. Read more