#[non_exhaustive]pub struct EventBuilder { /* private fields */ }Expand description
Fluent builder for UnsignedEvent / Event.
The four constituents — kind, content, tags, created_at — are
private by design: callers must go through the builder methods to
mutate them. The reason is twofold:
- NIP-46 / NIP-59 (gift wrap) compose builders that produce
encrypted
contentderived from a particular(kind, tags)snapshot. Letting outer code reach in and rewrite, say,kindafter the inner ciphertext was sealed would silently corrupt the event without the type system noticing. - Keeping the surface fluent (
builder.kind(K).tag(t).content(c)) means downstream code never has to know whether a field isStringvsCow<'_, str>vs&str— we can change the storage type freely without breaking callers.
The struct is #[non_exhaustive] so future versions may add
configuration fields (PoW search budget, dedup toggles, mining-aux
nonce cache, …) without breaking downstream pattern matches.
Implementations§
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn new<S>(kind: Kind, content: S) -> Self
pub fn new<S>(kind: Kind, content: S) -> Self
Construct a builder with the given kind and content.
Sourcepub fn text_note<S>(content: S) -> Self
pub fn text_note<S>(content: S) -> Self
Build a Kind::TEXT_NOTE event (NIP-01) with the supplied content.
Sourcepub const fn current_kind(&self) -> Kind
pub const fn current_kind(&self) -> Kind
Read-only accessor for the event kind.
Sourcepub fn current_content(&self) -> &str
pub fn current_content(&self) -> &str
Read-only accessor for the event content.
Read-only accessor for the event tags.
Sourcepub const fn current_created_at(&self) -> Option<Timestamp>
pub const fn current_created_at(&self) -> Option<Timestamp>
Read-only accessor for the explicitly pinned created_at.
None means “use the wall clock at sign time”.
Mutable accessor for the in-progress tag list.
Use this when a tag insertion needs custom logic (deduplication,
uniqueness, replace-or-push) that the fluent Self::tag /
Self::tags helpers do not cover. The fluent methods remain the
preferred surface for plain appends.
Sourcepub const fn kind(self, kind: Kind) -> Self
pub const fn kind(self, kind: Kind) -> Self
Set the event kind (overrides any previously set value).
Append several tags from any iterator.
Sourcepub const fn created_at(self, ts: Timestamp) -> Self
pub const fn created_at(self, ts: Timestamp) -> Self
Pin a custom created_at.
Useful when re-signing historical events or backfilling fixtures.
Sourcepub fn build_unsigned(
self,
pubkey: PublicKey,
) -> Result<UnsignedEvent, EventBuilderError>
pub fn build_unsigned( self, pubkey: PublicKey, ) -> Result<UnsignedEvent, EventBuilderError>
Build the UnsignedEvent but do not sign it.
pubkey becomes the pubkey field. The created_at field is taken
from the builder if set, otherwise from the system clock.
§Errors
Returns EventBuilderError::Clock if the wall clock could not be
read.
Sourcepub fn sign_with_keys(self, keys: &Keys) -> Result<Event, EventBuilderError>
pub fn sign_with_keys(self, keys: &Keys) -> Result<Event, EventBuilderError>
Build and sign with keys in one shot.
§Errors
Returns EventBuilderError::Clock if the wall clock could not be
read or EventBuilderError::Signer if signing fails (it cannot, in
the local-keys case).
Source§impl EventBuilder
impl EventBuilder
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn contact_list(list: &ContactList) -> Self
pub fn contact_list(list: &ContactList) -> Self
Build a kind: 3 contact list event from list.
The event’s content is empty per the modern interpretation of
NIP-02 (the legacy relay JSON is replaced by NIP-65).
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn deletion(request: &DeletionRequest) -> Self
pub fn deletion(request: &DeletionRequest) -> Self
Build a kind: 5 deletion event from the given DeletionRequest.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn note_with_context<S: Into<String>>(
content: S,
context: &ThreadContext,
) -> Self
pub fn note_with_context<S: Into<String>>( content: S, context: &ThreadContext, ) -> Self
Build a kind: 1 text note carrying the supplied ThreadContext
(i.e. a NIP-10 reply or mention).
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn repost(target: &Event, relay: &RelayUrl) -> Result<Self, RepostError>
pub fn repost(target: &Event, relay: &RelayUrl) -> Result<Self, RepostError>
Build a NIP-18 repost (Kind::REPOST) for a kind: 1 note.
The repost’s content is the canonical JSON of the reposted
note (or empty when target carries the NIP-70 ["-"]
protected marker). The mandatory e tag includes the relay
URL at index 2 — NIP-18 elevates the relay hint from “SHOULD”
to “MUST” specifically for reposts.
§Errors
RepostError::NotATextNotewhentarget.kind != Kind::TEXT_NOTE.RepostError::Serializeifserde_jsoncannot serialisetarget(in practice impossible because every signedEventround-trips throughserde_jsonalready).
Sourcepub fn generic_repost(
target: &Event,
relay: &RelayUrl,
) -> Result<Self, RepostError>
pub fn generic_repost( target: &Event, relay: &RelayUrl, ) -> Result<Self, RepostError>
Build a NIP-18 generic repost (Kind::GENERIC_REPOST) for a
non-kind: 1 event.
Carries a k tag with the original kind. For replaceable /
addressable events, an a tag is added with the
(kind, author, d-tag) coordinate and the content is left
empty per spec; for regular events the full JSON is stuffed
into content so the original is recoverable even if the
referenced relays drop it.
§Errors
Returns RepostError::Serialize if serde_json cannot
serialise target.
Source§impl EventBuilder
impl EventBuilder
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn long_form_article(article: Article) -> Self
pub fn long_form_article(article: Article) -> Self
Author a published NIP-23 kind: 30023 article.
Sourcepub fn long_form_draft(article: Article) -> Self
pub fn long_form_draft(article: Article) -> Self
Author a NIP-23 kind: 30024 draft.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn reaction(target: &ReactionTarget, reaction: &Reaction) -> Self
pub fn reaction(target: &ReactionTarget, reaction: &Reaction) -> Self
Build a Kind::REACTION event for target carrying
reaction as its content.
The builder pre-populates every NIP-25 SHOULD / MUST tag:
["e", <event_id>, <relay>?, <author>]— pubkey hint at the end matches the spec’s example (tags.append(["e", liked.id, hint, liked.pubkey])).["p", <author>, <relay>?].["k", <kind>]whentarget.kindis set.["a", <coordinate>, <relay>?]whentarget.coordinateis set.
Callers are free to add an ["emoji", <shortcode>, <url>]
tag for Reaction::CustomEmoji payloads, but this method
does not synthesise one because the URL is policy-dependent
and lives in higher-level NIP-30 code.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn channel_create(metadata: &ChannelMetadata) -> Result<Self, Error>
pub fn channel_create(metadata: &ChannelMetadata) -> Result<Self, Error>
Sourcepub fn channel_metadata_update(
metadata: &ChannelMetadata,
channel: EventId,
relay: Option<&RelayUrl>,
) -> Result<Self, Error>
pub fn channel_metadata_update( metadata: &ChannelMetadata, channel: EventId, relay: Option<&RelayUrl>, ) -> Result<Self, Error>
Author a NIP-28 channel metadata update (kind: 41).
channel is the kind 40 event id; relay is an optional
recommended-relay hint placed in the e tag per NIP-10.
§Errors
Forwarded from ChannelMetadata::to_json.
Sourcepub fn channel_message_root(
channel: EventId,
relay: Option<&RelayUrl>,
content: impl Into<String>,
) -> Self
pub fn channel_message_root( channel: EventId, relay: Option<&RelayUrl>, content: impl Into<String>, ) -> Self
Author a root channel message (kind: 42 with a single e
tag marked "root").
Sourcepub fn channel_message_reply(
channel: EventId,
channel_relay: Option<&RelayUrl>,
parent_message: EventId,
parent_relay: Option<&RelayUrl>,
parent_author: PublicKey,
author_relay: Option<&RelayUrl>,
content: impl Into<String>,
) -> Self
pub fn channel_message_reply( channel: EventId, channel_relay: Option<&RelayUrl>, parent_message: EventId, parent_relay: Option<&RelayUrl>, parent_author: PublicKey, author_relay: Option<&RelayUrl>, content: impl Into<String>, ) -> Self
Author a reply channel message (kind: 42 with a "root"
tag pointing at the channel and a "reply" tag pointing at
the parent message; a p tag references the replied-to
author).
Sourcepub fn channel_hide_message(
target: EventId,
reason: Option<&HideReason>,
) -> Self
pub fn channel_hide_message( target: EventId, reason: Option<&HideReason>, ) -> Self
Author a hide-message moderation event (kind: 43).
reason is optional; pass None for a bare hide signal.
Sourcepub fn channel_mute_user(target: PublicKey, reason: Option<&HideReason>) -> Self
pub fn channel_mute_user(target: PublicKey, reason: Option<&HideReason>) -> Self
Author a mute-user moderation event (kind: 44).
reason is optional.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn group_join_request(req: &JoinRequest) -> Self
pub fn group_join_request(req: &JoinRequest) -> Self
Author a NIP-29 kind: 9021 join request.
Sourcepub fn group_leave_request(req: &LeaveRequest) -> Self
pub fn group_leave_request(req: &LeaveRequest) -> Self
Author a NIP-29 kind: 9022 leave request.
Sourcepub fn group_moderation(action: &ModerationAction) -> Self
pub fn group_moderation(action: &ModerationAction) -> Self
Author a NIP-29 moderation event.
Sourcepub fn group_metadata(metadata: &GroupMetadata) -> Self
pub fn group_metadata(metadata: &GroupMetadata) -> Self
Author a NIP-29 kind: 39000 group-metadata event.
Sourcepub fn group_admins(admins: &GroupAdmins) -> Self
pub fn group_admins(admins: &GroupAdmins) -> Self
Author a NIP-29 kind: 39001 group-admins event.
Sourcepub fn group_members(members: &GroupMembers) -> Self
pub fn group_members(members: &GroupMembers) -> Self
Author a NIP-29 kind: 39002 group-members event.
Sourcepub fn group_roles(roles: &GroupRoles) -> Self
pub fn group_roles(roles: &GroupRoles) -> Self
Author a NIP-29 kind: 39003 group-roles event.
Source§impl EventBuilder
impl EventBuilder
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn git_repository(repo: &Repository) -> Self
pub fn git_repository(repo: &Repository) -> Self
Author a NIP-34 repository announcement (kind: 30617).
Sourcepub fn git_repository_state(state: &RepositoryState) -> Self
pub fn git_repository_state(state: &RepositoryState) -> Self
Author a NIP-34 repository state event (kind: 30618).
Sourcepub fn git_pull_request(pr: &PullRequest) -> Self
pub fn git_pull_request(pr: &PullRequest) -> Self
Author a NIP-34 pull request event (kind: 1618).
Sourcepub fn git_pull_request_update(update: &PullRequestUpdate) -> Self
pub fn git_pull_request_update(update: &PullRequestUpdate) -> Self
Author a NIP-34 pull request update event (kind: 1619).
Sourcepub fn git_status(event: &StatusEvent) -> Self
pub fn git_status(event: &StatusEvent) -> Self
Author a NIP-34 status event (kind: 1630..=1633).
Sourcepub fn git_grasp_servers(list: &GraspServerList) -> Self
pub fn git_grasp_servers(list: &GraspServerList) -> Self
Author a NIP-34 grasp-server list event (kind: 10317).
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn torrent_comment<S>(content: S, torrent: &Event) -> Self
pub fn torrent_comment<S>(content: S, torrent: &Event) -> Self
Build a NIP-35 torrent comment (kind: 2004) replying to torrent.
Per the spec a torrent comment “works exactly like a kind: 1” and
follows NIP-10, so this attaches a root e marker pointing at the
torrent and a p tag crediting its author.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn draft_wrap(draft: &DraftWrap) -> Self
Available on crate feature nip44 only.
pub fn draft_wrap(draft: &DraftWrap) -> Self
nip44 only.Author a NIP-37 kind: 31234 draft wrap.
Sourcepub fn private_storage_relays(list: &PrivateStorageRelays) -> Self
Available on crate feature nip44 only.
pub fn private_storage_relays(list: &PrivateStorageRelays) -> Self
nip44 only.Author a NIP-37 kind: 10013 private storage relay list.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn user_status(status: UserStatus) -> Self
pub fn user_status(status: UserStatus) -> Self
Author a NIP-38 user-status event.
The builder pins kind = 30315 and always emits the d tag
carrying the status-type identifier. The NIP-40 expiration
tag is attached through the existing
EventBuilder::expiration path when
UserStatus::expires_at is set, so callers that also
chain .expiration(ts) manually will get a single
consolidated tag.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn expiration(self, ts: Timestamp) -> Self
pub fn expiration(self, ts: Timestamp) -> Self
Attach a NIP-40 expiration deadline.
Subsequent calls replace any earlier deadline so the resulting event
always carries at most one expiration tag.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn nwc_info(info: &InfoEvent) -> Self
Available on crate feature nip44 only.
pub fn nwc_info(info: &InfoEvent) -> Self
nip44 only.Author a NIP-47 info event from a typed bundle. The author SHOULD be the wallet service’s pubkey.
Sourcepub fn nwc_request(
client_secret: &SecretKey,
wallet_public: &PublicKey,
request: &Request,
encryption: Encryption,
expiration: Option<Timestamp>,
) -> Result<Self, NwcError>
Available on crate feature nip44 only.
pub fn nwc_request( client_secret: &SecretKey, wallet_public: &PublicKey, request: &Request, encryption: Encryption, expiration: Option<Timestamp>, ) -> Result<Self, NwcError>
nip44 only.Build a NIP-47 request event with encrypted body.
client_secret is the URI’s secret; wallet_public is
the URI’s host. expiration populates a NIP-40 expiration
tag when set — spec §“Request and Response Events” treats
the timestamp as a hard cut-off the wallet service may use
to drop late requests.
§Errors
NwcError::InvalidJsonwhenrequestcannot be serialised.NwcError::Nip44/NwcError::Nip04from the underlying encryption primitives.
Sourcepub fn nwc_response(
wallet_secret: &SecretKey,
client_public: &PublicKey,
request_event_id: EventId,
response: &Response,
encryption: Encryption,
) -> Result<Self, NwcError>
Available on crate feature nip44 only.
pub fn nwc_response( wallet_secret: &SecretKey, client_public: &PublicKey, request_event_id: EventId, response: &Response, encryption: Encryption, ) -> Result<Self, NwcError>
nip44 only.Sourcepub fn nwc_notification(
wallet_secret: &SecretKey,
client_public: &PublicKey,
notification: &Notification,
encryption: Encryption,
) -> Result<Self, NwcError>
Available on crate feature nip44 only.
pub fn nwc_notification( wallet_secret: &SecretKey, client_public: &PublicKey, notification: &Notification, encryption: Encryption, ) -> Result<Self, NwcError>
nip44 only.Build a NIP-47 notification event with encrypted body.
kind should be KIND_NOTIFICATION for NIP-44 or
KIND_NOTIFICATION_LEGACY for NIP-04.
§Errors
See Self::nwc_request.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn list(list: &List) -> Self
pub fn list(list: &List) -> Self
Author a NIP-51 list event from a List bundle (no
encryption applied).
The resulting event has empty .content. Use
Self::list_with_private_items to encrypt private items
in one shot.
Sourcepub fn list_with_private_items(
list: &List,
owner_secret: &SecretKey,
owner_public: &PublicKey,
) -> Result<Self, ListEncryptionError>
Available on crate feature nip44 only.
pub fn list_with_private_items( list: &List, owner_secret: &SecretKey, owner_public: &PublicKey, ) -> Result<Self, ListEncryptionError>
nip44 only.Author a NIP-51 list event with encrypted private items.
owner_secret / owner_public MUST belong to the same
keypair (NIP-51 §“Encryption process pseudocode”).
§Errors
Forwarded from List::encrypt_private.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn calendar_date_event(event: &DateCalendarEvent) -> Self
pub fn calendar_date_event(event: &DateCalendarEvent) -> Self
Author a NIP-52 kind: 31922 date-based calendar event.
Sourcepub fn calendar_time_event(event: &TimeCalendarEvent) -> Self
pub fn calendar_time_event(event: &TimeCalendarEvent) -> Self
Author a NIP-52 kind: 31923 time-based calendar event.
Sourcepub fn calendar_rsvp(rsvp: &Rsvp) -> Self
pub fn calendar_rsvp(rsvp: &Rsvp) -> Self
Author a NIP-52 kind: 31925 RSVP event.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn live_stream(stream: &LiveStream) -> Self
pub fn live_stream(stream: &LiveStream) -> Self
Author a NIP-53 kind: 30311 live streaming event.
Sourcepub fn meeting_space(space: &MeetingSpace) -> Self
pub fn meeting_space(space: &MeetingSpace) -> Self
Author a NIP-53 kind: 30312 meeting space event.
Sourcepub fn meeting_room(room: &MeetingRoom) -> Result<Self, LiveError>
pub fn meeting_room(room: &MeetingRoom) -> Result<Self, LiveError>
Author a NIP-53 kind: 30313 meeting room event.
§Errors
Returns LiveError::MissingAddress when
MeetingRoom::space is None.
Sourcepub fn live_chat_message(msg: &LiveChatMessage) -> Self
pub fn live_chat_message(msg: &LiveChatMessage) -> Self
Author a NIP-53 kind: 1311 live chat message.
Sourcepub fn room_presence(presence: &RoomPresence) -> Self
pub fn room_presence(presence: &RoomPresence) -> Self
Author a NIP-53 kind: 10312 room presence signal.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn wiki_article(article: &WikiArticle) -> Self
pub fn wiki_article(article: &WikiArticle) -> Self
Author a NIP-54 kind: 30818 wiki article event.
Sourcepub fn wiki_redirect(redirect: &WikiRedirect) -> Self
pub fn wiki_redirect(redirect: &WikiRedirect) -> Self
Author a NIP-54 kind: 30819 wiki redirect event.
Sourcepub fn wiki_merge_request(merge: &MergeRequest) -> Self
pub fn wiki_merge_request(merge: &MergeRequest) -> Self
Author a NIP-54 kind: 818 merge request event.
Tag order matches spec example: destination a, base e,
destination p, then source e with the source marker.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn report(report: &Report) -> Self
pub fn report(report: &Report) -> Self
Author a NIP-56 kind: 1984 report event.
Tag order matches the spec examples:
- Primary target tag (
p,e, orx). - Secondary tags (the
pauthor for anereport or the hostefor anxreport). serverURL hints, if any.- Caller-supplied
Report::extra_tags.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn zap_request(request: &ZapRequest) -> Self
pub fn zap_request(request: &ZapRequest) -> Self
Author a NIP-57 zap-request event from a typed bundle.
Sourcepub fn zap_receipt(receipt: &ZapReceipt) -> Self
pub fn zap_receipt(receipt: &ZapReceipt) -> Self
Author a NIP-57 zap-receipt event from a typed bundle.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn badge_definition(definition: &BadgeDefinition) -> Self
pub fn badge_definition(definition: &BadgeDefinition) -> Self
Author a NIP-58 badge definition (kind: 30009).
Sourcepub fn badge_award(award: &BadgeAward) -> Self
pub fn badge_award(award: &BadgeAward) -> Self
Author a NIP-58 badge award (kind: 8).
Sourcepub fn profile_badges(badges: &ProfileBadges) -> Self
pub fn profile_badges(badges: &ProfileBadges) -> Self
Author a NIP-58 profile-badges list (kind: 10008).
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn cashu_wallet(info: &WalletInfo, owner: &Keys) -> Result<Self, Nip60Error>
Available on crate feature nip44 only.
pub fn cashu_wallet(info: &WalletInfo, owner: &Keys) -> Result<Self, Nip60Error>
nip44 only.Author a NIP-60 wallet event (kind: 17375) from a typed
WalletInfo.
The bundle is NIP-44 self-encrypted to owner before being
stamped on the new event’s .content.
§Errors
Forwards every error from WalletInfo::encrypt.
Sourcepub fn cashu_token(
token: &TokenContent,
owner: &Keys,
) -> Result<Self, Nip60Error>
Available on crate feature nip44 only.
pub fn cashu_token( token: &TokenContent, owner: &Keys, ) -> Result<Self, Nip60Error>
nip44 only.Author a NIP-60 token event (kind: 7375) from a typed
TokenContent.
§Errors
Forwards every error from TokenContent::encrypt.
Sourcepub fn cashu_history(
entry: &HistoryEntry,
owner: &Keys,
) -> Result<Self, Nip60Error>
Available on crate feature nip44 only.
pub fn cashu_history( entry: &HistoryEntry, owner: &Keys, ) -> Result<Self, Nip60Error>
nip44 only.Author a NIP-60 spending-history event (kind: 7376) from a
typed HistoryEntry.
The encrypted half — the direction, amount, unit, and the
created plus destroyed references — goes into .content;
the public redeemed references are stamped as cleartext
e tags so nutzap recipients can match them without
decryption.
§Errors
Forwards every error from HistoryEntry::encrypt.
Sourcepub fn cashu_quote(quote: &QuoteState, owner: &Keys) -> Result<Self, Nip60Error>
Available on crate feature nip44 only.
pub fn cashu_quote(quote: &QuoteState, owner: &Keys) -> Result<Self, Nip60Error>
nip44 only.Author a NIP-60 quote-state event (kind: 7374) from a typed
QuoteState.
The quote id is encrypted into .content; the mint and
NIP-40 expiration tags are stamped in cleartext per spec.
§Errors
Forwards every error from QuoteState::encrypt.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn nutzap_info(info: &NutzapInfo) -> Result<Self, Nip61Error>
Available on crate feature nip44 only.
pub fn nutzap_info(info: &NutzapInfo) -> Result<Self, Nip61Error>
nip44 only.Author a NIP-61 informational event (kind: 10019) from a
typed NutzapInfo.
§Errors
Forwards every error from NutzapInfo::to_tags.
Sourcepub fn nutzap(zap: &Nutzap) -> Result<Self, Nip61Error>
Available on crate feature nip44 only.
pub fn nutzap(zap: &Nutzap) -> Result<Self, Nip61Error>
nip44 only.Author a NIP-61 nutzap event (kind: 9321) from a typed
Nutzap bundle.
§Errors
Forwards every error from Nutzap::to_tags.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn request_to_vanish(req: &RequestToVanish) -> Result<Self, VanishError>
pub fn request_to_vanish(req: &RequestToVanish) -> Result<Self, VanishError>
Author a NIP-62 kind: 62 request-to-vanish event.
§Errors
Returns VanishError::MissingTarget when
RequestToVanish::targets is empty.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn relay_discovery(discovery: &RelayDiscovery) -> Self
pub fn relay_discovery(discovery: &RelayDiscovery) -> Self
Author a NIP-66 kind: 30166 relay discovery event.
Sourcepub fn relay_monitor(monitor: &RelayMonitor) -> Self
pub fn relay_monitor(monitor: &RelayMonitor) -> Self
Author a NIP-66 kind: 10166 relay monitor announcement.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn picture_post(post: &PicturePost) -> Result<Self, PictureError>
pub fn picture_post(post: &PicturePost) -> Result<Self, PictureError>
Author a NIP-68 kind: 20 picture event.
§Errors
Propagates MediaAttachmentError from any malformed
PicturePost::pictures entry.
Source§impl EventBuilder
impl EventBuilder
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn video(video: &Video) -> Result<Self, VideoError>
pub fn video(video: &Video) -> Result<Self, VideoError>
Author a NIP-71 video event.
§Errors
Propagates MediaAttachmentError when any variant in
Video::media violates NIP-92 invariants (missing URL or
no other field). Also returns
VideoError::MissingIdentifier when the variant is
addressable but Video::identifier is None.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn community_definition(definition: &CommunityDefinition) -> Self
pub fn community_definition(definition: &CommunityDefinition) -> Self
Author a NIP-72 community definition (kind: 34550).
Sourcepub fn community_post_approval(approval: &PostApproval) -> Self
pub fn community_post_approval(approval: &PostApproval) -> Self
Author a NIP-72 post approval (kind: 4550).
Sourcepub fn community_top_level_post(
community: Coordinate,
community_relay: Option<RelayUrl>,
community_author: PublicKey,
content: impl Into<String>,
) -> Self
pub fn community_top_level_post( community: Coordinate, community_relay: Option<RelayUrl>, community_author: PublicKey, content: impl Into<String>, ) -> Self
Author a top-level community post (kind: 1111 per NIP-22
- NIP-72 §“Top-level posts”).
Internally builds a Comment whose root and parent are
the community coordinate.
Sourcepub fn community_nested_reply(
community: Coordinate,
community_relay: Option<RelayUrl>,
community_author: PublicKey,
parent_post: EventId,
parent_relay: Option<RelayUrl>,
parent_kind: Kind,
parent_author: PublicKey,
content: impl Into<String>,
) -> Self
pub fn community_nested_reply( community: Coordinate, community_relay: Option<RelayUrl>, community_author: PublicKey, parent_post: EventId, parent_relay: Option<RelayUrl>, parent_kind: Kind, parent_author: PublicKey, content: impl Into<String>, ) -> Self
Author a nested community reply (kind: 1111 per NIP-22
- NIP-72 §“Nested replies”).
parent_post is the parent kind 1111 reply (or another
post). The community coordinate stays at the root scope
while parent_post lives at the parent scope.
Source§impl EventBuilder
impl EventBuilder
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn application_data(data: &ApplicationData) -> Self
pub fn application_data(data: &ApplicationData) -> Self
Author a NIP-78 kind: 30078 application-data event.
The d tag is pinned at the head of the tag list; any extra
tags follow in the order they were attached to the bundle.
Source§impl EventBuilder
impl EventBuilder
Source§impl EventBuilder
impl EventBuilder
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn poll_response(response: &PollResponse) -> Self
pub fn poll_response(response: &PollResponse) -> Self
Author a NIP-88 kind: 1018 poll-response event.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn handler_recommendation(rec: &HandlerRecommendation) -> Self
pub fn handler_recommendation(rec: &HandlerRecommendation) -> Self
Author a NIP-89 kind: 31989 recommendation event.
Sourcepub fn handler_information(handler: &HandlerInformation) -> Self
pub fn handler_information(handler: &HandlerInformation) -> Self
Author a NIP-89 kind: 31990 handler event.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn dvm_job_request(request: &JobRequest) -> Self
pub fn dvm_job_request(request: &JobRequest) -> Self
Author a NIP-90 job-request event from a typed JobRequest.
Sourcepub fn dvm_job_result(result: &JobResult) -> Self
pub fn dvm_job_result(result: &JobResult) -> Self
Author a NIP-90 job-result event from a typed JobResult.
Sourcepub fn dvm_job_feedback(feedback: &JobFeedback) -> Self
pub fn dvm_job_feedback(feedback: &JobFeedback) -> Self
Author a NIP-90 job-feedback event from a typed
JobFeedback.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn file_metadata(
caption: impl Into<String>,
metadata: &FileMetadata,
) -> Result<Self, FileMetadataError>
pub fn file_metadata( caption: impl Into<String>, metadata: &FileMetadata, ) -> Result<Self, FileMetadataError>
Author a NIP-94 file-metadata event.
caption becomes the event’s .content. The bundle’s
required fields (url, mime_type, hash) must be set, or
the call returns Err(FileMetadataError::Missing*).
§Errors
Forwards FileMetadataError from the bundle-to-tags step.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn nip96_file_servers(list: &FileServerList) -> Self
pub fn nip96_file_servers(list: &FileServerList) -> Self
Author a NIP-96 kind: 10096 user file-server list event
from a typed FileServerList.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn http_auth(request: &HttpAuthRequest) -> Self
pub fn http_auth(request: &HttpAuthRequest) -> Self
Author a NIP-98 HTTP-auth event from a typed bundle.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn classified_listing(listing: &Listing, kind: Kind) -> Self
pub fn classified_listing(listing: &Listing, kind: Kind) -> Self
Author a NIP-99 listing event of kind.
Use KIND_CLASSIFIED_LISTING for active listings or
KIND_CLASSIFIED_LISTING_DRAFT for drafts; both share the
same schema.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn voice_message(msg: &VoiceMessage) -> Result<Self, VoiceMessageError>
pub fn voice_message(msg: &VoiceMessage) -> Result<Self, VoiceMessageError>
Author a NIP-A0 voice message.
§Errors
Propagates MediaAttachmentError when the optional
VoiceMessage::media bundle violates NIP-92 invariants.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn public_message(msg: &PublicMessage) -> Result<Self, PublicMessageError>
pub fn public_message(msg: &PublicMessage) -> Result<Self, PublicMessageError>
Author a NIP-A4 kind: 24 public message.
§Errors
Returns PublicMessageError::MissingRecipient when
PublicMessage::recipients is empty.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn web_bookmark(bookmark: &WebBookmark) -> Self
pub fn web_bookmark(bookmark: &WebBookmark) -> Self
Author a NIP-B0 kind: 39701 web-bookmark event.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn blossom_servers(list: &BlossomServerList) -> Self
pub fn blossom_servers(list: &BlossomServerList) -> Self
Author a NIP-B7 / BUD-03 kind: 10063 user-server list event
from a typed BlossomServerList.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn code_snippet(snippet: &CodeSnippet) -> Self
pub fn code_snippet(snippet: &CodeSnippet) -> Self
Author a NIP-C0 kind: 1337 code-snippet event.
Source§impl EventBuilder
impl EventBuilder
Sourcepub fn chat_message(msg: &ChatMessage) -> Self
pub fn chat_message(msg: &ChatMessage) -> Self
Author a NIP-C7 kind: 9 chat message.
Trait Implementations§
Source§impl Clone for EventBuilder
impl Clone for EventBuilder
Source§fn clone(&self) -> EventBuilder
fn clone(&self) -> EventBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more