/ app / lib / src / rust / transport.dart
transport.dart
 1  // This file is automatically generated, so please do not edit it.
 2  // @generated by `flutter_rust_bridge`@ 2.11.1.
 3  
 4  // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
 5  
 6  import 'frb_generated.dart';
 7  import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
 8  
 9  /// A transport-specific address for reaching a peer.
10  ///
11  /// The address format depends on the transport type:
12  ///
13  /// - **BLE**: 16-byte rotating ID derived from shared secret
14  /// - **Tor**: 56-character v3 onion address (without .onion)
15  /// - **DHT**: 32-byte DHT key (typically derived from public key)
16  /// - **I2P**: Base64-encoded I2P destination
17  ///
18  /// # Example
19  ///
20  /// ```
21  /// use rust_lib_dead_drop::transport::{TransportAddress, TransportType};
22  ///
23  /// // Create a BLE address from rotating ID
24  /// let rotating_id = [0u8; 16];
25  /// let ble_addr = TransportAddress::new(TransportType::BLE, rotating_id.to_vec());
26  ///
27  /// // Check the transport type
28  /// assert_eq!(ble_addr.transport_type(), TransportType::BLE);
29  /// ```
30  class TransportAddress {
31    /// The transport protocol for this address.
32    final TransportType transportType;
33  
34    /// The raw address bytes (format depends on transport type).
35    final Uint8List address;
36  
37    const TransportAddress({required this.transportType, required this.address});
38  
39    @override
40    int get hashCode => transportType.hashCode ^ address.hashCode;
41  
42    @override
43    bool operator ==(Object other) =>
44        identical(this, other) ||
45        other is TransportAddress &&
46            runtimeType == other.runtimeType &&
47            transportType == other.transportType &&
48            address == other.address;
49  }
50  
51  /// Supported transport protocols.
52  ///
53  /// Each transport has different characteristics:
54  ///
55  /// | Transport | Latency | Anonymity | Range    | Online Required |
56  /// |-----------|---------|-----------|----------|-----------------|
57  /// | BLE       | Low     | None      | ~100m    | No              |
58  /// | Relay     | Medium  | Low       | Global   | Yes             |
59  /// | Tor       | High    | High      | Global   | Yes             |
60  /// | DHT       | Medium  | Medium    | Global   | Yes             |
61  /// | I2P       | High    | Very High | Global   | Yes             |
62  /// | Iroh      | Low     | Low       | Global   | Yes             |
63  enum TransportType {
64    /// Bluetooth Low Energy - proximity-based messaging.
65    ble,
66  
67    /// Tor onion services - anonymous global messaging.
68    tor,
69  
70    /// Distributed Hash Table - decentralized message storage.
71    dht,
72  
73    /// Invisible Internet Project - anonymous overlay network.
74    i2P,
75  
76    /// Relay server - push-based message delivery.
77    relay,
78  
79    /// Iroh - QUIC-based P2P with NAT traversal via n0 relays.
80    iroh,
81  
82    /// Any available transport (for routing hints).
83    any,
84  }