Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

SyncTransport

Trait SyncTransport 

Source
pub trait SyncTransport: Send + Sync {
    // Required methods
    fn transport_type(&self) -> &'static str;
    fn can_handle_address(&self, address: &Address) -> bool;
    fn start_server<'life0, 'async_trait>(
        &'life0 mut self,
        handler: Arc<dyn SyncHandler>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stop_server<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send_request<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        address: &'life1 Address,
        request: &'life2 SyncRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SyncResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn is_server_running(&self) -> bool;
    fn get_server_address(&self) -> Result<String>;

    // Provided method
    fn send_entries<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        address: &'life1 Address,
        entries: &'life2 [Entry],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Trait for implementing sync communication over different transports.

Each transport implementation (HTTP, Iroh, etc.) must implement this trait to provide server and client functionality.

Required Methods§

Source

fn transport_type(&self) -> &'static str

Get the transport type identifier.

This should return a unique string identifying the transport type (e.g., “http”, “iroh”). Used for routing and configuration lookup.

Source

fn can_handle_address(&self, address: &Address) -> bool

Check if this transport can handle the given address

§Arguments
  • address - The address to check
§Returns

True if this transport can handle the address, false otherwise.

Source

fn start_server<'life0, 'async_trait>( &'life0 mut self, handler: Arc<dyn SyncHandler>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start a server with the pre-configured bind address.

The transport uses its bind address configured via the builder.

§Arguments
  • handler - The sync handler to process incoming requests
§Returns

A Result indicating success or failure of server startup.

Source

fn stop_server<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop the running server gracefully.

§Returns

A Result indicating success or failure of server shutdown.

Source

fn send_request<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, address: &'life1 Address, request: &'life2 SyncRequest, ) -> Pin<Box<dyn Future<Output = Result<SyncResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a sync request to a peer and receive a response.

§Arguments
  • address - The address of the peer to connect to
  • request - The sync request to send
§Returns

The response from the peer, or an error if the request failed.

Source

fn is_server_running(&self) -> bool

Check if the server is currently running.

§Returns

True if the server is running, false otherwise.

Source

fn get_server_address(&self) -> Result<String>

Get the address the server is currently bound to.

§Returns

The server address if running, or an error if no server is running. Useful when the server was started with port 0 for dynamic port assignment.

Provided Methods§

Source

fn send_entries<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, address: &'life1 Address, entries: &'life2 [Entry], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send entries to a sync peer and ensure they are acknowledged.

This is a convenience method that wraps send_request and validates the response.

§Arguments
  • address - The address of the peer to connect to
  • entries - The entries to send
§Returns

A Result indicating whether the entries were successfully acknowledged.

Implementors§