diff --git a/bindings/nostr-ffi/src/event/tag.rs b/bindings/nostr-ffi/src/event/tag.rs index c47668147..11abac679 100644 --- a/bindings/nostr-ffi/src/event/tag.rs +++ b/bindings/nostr-ffi/src/event/tag.rs @@ -2,6 +2,8 @@ // Copyright (c) 2023-2024 Rust Nostr Developers // Distributed under the MIT software license +#![allow(non_camel_case_types)] + use std::ops::Deref; use std::str::FromStr; use std::sync::Arc; @@ -472,12 +474,12 @@ pub enum TagEnum { kind: TagKind, data: Vec, }, - Event { + EventTag { event_id: Arc, relay_url: Option, marker: Option, }, - PublicKey { + PublicKeyTag { public_key: Arc, relay_url: Option, alias: Option, @@ -499,7 +501,7 @@ pub enum TagEnum { Reference { reference: String, }, - RelayMetadata { + RelayMetadataTag { relay_url: String, rw: Option, }, @@ -512,7 +514,7 @@ pub enum TagEnum { Identifier { identifier: String, }, - ExternalIdentity { + ExternalIdentityTag { identity: Identity, }, A { @@ -584,7 +586,7 @@ pub enum TagEnum { PublishedAt { timestamp: Arc, }, - Url { + UrlTag { url: String, }, MimeType { @@ -622,7 +624,7 @@ pub enum TagEnum { Ends { timestamp: Arc, }, - LiveEventStatus { + LiveEventStatusTag { status: LiveEventStatus, }, CurrentParticipants { @@ -654,7 +656,7 @@ pub enum TagEnum { Request { event: Arc, }, - DataVendingMachineStatus { + DataVendingMachineStatusTag { status: DataVendingMachineStatus, extra_info: Option, }, @@ -671,7 +673,7 @@ impl From for TagEnum { event_id, relay_url, marker, - } => Self::Event { + } => Self::EventTag { event_id: Arc::new(event_id.into()), relay_url: relay_url.map(|u| u.to_string()), marker: marker.map(|m| m.into()), @@ -680,7 +682,7 @@ impl From for TagEnum { public_key, relay_url, alias, - } => Self::PublicKey { + } => Self::PublicKeyTag { public_key: Arc::new(public_key.into()), relay_url: relay_url.map(|u| u.to_string()), alias, @@ -705,7 +707,7 @@ impl From for TagEnum { proof: proof.map(|p| p.to_string()), }, tag::Tag::Reference(r) => Self::Reference { reference: r }, - tag::Tag::RelayMetadata(url, rw) => Self::RelayMetadata { + tag::Tag::RelayMetadata(url, rw) => Self::RelayMetadataTag { relay_url: url.to_string(), rw: rw.map(|rw| rw.into()), }, @@ -723,7 +725,7 @@ impl From for TagEnum { identifier, relay_url: relay_url.map(|u| u.to_string()), }, - tag::Tag::ExternalIdentity(identity) => Self::ExternalIdentity { + tag::Tag::ExternalIdentity(identity) => Self::ExternalIdentityTag { identity: identity.into(), }, tag::Tag::Relay(url) => Self::RelayUrl { @@ -770,7 +772,7 @@ impl From for TagEnum { tag::Tag::Amount { millisats, bolt11 } => Self::Amount { millisats, bolt11 }, tag::Tag::Name(name) => Self::Name { name }, tag::Tag::Lnurl(lnurl) => Self::Lnurl { lnurl }, - tag::Tag::Url(url) => Self::Url { + tag::Tag::Url(url) => Self::UrlTag { url: url.to_string(), }, tag::Tag::MimeType(mime) => Self::MimeType { mime }, @@ -796,7 +798,7 @@ impl From for TagEnum { tag::Tag::Ends(timestamp) => Self::Ends { timestamp: Arc::new(timestamp.into()), }, - tag::Tag::LiveEventStatus(s) => Self::LiveEventStatus { status: s.into() }, + tag::Tag::LiveEventStatus(s) => Self::LiveEventStatusTag { status: s.into() }, tag::Tag::CurrentParticipants(num) => Self::CurrentParticipants { num }, tag::Tag::TotalParticipants(num) => Self::TotalParticipants { num }, tag::Tag::AbsoluteURL(url) => Self::AbsoluteURL { @@ -821,7 +823,7 @@ impl From for TagEnum { event: Arc::new(event.into()), }, tag::Tag::DataVendingMachineStatus { status, extra_info } => { - Self::DataVendingMachineStatus { + Self::DataVendingMachineStatusTag { status: status.into(), extra_info, } @@ -835,7 +837,7 @@ impl TryFrom for tag::Tag { fn try_from(value: TagEnum) -> Result { match value { TagEnum::Unknown { kind, data } => Ok(Self::Generic(kind.into(), data)), - TagEnum::Event { + TagEnum::EventTag { event_id, relay_url, marker, @@ -844,7 +846,7 @@ impl TryFrom for tag::Tag { relay_url: relay_url.map(UncheckedUrl::from), marker: marker.map(tag::Marker::from), }), - TagEnum::PublicKey { + TagEnum::PublicKeyTag { public_key, relay_url, alias, @@ -874,14 +876,16 @@ impl TryFrom for tag::Tag { }, }), TagEnum::Reference { reference } => Ok(Self::Reference(reference)), - TagEnum::RelayMetadata { relay_url, rw } => Ok(Self::RelayMetadata( + TagEnum::RelayMetadataTag { relay_url, rw } => Ok(Self::RelayMetadata( UncheckedUrl::from(relay_url), rw.map(|rw| rw.into()), )), TagEnum::Hashtag { hashtag } => Ok(Self::Hashtag(hashtag)), TagEnum::Geohash { geohash } => Ok(Self::Geohash(geohash)), TagEnum::Identifier { identifier } => Ok(Self::Identifier(identifier)), - TagEnum::ExternalIdentity { identity } => Ok(Self::ExternalIdentity(identity.into())), + TagEnum::ExternalIdentityTag { identity } => { + Ok(Self::ExternalIdentity(identity.into())) + } TagEnum::A { kind, public_key, @@ -931,7 +935,7 @@ impl TryFrom for tag::Tag { TagEnum::Lnurl { lnurl } => Ok(Self::Lnurl(lnurl)), TagEnum::Name { name } => Ok(Self::Name(name)), TagEnum::PublishedAt { timestamp } => Ok(Self::PublishedAt(**timestamp)), - TagEnum::Url { url } => Ok(Self::Url(Url::parse(&url)?)), + TagEnum::UrlTag { url } => Ok(Self::Url(Url::parse(&url)?)), TagEnum::MimeType { mime } => Ok(Self::MimeType(mime)), TagEnum::Aes256Gcm { key, iv } => Ok(Self::Aes256Gcm { key, iv }), TagEnum::Sha256 { hash } => Ok(Self::Sha256(Sha256Hash::from_str(&hash)?)), @@ -943,7 +947,7 @@ impl TryFrom for tag::Tag { TagEnum::Recording { url } => Ok(Self::Recording(UncheckedUrl::from(url))), TagEnum::Starts { timestamp } => Ok(Self::Starts(**timestamp)), TagEnum::Ends { timestamp } => Ok(Self::Ends(**timestamp)), - TagEnum::LiveEventStatus { status } => Ok(Self::LiveEventStatus(status.into())), + TagEnum::LiveEventStatusTag { status } => Ok(Self::LiveEventStatus(status.into())), TagEnum::CurrentParticipants { num } => Ok(Self::CurrentParticipants(num)), TagEnum::TotalParticipants { num } => Ok(Self::CurrentParticipants(num)), TagEnum::AbsoluteURL { url } => Ok(Self::AbsoluteURL(UncheckedUrl::from(url))), @@ -959,7 +963,7 @@ impl TryFrom for tag::Tag { url: UncheckedUrl::from(url), }), TagEnum::Request { event } => Ok(Self::Request(event.as_ref().deref().clone())), - TagEnum::DataVendingMachineStatus { status, extra_info } => { + TagEnum::DataVendingMachineStatusTag { status, extra_info } => { Ok(Self::DataVendingMachineStatus { status: status.into(), extra_info, diff --git a/bindings/nostr-ffi/src/message/client.rs b/bindings/nostr-ffi/src/message/client.rs index 30bcc8266..00bdc3610 100644 --- a/bindings/nostr-ffi/src/message/client.rs +++ b/bindings/nostr-ffi/src/message/client.rs @@ -13,7 +13,7 @@ use crate::{Event, Filter}; /// Messages sent by clients, received by relays #[derive(Enum)] pub enum ClientMessage { - Event { + EventMsg { event: Arc, }, Req { @@ -52,7 +52,9 @@ pub enum ClientMessage { impl From for nostr::ClientMessage { fn from(value: ClientMessage) -> Self { match value { - ClientMessage::Event { event } => Self::Event(Box::new(event.as_ref().deref().clone())), + ClientMessage::EventMsg { event } => { + Self::Event(Box::new(event.as_ref().deref().clone())) + } ClientMessage::Req { subscription_id, filters, @@ -105,7 +107,7 @@ impl From for nostr::ClientMessage { impl From for ClientMessage { fn from(value: nostr::ClientMessage) -> Self { match value { - nostr::ClientMessage::Event(event) => Self::Event { + nostr::ClientMessage::Event(event) => Self::EventMsg { event: Arc::new(event.as_ref().to_owned().into()), }, nostr::ClientMessage::Req { diff --git a/bindings/nostr-ffi/src/message/relay.rs b/bindings/nostr-ffi/src/message/relay.rs index 3cb4e3ed3..ce3e34d3d 100644 --- a/bindings/nostr-ffi/src/message/relay.rs +++ b/bindings/nostr-ffi/src/message/relay.rs @@ -10,7 +10,7 @@ use crate::{Event, EventId}; #[derive(Enum)] pub enum RelayMessage { - Event { + EventMsg { subscription_id: String, event: Arc, }, @@ -52,7 +52,7 @@ impl From for RelayMessage { nostr::RelayMessage::Event { subscription_id, event, - } => Self::Event { + } => Self::EventMsg { subscription_id: subscription_id.to_string(), event: Arc::new(event.as_ref().clone().into()), },