pub struct IrohTransportBuilder { /* private fields */ }Expand description
Builder for configuring IrohTransport with different relay modes and options.
§Examples
§Production deployment (default)
use eidetica::sync::transports::iroh::IrohTransport;
let transport = IrohTransport::builder()
.build()?;
// Uses n0's production relay servers by default§Local testing without internet
use eidetica::sync::transports::iroh::IrohTransport;
use iroh::RelayMode;
let transport = IrohTransport::builder()
.relay_mode(RelayMode::Disabled)
.build()?;
// Direct P2P only, no relay servers§Enterprise deployment with custom relay
use eidetica::sync::transports::iroh::IrohTransport;
use iroh::{RelayConfig, RelayMode, RelayMap, RelayUrl};
let relay_url: RelayUrl = "https://relay.example.com".parse()?;
let relay_config: RelayConfig = relay_url.into();
let transport = IrohTransport::builder()
.relay_mode(RelayMode::Custom(RelayMap::from_iter([relay_config])))
.build()?;Implementations§
Source§impl IrohTransportBuilder
impl IrohTransportBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with production defaults.
By default, uses RelayMode::Default which connects to n0’s
production relay infrastructure for NAT traversal.
Sourcepub fn relay_mode(self, mode: RelayMode) -> Self
pub fn relay_mode(self, mode: RelayMode) -> Self
Set the relay mode for the transport.
§Relay Modes
RelayMode::Default- Use n0’s production relay servers (recommended)RelayMode::Staging- Use n0’s staging infrastructure for testingRelayMode::Disabled- No relay servers, direct P2P only (local testing)RelayMode::Custom(RelayMap)- Use custom relay servers (enterprise deployments)
§Example
use eidetica::sync::transports::iroh::IrohTransport;
use iroh::RelayMode;
let transport = IrohTransport::builder()
.relay_mode(RelayMode::Disabled)
.build()?;Sourcepub fn secret_key(self, key: SecretKey) -> Self
pub fn secret_key(self, key: SecretKey) -> Self
Set the secret key for persistent node identity.
When a secret key is provided, the node will have the same cryptographic identity (and thus the same address) across restarts. This is essential for maintaining stable peer connections.
If not set, a random secret key will be generated on each startup, resulting in a different node address each time.
§Example
use eidetica::sync::transports::iroh::IrohTransport;
use iroh::SecretKey;
use rand::RngCore;
// Generate or load secret key from storage
let mut secret_bytes = [0u8; 32];
rand::rngs::OsRng.fill_bytes(&mut secret_bytes);
let secret_key = SecretKey::from_bytes(&secret_bytes);
let transport = IrohTransport::builder()
.secret_key(secret_key)
.build()?;Sourcepub fn build(self) -> Result<IrohTransport>
pub fn build(self) -> Result<IrohTransport>
Build the IrohTransport with the configured options.
Returns a configured IrohTransport ready to be used with
SyncEngine::enable_iroh_transport_with_config().
Trait Implementations§
Source§impl Clone for IrohTransportBuilder
impl Clone for IrohTransportBuilder
Source§fn clone(&self) -> IrohTransportBuilder
fn clone(&self) -> IrohTransportBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IrohTransportBuilder
impl Debug for IrohTransportBuilder
Source§impl Default for IrohTransportBuilder
impl Default for IrohTransportBuilder
Source§impl TransportBuilder for IrohTransportBuilder
impl TransportBuilder for IrohTransportBuilder
Source§fn build<'async_trait>(
self,
persisted: Doc,
) -> Pin<Box<dyn Future<Output = Result<(Self::Transport, Option<Doc>)>> + Send + 'async_trait>>where
Self: 'async_trait,
fn build<'async_trait>(
self,
persisted: Doc,
) -> Pin<Box<dyn Future<Output = Result<(Self::Transport, Option<Doc>)>> + Send + 'async_trait>>where
Self: 'async_trait,
Build the transport using persisted state for identity.
The secret key (node identity) is loaded from the persisted Doc. If no secret key exists, a new one is generated and the Doc is returned for persistence. Any secret_key set via the builder is ignored - persisted state takes precedence.
Source§type Transport = IrohTransport
type Transport = IrohTransport
Auto Trait Implementations§
impl Freeze for IrohTransportBuilder
impl RefUnwindSafe for IrohTransportBuilder
impl Send for IrohTransportBuilder
impl Sync for IrohTransportBuilder
impl Unpin for IrohTransportBuilder
impl UnwindSafe for IrohTransportBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more