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§
Sourcefn transport_type(&self) -> &'static str
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.
Sourcefn can_handle_address(&self, address: &Address) -> bool
fn can_handle_address(&self, address: &Address) -> bool
Sourcefn 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 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,
Sourcefn 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 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.
Sourcefn 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 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,
Sourcefn is_server_running(&self) -> bool
fn is_server_running(&self) -> bool
Sourcefn get_server_address(&self) -> Result<String>
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§
Sourcefn 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,
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 toentries- The entries to send
§Returns
A Result indicating whether the entries were successfully acknowledged.