lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit 52fe6e3e3b035a2b9cfd140a019ca102e5c2c0a7
parent a6d342d40d04820a6e646eff4f663d805854cd18
Author: triesap <tyson@radroots.org>
Date:   Wed,  4 Mar 2026 17:53:31 +0000

events-codec: run cargo fmt

Diffstat:
Mcrates/events-codec/src/app_data/decode.rs | 12++++++++----
Mcrates/events-codec/src/comment/decode.rs | 12+++++++++---
Mcrates/events-codec/src/coop/decode.rs | 15++++++++-------
Mcrates/events-codec/src/document/decode.rs | 13++++++++-----
Mcrates/events-codec/src/farm/decode.rs | 15++++++++-------
Mcrates/events-codec/src/follow/decode.rs | 13++++++++-----
Mcrates/events-codec/src/geochat/decode.rs | 14++++++++------
Mcrates/events-codec/src/gift_wrap/decode.rs | 13++++++++-----
Mcrates/events-codec/src/job/feedback/decode.rs | 16+++++++++-------
Mcrates/events-codec/src/job/request/decode.rs | 15+++++++++------
Mcrates/events-codec/src/job/result/decode.rs | 15+++++++++------
Mcrates/events-codec/src/job/traits.rs | 33++++++++++++++++++++++-----------
Mcrates/events-codec/src/lib.rs | 2+-
Mcrates/events-codec/src/list/decode.rs | 8+++++++-
Mcrates/events-codec/src/list_set/decode.rs | 16++++++++++------
Mcrates/events-codec/src/listing/decode.rs | 13++++++++-----
Mcrates/events-codec/src/message/decode.rs | 16+++++++++-------
Mcrates/events-codec/src/message_file/decode.rs | 14+++++++++-----
Mcrates/events-codec/src/plot/decode.rs | 10++++++++--
Mcrates/events-codec/src/post/decode.rs | 14++++++++------
Mcrates/events-codec/src/profile/decode.rs | 3++-
Mcrates/events-codec/src/reaction/decode.rs | 15+++++++++------
Mcrates/events-codec/src/resource_area/decode.rs | 15++++++++-------
Mcrates/events-codec/src/resource_cap/decode.rs | 6+-----
Mcrates/events-codec/src/seal/decode.rs | 14++++++++------
Mcrates/events-codec/tests/app_data.rs | 2+-
Mcrates/events-codec/tests/comment.rs | 2+-
Mcrates/events-codec/tests/follow.rs | 9++-------
Mcrates/events-codec/tests/geochat.rs | 2+-
Mcrates/events-codec/tests/gift_wrap.rs | 2+-
Mcrates/events-codec/tests/job_feedback.rs | 2+-
Mcrates/events-codec/tests/job_request.rs | 2+-
Mcrates/events-codec/tests/job_result.rs | 2+-
Mcrates/events-codec/tests/list.rs | 2+-
Mcrates/events-codec/tests/list_set.rs | 2+-
Mcrates/events-codec/tests/message.rs | 2+-
Mcrates/events-codec/tests/message_file.rs | 2+-
Mcrates/events-codec/tests/post.rs | 4+---
Mcrates/events-codec/tests/profile.rs | 5++++-
Mcrates/events-codec/tests/reaction.rs | 2+-
Mcrates/events-codec/tests/seal.rs | 2+-
Mcrates/events-codec/tests/structured_decode.rs | 51++++++++++++++++++++++++---------------------------
42 files changed, 246 insertions(+), 181 deletions(-)

diff --git a/crates/events-codec/src/app_data/decode.rs b/crates/events-codec/src/app_data/decode.rs @@ -6,9 +6,7 @@ use alloc::{ use radroots_events::{ RadrootsNostrEvent, - app_data::{ - KIND_APP_DATA, RadrootsAppData, - }, + app_data::{KIND_APP_DATA, RadrootsAppData}, tags::TAG_D, }; @@ -57,7 +55,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsAppData>, EventParseError> { let app_data = app_data_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, app_data)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + app_data, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/comment/decode.rs b/crates/events-codec/src/comment/decode.rs @@ -6,14 +6,14 @@ use alloc::{ use radroots_events::{ RadrootsNostrEvent, - comment::{RadrootsComment}, + comment::RadrootsComment, kinds::KIND_COMMENT, tags::{TAG_E_PREV, TAG_E_ROOT}, }; use crate::error::EventParseError; -use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; use crate::event_ref::{find_event_ref_tag, parse_event_ref_tag, parse_nip10_ref_tags}; +use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; const DEFAULT_KIND: u32 = KIND_COMMENT; @@ -64,7 +64,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsComment>, EventParseError> { let comment = comment_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, comment)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + comment, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/coop/decode.rs b/crates/events-codec/src/coop/decode.rs @@ -7,12 +7,7 @@ use alloc::{ vec::Vec, }; -use radroots_events::{ - RadrootsNostrEvent, - coop::{RadrootsCoop}, - kinds::KIND_COOP, - tags::TAG_D, -}; +use radroots_events::{RadrootsNostrEvent, coop::RadrootsCoop, kinds::KIND_COOP, tags::TAG_D}; use crate::d_tag::validate_d_tag_tag; use crate::error::EventParseError; @@ -72,7 +67,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsCoop>, EventParseError> { let coop = coop_from_event(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, coop)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + coop, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/document/decode.rs b/crates/events-codec/src/document/decode.rs @@ -8,10 +8,7 @@ use alloc::{ }; use radroots_events::{ - RadrootsNostrEvent, - document::{RadrootsDocument}, - kinds::KIND_DOCUMENT, - tags::TAG_D, + RadrootsNostrEvent, document::RadrootsDocument, kinds::KIND_DOCUMENT, tags::TAG_D, }; use crate::d_tag::validate_d_tag_tag; @@ -133,7 +130,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsDocument>, EventParseError> { let document = document_from_event(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, document)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + document, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/farm/decode.rs b/crates/events-codec/src/farm/decode.rs @@ -6,12 +6,7 @@ use alloc::{ vec::Vec, }; -use radroots_events::{ - RadrootsNostrEvent, - farm::{RadrootsFarm}, - kinds::KIND_FARM, - tags::TAG_D, -}; +use radroots_events::{RadrootsNostrEvent, farm::RadrootsFarm, kinds::KIND_FARM, tags::TAG_D}; use crate::d_tag::validate_d_tag_tag; use crate::error::EventParseError; @@ -71,7 +66,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsFarm>, EventParseError> { let farm = farm_from_event(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, farm)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + farm, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/follow/decode.rs b/crates/events-codec/src/follow/decode.rs @@ -3,10 +3,7 @@ use alloc::{string::String, vec::Vec}; use radroots_events::{ RadrootsNostrEvent, - follow::{ - RadrootsFollow, - RadrootsFollowProfile, - }, + follow::{RadrootsFollow, RadrootsFollowProfile}, kinds::KIND_FOLLOW, }; @@ -78,7 +75,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsFollow>, EventParseError> { let follow = follow_from_tags(kind, &tags, published_at)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, follow)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + follow, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/geochat/decode.rs b/crates/events-codec/src/geochat/decode.rs @@ -4,11 +4,7 @@ use alloc::{ vec::Vec, }; -use radroots_events::{ - RadrootsNostrEvent, - geochat::{RadrootsGeoChat}, - kinds::KIND_GEOCHAT, -}; +use radroots_events::{RadrootsNostrEvent, geochat::RadrootsGeoChat, kinds::KIND_GEOCHAT}; use crate::error::EventParseError; use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; @@ -98,7 +94,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsGeoChat>, EventParseError> { let geochat = geochat_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, geochat)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + geochat, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/gift_wrap/decode.rs b/crates/events-codec/src/gift_wrap/decode.rs @@ -6,10 +6,7 @@ use alloc::{ use radroots_events::{ RadrootsNostrEvent, - gift_wrap::{ - RadrootsGiftWrap, - RadrootsGiftWrapRecipient, - }, + gift_wrap::{RadrootsGiftWrap, RadrootsGiftWrapRecipient}, kinds::KIND_GIFT_WRAP, }; @@ -87,7 +84,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsGiftWrap>, EventParseError> { let gift_wrap = gift_wrap_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, gift_wrap)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + gift_wrap, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/job/feedback/decode.rs b/crates/events-codec/src/job/feedback/decode.rs @@ -1,10 +1,6 @@ use radroots_events::{ - RadrootsNostrEvent, RadrootsNostrEventPtr, - job::JobPaymentRequest, - job_feedback::{ - RadrootsJobFeedback, - }, - kinds::KIND_JOB_FEEDBACK, + RadrootsNostrEvent, RadrootsNostrEventPtr, job::JobPaymentRequest, + job_feedback::RadrootsJobFeedback, kinds::KIND_JOB_FEEDBACK, }; #[cfg(not(feature = "std"))] @@ -90,7 +86,13 @@ pub fn data_from_event( return Err(JobParseError::InvalidTag("kind (expected 7000)")); } let job_feedback = job_feedback_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, job_feedback)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + job_feedback, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/job/request/decode.rs b/crates/events-codec/src/job/request/decode.rs @@ -1,8 +1,6 @@ use radroots_events::{ RadrootsNostrEvent, - job_request::{ - RadrootsJobInput, RadrootsJobParam, RadrootsJobRequest, - }, + job_request::{RadrootsJobInput, RadrootsJobParam, RadrootsJobRequest}, kinds::is_request_kind, }; @@ -78,7 +76,13 @@ pub fn data_from_event( return Err(JobParseError::InvalidTag("kind (expected 5000-5999)")); } let job_request = job_request_from_tags(kind, &tags)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, job_request)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + job_request, + )) } pub fn parsed_from_event( @@ -90,8 +94,7 @@ pub fn parsed_from_event( tags: Vec<Vec<String>>, sig: String, ) -> Result<RadrootsParsedEvent<RadrootsJobRequest>, JobParseError> { - let data = - data_from_event(id.clone(), author.clone(), published_at, kind, tags.clone())?; + let data = data_from_event(id.clone(), author.clone(), published_at, kind, tags.clone())?; Ok(RadrootsParsedEvent { event: RadrootsNostrEvent { id, diff --git a/crates/events-codec/src/job/result/decode.rs b/crates/events-codec/src/job/result/decode.rs @@ -1,9 +1,6 @@ use radroots_events::{ - RadrootsNostrEvent, RadrootsNostrEventPtr, - job::JobPaymentRequest, - job_request::RadrootsJobInput, - job_result::{RadrootsJobResult}, - kinds::is_result_kind, + RadrootsNostrEvent, RadrootsNostrEventPtr, job::JobPaymentRequest, + job_request::RadrootsJobInput, job_result::RadrootsJobResult, kinds::is_result_kind, }; #[cfg(not(feature = "std"))] @@ -85,7 +82,13 @@ pub fn data_from_event( return Err(JobParseError::InvalidTag("kind (expected 6000-6999)")); } let job_result = job_result_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, job_result)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + job_result, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/job/traits.rs b/crates/events-codec/src/job/traits.rs @@ -1,27 +1,26 @@ #[cfg(not(feature = "std"))] extern crate alloc; +use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; #[cfg(not(feature = "std"))] use alloc::{borrow::ToOwned, string::String, vec::Vec}; use radroots_events::{ job_feedback::RadrootsJobFeedback, job_request::RadrootsJobRequest, job_result::RadrootsJobResult, }; -use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; use crate::job::{ error::JobParseError, feedback::decode::{ - parsed_from_event as feedback_index_from_event, data_from_event as feedback_metadata_from_event, + parsed_from_event as feedback_index_from_event, }, request::decode::{ - parsed_from_event as request_index_from_event, data_from_event as request_metadata_from_event, + parsed_from_event as request_index_from_event, }, result::decode::{ - parsed_from_event as result_index_from_event, - data_from_event as result_metadata_from_event, + data_from_event as result_metadata_from_event, parsed_from_event as result_index_from_event, }, }; @@ -34,7 +33,9 @@ pub trait JobEventLike { fn raw_tags(&self) -> Vec<Vec<String>>; fn raw_sig(&self) -> String; - fn to_job_request_metadata(&self) -> Result<RadrootsParsedData<RadrootsJobRequest>, JobParseError> { + fn to_job_request_metadata( + &self, + ) -> Result<RadrootsParsedData<RadrootsJobRequest>, JobParseError> { request_metadata_from_event( self.raw_id(), self.raw_author(), @@ -44,7 +45,9 @@ pub trait JobEventLike { ) } - fn to_job_request_event_index(&self) -> Result<RadrootsParsedEvent<RadrootsJobRequest>, JobParseError> { + fn to_job_request_event_index( + &self, + ) -> Result<RadrootsParsedEvent<RadrootsJobRequest>, JobParseError> { request_index_from_event( self.raw_id(), self.raw_author(), @@ -56,7 +59,9 @@ pub trait JobEventLike { ) } - fn to_job_result_metadata(&self) -> Result<RadrootsParsedData<RadrootsJobResult>, JobParseError> { + fn to_job_result_metadata( + &self, + ) -> Result<RadrootsParsedData<RadrootsJobResult>, JobParseError> { result_metadata_from_event( self.raw_id(), self.raw_author(), @@ -67,7 +72,9 @@ pub trait JobEventLike { ) } - fn to_job_result_event_index(&self) -> Result<RadrootsParsedEvent<RadrootsJobResult>, JobParseError> { + fn to_job_result_event_index( + &self, + ) -> Result<RadrootsParsedEvent<RadrootsJobResult>, JobParseError> { result_index_from_event( self.raw_id(), self.raw_author(), @@ -79,7 +86,9 @@ pub trait JobEventLike { ) } - fn to_job_feedback_metadata(&self) -> Result<RadrootsParsedData<RadrootsJobFeedback>, JobParseError> { + fn to_job_feedback_metadata( + &self, + ) -> Result<RadrootsParsedData<RadrootsJobFeedback>, JobParseError> { feedback_metadata_from_event( self.raw_id(), self.raw_author(), @@ -90,7 +99,9 @@ pub trait JobEventLike { ) } - fn to_job_feedback_event_index(&self) -> Result<RadrootsParsedEvent<RadrootsJobFeedback>, JobParseError> { + fn to_job_feedback_event_index( + &self, + ) -> Result<RadrootsParsedEvent<RadrootsJobFeedback>, JobParseError> { feedback_index_from_event( self.raw_id(), self.raw_author(), diff --git a/crates/events-codec/src/lib.rs b/crates/events-codec/src/lib.rs @@ -7,8 +7,8 @@ pub mod d_tag; pub mod error; pub mod event_ref; pub mod job; -pub mod profile; pub mod parsed; +pub mod profile; pub mod tag_builders; pub mod wire; diff --git a/crates/events-codec/src/list/decode.rs b/crates/events-codec/src/list/decode.rs @@ -59,7 +59,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsList>, EventParseError> { let list = list_from_tags(kind, content, &tags)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, list)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + list, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/list_set/decode.rs b/crates/events-codec/src/list_set/decode.rs @@ -2,16 +2,14 @@ use alloc::{string::String, vec::Vec}; use radroots_events::{ - RadrootsNostrEvent, - kinds::is_nip51_list_set_kind, - list::RadrootsListEntry, - list_set::{RadrootsListSet}, + RadrootsNostrEvent, kinds::is_nip51_list_set_kind, list::RadrootsListEntry, + list_set::RadrootsListSet, }; use crate::error::EventParseError; -use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; #[cfg(feature = "serde_json")] use crate::list::decode::list_entries_from_tags; +use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; const TAG_D: &str = "d"; const TAG_TITLE: &str = "title"; @@ -110,7 +108,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsListSet>, EventParseError> { let list_set = list_set_from_tags(kind, content, &tags)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, list_set)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + list_set, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/listing/decode.rs b/crates/events-codec/src/listing/decode.rs @@ -10,10 +10,7 @@ use radroots_events::{ RadrootsNostrEvent, kinds::KIND_LISTING, kinds::{KIND_FARM, KIND_PLOT, KIND_RESOURCE_AREA}, - listing::{ - RadrootsListing, - RadrootsListingFarmRef, - }, + listing::{RadrootsListing, RadrootsListingFarmRef}, plot::RadrootsPlotRef, resource_area::RadrootsResourceAreaRef, tags::TAG_D, @@ -235,7 +232,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsListing>, EventParseError> { let listing = listing_from_event(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, listing)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + listing, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/message/decode.rs b/crates/events-codec/src/message/decode.rs @@ -4,15 +4,11 @@ use alloc::{ vec::Vec, }; -use radroots_events::{ - RadrootsNostrEvent, - kinds::KIND_MESSAGE, - message::{RadrootsMessage}, -}; +use radroots_events::{RadrootsNostrEvent, kinds::KIND_MESSAGE, message::RadrootsMessage}; use crate::error::EventParseError; -use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; use crate::message::tags::{parse_recipients, parse_reply_tag, parse_subject_tag}; +use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; const DEFAULT_KIND: u32 = KIND_MESSAGE; @@ -54,7 +50,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsMessage>, EventParseError> { let message = message_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, message)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + message, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/message_file/decode.rs b/crates/events-codec/src/message_file/decode.rs @@ -7,14 +7,12 @@ use alloc::{ use radroots_events::{ RadrootsNostrEvent, kinds::KIND_MESSAGE_FILE, - message_file::{ - RadrootsMessageFile, RadrootsMessageFileDimensions, - }, + message_file::{RadrootsMessageFile, RadrootsMessageFileDimensions}, }; use crate::error::EventParseError; -use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; use crate::message::tags::{parse_recipients, parse_reply_tag, parse_subject_tag}; +use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; const DEFAULT_KIND: u32 = KIND_MESSAGE_FILE; @@ -164,7 +162,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsMessageFile>, EventParseError> { let message_file = message_file_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, message_file)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + message_file, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/plot/decode.rs b/crates/events-codec/src/plot/decode.rs @@ -10,7 +10,7 @@ use radroots_events::{ RadrootsNostrEvent, farm::RadrootsFarmRef, kinds::{KIND_FARM, KIND_PLOT}, - plot::{RadrootsPlot}, + plot::RadrootsPlot, tags::TAG_D, }; @@ -132,7 +132,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsPlot>, EventParseError> { let plot = plot_from_event(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, plot)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + plot, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/post/decode.rs b/crates/events-codec/src/post/decode.rs @@ -4,11 +4,7 @@ use alloc::{ vec::Vec, }; -use radroots_events::{ - RadrootsNostrEvent, - kinds::KIND_POST, - post::{RadrootsPost}, -}; +use radroots_events::{RadrootsNostrEvent, kinds::KIND_POST, post::RadrootsPost}; use crate::error::EventParseError; use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; @@ -39,7 +35,13 @@ pub fn data_from_event( _tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsPost>, EventParseError> { let post = post_from_content(kind, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, post)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + post, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/profile/decode.rs b/crates/events-codec/src/profile/decode.rs @@ -11,7 +11,8 @@ use radroots_events::{ RadrootsNostrEvent, kinds::KIND_PROFILE, profile::{ - RADROOTS_PROFILE_TYPE_TAG_KEY, RadrootsProfile, RadrootsProfileType, radroots_profile_type_from_tag_value, + RADROOTS_PROFILE_TYPE_TAG_KEY, RadrootsProfile, RadrootsProfileType, + radroots_profile_type_from_tag_value, }, }; diff --git a/crates/events-codec/src/reaction/decode.rs b/crates/events-codec/src/reaction/decode.rs @@ -5,15 +5,12 @@ use alloc::{ }; use radroots_events::{ - RadrootsNostrEvent, - kinds::KIND_REACTION, - reaction::{RadrootsReaction}, - tags::TAG_E_ROOT, + RadrootsNostrEvent, kinds::KIND_REACTION, reaction::RadrootsReaction, tags::TAG_E_ROOT, }; use crate::error::EventParseError; -use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; use crate::event_ref::{find_event_ref_tag, parse_event_ref_tag, parse_nip10_ref_tags}; +use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; const DEFAULT_KIND: u32 = KIND_REACTION; @@ -53,7 +50,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsReaction>, EventParseError> { let reaction = reaction_from_tags(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, reaction)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + reaction, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/resource_area/decode.rs b/crates/events-codec/src/resource_area/decode.rs @@ -7,12 +7,7 @@ use alloc::{ }; use radroots_events::{ - RadrootsNostrEvent, - kinds::KIND_RESOURCE_AREA, - resource_area::{ - RadrootsResourceArea, - }, - tags::TAG_D, + RadrootsNostrEvent, kinds::KIND_RESOURCE_AREA, resource_area::RadrootsResourceArea, tags::TAG_D, }; use crate::d_tag::validate_d_tag_tag; @@ -73,7 +68,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsResourceArea>, EventParseError> { let area = resource_area_from_event(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, area)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + area, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/src/resource_cap/decode.rs b/crates/events-codec/src/resource_cap/decode.rs @@ -7,11 +7,7 @@ use alloc::{ }; use radroots_events::{ - RadrootsNostrEvent, - kinds::KIND_RESOURCE_HARVEST_CAP, - resource_cap::{ - RadrootsResourceHarvestCap, - }, + RadrootsNostrEvent, kinds::KIND_RESOURCE_HARVEST_CAP, resource_cap::RadrootsResourceHarvestCap, tags::TAG_D, }; diff --git a/crates/events-codec/src/seal/decode.rs b/crates/events-codec/src/seal/decode.rs @@ -4,11 +4,7 @@ use alloc::{ vec::Vec, }; -use radroots_events::{ - RadrootsNostrEvent, - kinds::KIND_SEAL, - seal::{RadrootsSeal}, -}; +use radroots_events::{RadrootsNostrEvent, kinds::KIND_SEAL, seal::RadrootsSeal}; use crate::error::EventParseError; use crate::parsed::{RadrootsParsedData, RadrootsParsedEvent}; @@ -46,7 +42,13 @@ pub fn data_from_event( tags: Vec<Vec<String>>, ) -> Result<RadrootsParsedData<RadrootsSeal>, EventParseError> { let seal = seal_from_parts(kind, &tags, &content)?; - Ok(RadrootsParsedData::new(id, author, published_at, kind, seal)) + Ok(RadrootsParsedData::new( + id, + author, + published_at, + kind, + seal, + )) } pub fn parsed_from_event( diff --git a/crates/events-codec/tests/app_data.rs b/crates/events-codec/tests/app_data.rs @@ -3,7 +3,7 @@ use radroots_events::{ kinds::KIND_POST, }; use radroots_events_codec::app_data::decode::{ - app_data_from_tags, parsed_from_event, data_from_event, + app_data_from_tags, data_from_event, parsed_from_event, }; use radroots_events_codec::app_data::encode::{ app_data_build_tags, to_wire_parts, to_wire_parts_with_kind, diff --git a/crates/events-codec/tests/comment.rs b/crates/events-codec/tests/comment.rs @@ -7,7 +7,7 @@ use radroots_events::{ }; use radroots_events_codec::comment::decode::comment_from_tags; -use radroots_events_codec::comment::decode::{parsed_from_event, data_from_event}; +use radroots_events_codec::comment::decode::{data_from_event, parsed_from_event}; use radroots_events_codec::comment::encode::{ comment_build_tags, to_wire_parts, to_wire_parts_with_kind, }; diff --git a/crates/events-codec/tests/follow.rs b/crates/events-codec/tests/follow.rs @@ -4,9 +4,7 @@ use radroots_events::{ }; use radroots_events_codec::error::{EventEncodeError, EventParseError}; -use radroots_events_codec::follow::decode::{ - follow_from_tags, parsed_from_event, data_from_event, -}; +use radroots_events_codec::follow::decode::{data_from_event, follow_from_tags, parsed_from_event}; use radroots_events_codec::follow::encode::{ FollowMutation, follow_apply, follow_to_wire_parts_after, to_wire_parts, to_wire_parts_with_kind, @@ -166,10 +164,7 @@ fn follow_metadata_and_index_from_event_roundtrip() { metadata.data.list[0].relay_url.as_deref(), Some("wss://relay.example.com") ); - assert_eq!( - metadata.data.list[0].contact_name.as_deref(), - Some("alice") - ); + assert_eq!(metadata.data.list[0].contact_name.as_deref(), Some("alice")); let index = parsed_from_event( "id".to_string(), diff --git a/crates/events-codec/tests/geochat.rs b/crates/events-codec/tests/geochat.rs @@ -4,7 +4,7 @@ use radroots_events::{ }; use radroots_events_codec::error::{EventEncodeError, EventParseError}; use radroots_events_codec::geochat::decode::{ - geochat_from_tags, parsed_from_event, data_from_event, + data_from_event, geochat_from_tags, parsed_from_event, }; use radroots_events_codec::geochat::encode::{geochat_build_tags, to_wire_parts}; diff --git a/crates/events-codec/tests/gift_wrap.rs b/crates/events-codec/tests/gift_wrap.rs @@ -3,7 +3,7 @@ use radroots_events::kinds::{KIND_GIFT_WRAP, KIND_MESSAGE}; use radroots_events_codec::error::{EventEncodeError, EventParseError}; use radroots_events_codec::gift_wrap::decode::{ - gift_wrap_from_tags, parsed_from_event, data_from_event, + data_from_event, gift_wrap_from_tags, parsed_from_event, }; use radroots_events_codec::gift_wrap::encode::{ gift_wrap_build_tags, to_wire_parts, to_wire_parts_with_kind, diff --git a/crates/events-codec/tests/job_feedback.rs b/crates/events-codec/tests/job_feedback.rs @@ -5,7 +5,7 @@ use radroots_events::job_feedback::RadrootsJobFeedback; use radroots_events::kinds::{KIND_JOB_FEEDBACK, KIND_JOB_REQUEST_MIN, KIND_JOB_RESULT_MIN}; use radroots_events_codec::job::encode::JobEncodeError; use radroots_events_codec::job::error::JobParseError; -use radroots_events_codec::job::feedback::decode::{parsed_from_event, job_feedback_from_tags}; +use radroots_events_codec::job::feedback::decode::{job_feedback_from_tags, parsed_from_event}; use radroots_events_codec::job::feedback::encode::to_wire_parts; fn sample_feedback() -> RadrootsJobFeedback { diff --git a/crates/events-codec/tests/job_request.rs b/crates/events-codec/tests/job_request.rs @@ -3,7 +3,7 @@ use radroots_events::job_request::{RadrootsJobInput, RadrootsJobParam, RadrootsJ use radroots_events::kinds::{KIND_JOB_FEEDBACK, KIND_JOB_REQUEST_MIN, KIND_JOB_RESULT_MIN}; use radroots_events_codec::job::encode::JobEncodeError; use radroots_events_codec::job::error::JobParseError; -use radroots_events_codec::job::request::decode::{parsed_from_event, job_request_from_tags}; +use radroots_events_codec::job::request::decode::{job_request_from_tags, parsed_from_event}; use radroots_events_codec::job::request::encode::to_wire_parts; fn sample_request() -> RadrootsJobRequest { diff --git a/crates/events-codec/tests/job_result.rs b/crates/events-codec/tests/job_result.rs @@ -6,7 +6,7 @@ use radroots_events::job_result::RadrootsJobResult; use radroots_events::kinds::{KIND_JOB_REQUEST_MIN, KIND_JOB_RESULT_MIN}; use radroots_events_codec::job::encode::JobEncodeError; use radroots_events_codec::job::error::JobParseError; -use radroots_events_codec::job::result::decode::{parsed_from_event, job_result_from_tags}; +use radroots_events_codec::job::result::decode::{job_result_from_tags, parsed_from_event}; use radroots_events_codec::job::result::encode::to_wire_parts; fn sample_result() -> RadrootsJobResult { diff --git a/crates/events-codec/tests/list.rs b/crates/events-codec/tests/list.rs @@ -4,7 +4,7 @@ use radroots_events::{ }; use radroots_events_codec::error::{EventEncodeError, EventParseError}; use radroots_events_codec::list::decode::{ - parsed_from_event, list_entries_from_tags, list_from_tags, data_from_event, + data_from_event, list_entries_from_tags, list_from_tags, parsed_from_event, }; use radroots_events_codec::list::encode::{list_build_tags, to_wire_parts_with_kind}; diff --git a/crates/events-codec/tests/list_set.rs b/crates/events-codec/tests/list_set.rs @@ -5,7 +5,7 @@ use radroots_events::{ }; use radroots_events_codec::error::{EventEncodeError, EventParseError}; use radroots_events_codec::list_set::decode::{ - parsed_from_event, list_set_from_tags, data_from_event, + data_from_event, list_set_from_tags, parsed_from_event, }; use radroots_events_codec::list_set::encode::{list_set_build_tags, to_wire_parts_with_kind}; diff --git a/crates/events-codec/tests/message.rs b/crates/events-codec/tests/message.rs @@ -5,7 +5,7 @@ use radroots_events::{ }; use radroots_events_codec::error::{EventEncodeError, EventParseError}; use radroots_events_codec::message::decode::{ - parsed_from_event, message_from_tags, data_from_event, + data_from_event, message_from_tags, parsed_from_event, }; use radroots_events_codec::message::encode::{message_build_tags, to_wire_parts}; diff --git a/crates/events-codec/tests/message_file.rs b/crates/events-codec/tests/message_file.rs @@ -5,7 +5,7 @@ use radroots_events::message_file::{RadrootsMessageFile, RadrootsMessageFileDime use radroots_events_codec::error::{EventEncodeError, EventParseError}; use radroots_events_codec::message_file::decode::{ - parsed_from_event, message_file_from_tags, data_from_event, + data_from_event, message_file_from_tags, parsed_from_event, }; use radroots_events_codec::message_file::encode::{ message_file_build_tags, to_wire_parts, to_wire_parts_with_kind, diff --git a/crates/events-codec/tests/post.rs b/crates/events-codec/tests/post.rs @@ -3,9 +3,7 @@ use radroots_events::{ post::RadrootsPost, }; use radroots_events_codec::error::{EventEncodeError, EventParseError}; -use radroots_events_codec::post::decode::{ - parsed_from_event, data_from_event, post_from_content, -}; +use radroots_events_codec::post::decode::{data_from_event, parsed_from_event, post_from_content}; use radroots_events_codec::post::encode::to_wire_parts; #[test] diff --git a/crates/events-codec/tests/profile.rs b/crates/events-codec/tests/profile.rs @@ -113,5 +113,8 @@ fn profile_metadata_reads_profile_type_radrootsd_tag() { ) .expect("metadata"); - assert_eq!(metadata.data.profile_type, Some(RadrootsProfileType::Radrootsd)); + assert_eq!( + metadata.data.profile_type, + Some(RadrootsProfileType::Radrootsd) + ); } diff --git a/crates/events-codec/tests/reaction.rs b/crates/events-codec/tests/reaction.rs @@ -9,7 +9,7 @@ use radroots_events::{ use radroots_events_codec::error::{EventEncodeError, EventParseError}; use radroots_events_codec::event_ref::{build_event_ref_tag, push_nip10_ref_tags}; use radroots_events_codec::reaction::decode::{ - parsed_from_event, data_from_event, reaction_from_tags, + data_from_event, parsed_from_event, reaction_from_tags, }; use radroots_events_codec::reaction::encode::{ reaction_build_tags, to_wire_parts, to_wire_parts_with_kind, diff --git a/crates/events-codec/tests/seal.rs b/crates/events-codec/tests/seal.rs @@ -2,7 +2,7 @@ use radroots_events::kinds::{KIND_MESSAGE, KIND_SEAL}; use radroots_events::seal::RadrootsSeal; use radroots_events_codec::error::{EventEncodeError, EventParseError}; -use radroots_events_codec::seal::decode::{parsed_from_event, data_from_event, seal_from_parts}; +use radroots_events_codec::seal::decode::{data_from_event, parsed_from_event, seal_from_parts}; use radroots_events_codec::seal::encode::{ seal_build_tags, to_wire_parts, to_wire_parts_with_kind, }; diff --git a/crates/events-codec/tests/structured_decode.rs b/crates/events-codec/tests/structured_decode.rs @@ -2,9 +2,7 @@ use radroots_core::{RadrootsCoreDecimal, RadrootsCoreQuantity, RadrootsCoreUnit}; use radroots_events::coop::RadrootsCoop; -use radroots_events::document::{ - RadrootsDocument, RadrootsDocumentSubject, -}; +use radroots_events::document::{RadrootsDocument, RadrootsDocumentSubject}; use radroots_events::farm::{ RadrootsFarm, RadrootsFarmRef, RadrootsGcsLocation, RadrootsGeoJsonPoint, RadrootsGeoJsonPolygon, @@ -16,36 +14,34 @@ use radroots_events::plot::RadrootsPlot; use radroots_events::resource_area::{ RadrootsResourceArea, RadrootsResourceAreaLocation, RadrootsResourceAreaRef, }; -use radroots_events::resource_cap::{ - RadrootsResourceHarvestCap, RadrootsResourceHarvestProduct, -}; +use radroots_events::resource_cap::{RadrootsResourceHarvestCap, RadrootsResourceHarvestProduct}; use radroots_events::tags::TAG_D; use radroots_events_codec::coop::decode::{ - coop_from_event, parsed_from_event as coop_index_from_event, - data_from_event as coop_metadata_from_event, + coop_from_event, data_from_event as coop_metadata_from_event, + parsed_from_event as coop_index_from_event, }; use radroots_events_codec::document::decode::{ - document_from_event, parsed_from_event as document_index_from_event, - data_from_event as document_metadata_from_event, + data_from_event as document_metadata_from_event, document_from_event, + parsed_from_event as document_index_from_event, }; use radroots_events_codec::error::EventParseError; use radroots_events_codec::farm::decode::{ - farm_from_event, parsed_from_event as farm_index_from_event, - data_from_event as farm_metadata_from_event, + data_from_event as farm_metadata_from_event, farm_from_event, + parsed_from_event as farm_index_from_event, }; +use radroots_events_codec::parsed::{RadrootsParsedData, RadrootsParsedEvent}; use radroots_events_codec::plot::decode::{ - parsed_from_event as plot_index_from_event, data_from_event as plot_metadata_from_event, + data_from_event as plot_metadata_from_event, parsed_from_event as plot_index_from_event, plot_from_event, }; use radroots_events_codec::resource_area::decode::{ - parsed_from_event as resource_area_index_from_event, - data_from_event as resource_area_metadata_from_event, resource_area_from_event, + data_from_event as resource_area_metadata_from_event, + parsed_from_event as resource_area_index_from_event, resource_area_from_event, }; use radroots_events_codec::resource_cap::decode::{ - parsed_from_event as resource_cap_index_from_event, - data_from_event as resource_cap_metadata_from_event, resource_harvest_cap_from_event, + data_from_event as resource_cap_metadata_from_event, + parsed_from_event as resource_cap_index_from_event, resource_harvest_cap_from_event, }; -use radroots_events_codec::parsed::{RadrootsParsedData, RadrootsParsedEvent}; const TEST_NPUB: &str = "npub1tr33s4tj2le2kk9yzhfphdtss26gyn8kv7savnnjhj794nqp333q8e7grr"; const TEST_PUBKEY_HEX: &str = "58e318557257f2ab58a415d21bb57082b4824cf667a1d64e72bcbc5acc018c62"; @@ -614,15 +610,16 @@ fn resource_cap_metadata_and_index_decode_roundtrip() { let d_tag = "DAAAAAAAAAAAAAAAAAAAAA"; let content = serde_json::to_string(&sample_resource_cap(d_tag)).expect("cap content"); let tags = d_tag_tags(d_tag); - let metadata: RadrootsParsedData<RadrootsResourceHarvestCap> = resource_cap_metadata_from_event( - "id6".to_string(), - TEST_PUBKEY_HEX.to_string(), - 60, - KIND_RESOURCE_HARVEST_CAP, - content.clone(), - tags.clone(), - ) - .expect("cap metadata"); + let metadata: RadrootsParsedData<RadrootsResourceHarvestCap> = + resource_cap_metadata_from_event( + "id6".to_string(), + TEST_PUBKEY_HEX.to_string(), + 60, + KIND_RESOURCE_HARVEST_CAP, + content.clone(), + tags.clone(), + ) + .expect("cap metadata"); assert_eq!(metadata.data.d_tag, d_tag); let index: RadrootsParsedEvent<RadrootsResourceHarvestCap> = resource_cap_index_from_event(