pub struct ComHub {
pub endpoint: Endpoint,
pub options: ComHubOptions,
pub block_handler: BlockHandler,
pub task_manager: TaskManager,
/* private fields */
}Fields§
§endpoint: Endpointthe runtime endpoint of the hub (@me)
options: ComHubOptionsComHub configuration options
block_handler: BlockHandler§task_manager: TaskManagerImplementations§
Source§impl ComHub
impl ComHub
Sourcepub fn get_metadata(&self) -> ComHubMetadata
pub fn get_metadata(&self) -> ComHubMetadata
Generates metadata about the ComHub, its interfaces and sockets.
Sourcepub fn print_metadata(&self)
pub fn print_metadata(&self)
Prints the ComHub metadata to the log.
Source§impl ComHub
impl ComHub
pub async fn record_trace( &self, endpoint: impl Into<Endpoint>, ) -> Option<NetworkTraceResult>
pub async fn record_trace_with_options( &self, options: TraceOptions, ) -> Option<NetworkTraceResult>
pub async fn record_trace_multiple( &self, endpoints: Vec<impl Into<Endpoint>>, ) -> Vec<NetworkTraceResult>
pub async fn record_trace_multiple_with_options( &self, options: TraceOptions, ) -> Vec<NetworkTraceResult>
Source§impl ComHub
Interface management methods
impl ComHub
Interface management methods
Sourcepub fn register_sync_interface_factory<T: ComInterfaceSyncFactory>(&self)
pub fn register_sync_interface_factory<T: ComInterfaceSyncFactory>(&self)
Registers a new sync interface factory for the given interface type
pub fn register_async_interface_factory<T: ComInterfaceAsyncFactory>(&self)
pub fn register_dyn_interface_factory( &self, interface_type: String, factory: DynInterfaceImplementationFactoryFn, )
Sourcepub fn add_interface_from_configuration(
self: Rc<Self>,
interface_configuration: ComInterfaceConfiguration,
priority: InterfacePriority,
) -> Result<Option<impl Future<Output = Result<(), ()>>>, InterfaceAddError>
pub fn add_interface_from_configuration( self: Rc<Self>, interface_configuration: ComInterfaceConfiguration, priority: InterfacePriority, ) -> Result<Option<impl Future<Output = Result<(), ()>>>, InterfaceAddError>
Adds a new interface to the ComHub based on the provided configuration
Sourcepub async fn create_interface(
self: Rc<Self>,
interface_type: &str,
setup_data: ValueContainer,
priority: InterfacePriority,
) -> Result<(ComInterfaceUUID, Option<impl Future<Output = Result<(), ()>>>), ComInterfaceCreateError>
pub async fn create_interface( self: Rc<Self>, interface_type: &str, setup_data: ValueContainer, priority: InterfacePriority, ) -> Result<(ComInterfaceUUID, Option<impl Future<Output = Result<(), ()>>>), ComInterfaceCreateError>
Creates a new interface of the given type with the provided setup data
Sourcepub async fn create_interface_sync(
self: Rc<Self>,
interface_type: &str,
setup_data: ValueContainer,
priority: InterfacePriority,
) -> Result<(ComInterfaceUUID, Option<impl Future<Output = Result<(), ()>>>), ComInterfaceCreateError>
pub async fn create_interface_sync( self: Rc<Self>, interface_type: &str, setup_data: ValueContainer, priority: InterfacePriority, ) -> Result<(ComInterfaceUUID, Option<impl Future<Output = Result<(), ()>>>), ComInterfaceCreateError>
Creates a new interface of the given type with the provided setup data If the interface does not support sync initialization, an error is returned
pub async fn remove_interface( &self, interface_uuid: ComInterfaceUUID, ) -> Result<(), ()>
pub fn has_interface(&self, interface_uuid: &ComInterfaceUUID) -> bool
Source§impl ComHub
impl ComHub
pub async fn remove_socket( &self, socket_uuid: ComInterfaceSocketUUID, ) -> Result<(), ()>
Source§impl ComHub
impl ComHub
pub fn create( endpoint: impl Into<Endpoint>, incoming_sections_sender: UnboundedSender<IncomingSection>, ) -> (Rc<ComHub>, impl Future<Output = ()>)
Sourcepub fn is_local_endpoint_exact(&self, endpoint: &Endpoint) -> bool
pub fn is_local_endpoint_exact(&self, endpoint: &Endpoint) -> bool
Checks if the given endpoint is the local endpoint, matching instances as well
Sourcepub fn register_incoming_block_interceptor<F>(&self, interceptor: F)
pub fn register_incoming_block_interceptor<F>(&self, interceptor: F)
Register an incoming block interceptor
Sourcepub fn register_outgoing_block_interceptor<F>(&self, interceptor: F)
pub fn register_outgoing_block_interceptor<F>(&self, interceptor: F)
Register an outgoing block interceptor
Sourcepub fn prepare_own_block(&self, block: DXBBlock) -> PrepareOwnBlockResult<'_>
pub fn prepare_own_block(&self, block: DXBBlock) -> PrepareOwnBlockResult<'_>
Prepares an own block for sending by setting sender, timestamp, distance and signing if needed. Will return either synchronously or asynchronously depending on the signature type.
Sourcepub async fn send_own_block_async(
&self,
block: DXBBlock,
) -> Result<(), Vec<Endpoint>>
pub async fn send_own_block_async( &self, block: DXBBlock, ) -> Result<(), Vec<Endpoint>>
Public method to send an outgoing block from this endpoint. Called by the runtime.
Sourcepub fn send_own_block(
&self,
block: DXBBlock,
) -> Result<Option<Vec<Vec<u8>>>, Vec<Endpoint>>
pub fn send_own_block( &self, block: DXBBlock, ) -> Result<Option<Vec<Vec<u8>>>, Vec<Endpoint>>
Sends a block from this endpoint synchronously. If any endpoint can not be reached synchronously, an Err with the list of all endpoints is returned. Otherwise, Ok with optional list of responses is returned.
Sourcepub async fn send_own_block_await_response(
&self,
block: DXBBlock,
options: ResponseOptions,
) -> Vec<Result<Response, ResponseError>>
pub async fn send_own_block_await_response( &self, block: DXBBlock, options: ResponseOptions, ) -> Vec<Result<Response, ResponseError>>
Sends a block and wait for a response block. Fix number of exact endpoints -> Expected responses are known at send time. TODO #189: make sure that mutating blocks are always send to specific endpoint instances (@jonas/0001), not generic endpoints like @jonas. @jonas -> response comes from a specific instance of @jonas/0001
Sourcepub async fn send_block_async(
&self,
block: DXBBlock,
exclude_sockets: Vec<ComInterfaceSocketUUID>,
forked: bool,
) -> Result<(), Vec<Endpoint>>
pub async fn send_block_async( &self, block: DXBBlock, exclude_sockets: Vec<ComInterfaceSocketUUID>, forked: bool, ) -> Result<(), Vec<Endpoint>>
Sends a block to all endpoints specified in the block header.
Awaits the result if any block was sent via an async interface.
See send_block for details.
Sourcepub fn send_block(
&self,
block: DXBBlock,
exclude_sockets: Vec<ComInterfaceSocketUUID>,
forked: bool,
) -> BlockSendSyncOrAsyncResult<impl Future<Output = Result<(), Vec<Endpoint>>>>
pub fn send_block( &self, block: DXBBlock, exclude_sockets: Vec<ComInterfaceSocketUUID>, forked: bool, ) -> BlockSendSyncOrAsyncResult<impl Future<Output = Result<(), Vec<Endpoint>>>>
Sends a block to all endpoints specified in the block header. The routing algorithm decides which sockets are used to send the block, based on the endpoint. A block can be sent to multiple endpoints at the same time over a socket or to multiple sockets for each endpoint. The original_socket parameter is used to prevent sending the block back to the sender. When this method is called, the block is queued in the send queue. Returns a SyncOrAsyncResult:
- if all blocks were sent via sync interfaces, returns Sync with Ok containing an optional vector of received blocks (if any), or Err with a list of unreachable endpoints
- if any block was sent via an async interface, returns Async with a Future that resolves to Ok(()) or Err with a list of unreachable endpoints
Sourcepub async fn send_hello_block(
&self,
socket_uuid: ComInterfaceSocketUUID,
) -> Result<(), SendFailure>
pub async fn send_hello_block( &self, socket_uuid: ComInterfaceSocketUUID, ) -> Result<(), SendFailure>
Sends a hello block via the specified socket. Returns Ok(()) if the block was sent successfully, or Err(SendFailure) if sending failed.
pub fn clear_endpoint_blacklist(&self)
pub fn interfaces_manager(&self) -> &ComInterfaceManager
pub fn socket_manager(&self) -> &ComInterfaceSocketManager
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ComHub
impl !RefUnwindSafe for ComHub
impl !Send for ComHub
impl !Sync for ComHub
impl Unpin for ComHub
impl UnsafeUnpin for ComHub
impl !UnwindSafe for ComHub
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> 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