@@ -6,13 +6,19 @@ use std::{
66 net:: { IpAddr , Ipv4Addr , Ipv6Addr , SocketAddr } ,
77} ;
88
9+ #[ cfg( feature = "serde" ) ]
10+ use serde:: { Deserialize , Serialize } ;
911use time:: OffsetDateTime ;
12+ #[ cfg( feature = "typescript-bindings" ) ]
13+ use ts_rs:: TS ;
1014
1115use crate :: TunnelType ;
1216
1317// Represents the identity of a gateway
1418#[ derive( Debug , Clone , Eq , PartialEq ) ]
1519#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Record ) ) ]
20+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
21+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
1622pub struct GatewayId {
1723 pub id : String ,
1824}
@@ -32,6 +38,8 @@ impl From<nym_gateway_directory::Gateway> for GatewayId {
3238
3339#[ derive( Clone , Debug , Eq , PartialEq ) ]
3440#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Record ) ) ]
41+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
42+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
3543pub struct EstablishConnectionData {
3644 /// Mixnet entry gateway.
3745 pub entry_gateway : GatewayId ,
@@ -47,6 +55,8 @@ pub struct EstablishConnectionData {
4755/// Describes the current state when establishing connection.
4856#[ derive( Clone , Debug , Eq , PartialEq ) ]
4957#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Enum ) ) ]
58+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
59+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
5060pub enum EstablishConnectionState {
5161 /// Resolving API IP addresses
5262 ResolvingApiAddresses ,
@@ -82,6 +92,8 @@ impl fmt::Display for EstablishConnectionState {
8292
8393#[ derive( Clone , Debug , Eq , PartialEq ) ]
8494#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Record ) ) ]
95+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
96+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
8597pub struct ConnectionData {
8698 /// Mixnet entry gateway.
8799 pub entry_gateway : GatewayId ,
@@ -90,6 +102,8 @@ pub struct ConnectionData {
90102 pub exit_gateway : GatewayId ,
91103
92104 /// When the tunnel connection was last established.
105+ #[ cfg_attr( feature = "typescript-bindings" , ts( as = "String" ) ) ]
106+ #[ cfg_attr( feature = "serde" , serde( with = "time::serde::iso8601" ) ) ]
93107 pub connected_at : OffsetDateTime ,
94108
95109 /// Tunnel connection data.
@@ -98,6 +112,8 @@ pub struct ConnectionData {
98112
99113#[ derive( Debug , Clone , Eq , PartialEq ) ]
100114#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Enum ) ) ]
115+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
116+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
101117pub enum TunnelConnectionData {
102118 Mixnet ( MixnetConnectionData ) ,
103119 Wireguard ( WireguardConnectionData ) ,
@@ -115,6 +131,8 @@ impl TunnelConnectionData {
115131// Represents a nym-address of the form id.enc@gateway
116132#[ derive( Debug , Clone , Eq , PartialEq ) ]
117133#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Record ) ) ]
134+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
135+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
118136pub struct NymAddress {
119137 pub nym_address : String ,
120138 pub gateway_id : String ,
@@ -155,6 +173,8 @@ impl From<nym_gateway_directory::IpPacketRouterAddress> for NymAddress {
155173
156174#[ derive( Debug , Clone , Eq , PartialEq ) ]
157175#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Record ) ) ]
176+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
177+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
158178pub struct MixnetConnectionData {
159179 pub nym_address : NymAddress ,
160180 pub exit_ipr : NymAddress ,
@@ -166,6 +186,8 @@ pub struct MixnetConnectionData {
166186
167187#[ derive( Debug , Clone , Eq , PartialEq ) ]
168188#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Record ) ) ]
189+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
190+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
169191pub struct WireguardConnectionData {
170192 pub entry_bridge_addr : Option < SocketAddr > ,
171193 pub entry : WireguardNode ,
@@ -174,6 +196,8 @@ pub struct WireguardConnectionData {
174196
175197#[ derive( Debug , Clone , Eq , PartialEq ) ]
176198#[ cfg_attr( feature = "uniffi-bindings" , derive( uniffi:: Record ) ) ]
199+ #[ cfg_attr( feature = "typescript-bindings" , derive( TS ) , ts( export) ) ]
200+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
177201pub struct WireguardNode {
178202 pub endpoint : SocketAddr ,
179203 pub public_key : String ,
0 commit comments