Skip to main content

ComHub

Struct ComHub 

Source
pub struct ComHub {
    pub endpoint: Endpoint,
    pub options: ComHubOptions,
    pub block_handler: BlockHandler,
    pub task_manager: TaskManager,
    /* private fields */
}

Fields§

§endpoint: Endpoint

the runtime endpoint of the hub (@me)

§options: ComHubOptions

ComHub configuration options

§block_handler: BlockHandler§task_manager: TaskManager

Implementations§

Source§

impl ComHub

Source

pub fn get_metadata(&self) -> ComHubMetadata

Generates metadata about the ComHub, its interfaces and sockets.

Source

pub fn print_metadata(&self)

Prints the ComHub metadata to the log.

Source§

impl ComHub

Source

pub async fn record_trace( &self, endpoint: impl Into<Endpoint>, ) -> Option<NetworkTraceResult>

Source

pub async fn record_trace_with_options( &self, options: TraceOptions, ) -> Option<NetworkTraceResult>

Source

pub async fn record_trace_multiple( &self, endpoints: Vec<impl Into<Endpoint>>, ) -> Vec<NetworkTraceResult>

Source

pub async fn record_trace_multiple_with_options( &self, options: TraceOptions, ) -> Vec<NetworkTraceResult>

Source§

impl ComHub

Interface management methods

Source

pub fn register_sync_interface_factory<T: ComInterfaceSyncFactory>(&self)

Registers a new sync interface factory for the given interface type

Source

pub fn register_async_interface_factory<T: ComInterfaceAsyncFactory>(&self)

Source

pub fn register_dyn_interface_factory( &self, interface_type: String, factory: DynInterfaceImplementationFactoryFn, )

Source

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

Source

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

Source

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

Source

pub async fn remove_interface( &self, interface_uuid: ComInterfaceUUID, ) -> Result<(), ()>

Source

pub fn has_interface(&self, interface_uuid: &ComInterfaceUUID) -> bool

Source§

impl ComHub

Source

pub async fn remove_socket( &self, socket_uuid: ComInterfaceSocketUUID, ) -> Result<(), ()>

Source§

impl ComHub

Source

pub fn create( endpoint: impl Into<Endpoint>, incoming_sections_sender: UnboundedSender<IncomingSection>, ) -> (Rc<ComHub>, impl Future<Output = ()>)

Source

pub fn is_local_endpoint_exact(&self, endpoint: &Endpoint) -> bool

Checks if the given endpoint is the local endpoint, matching instances as well

Source

pub fn register_incoming_block_interceptor<F>(&self, interceptor: F)
where F: Fn(&DXBBlock, &ComInterfaceSocketUUID) + 'static,

Register an incoming block interceptor

Source

pub fn register_outgoing_block_interceptor<F>(&self, interceptor: F)
where F: Fn(&DXBBlock, &ComInterfaceSocketUUID, &[Endpoint]) + 'static,

Register an outgoing block interceptor

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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
Source

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.

Source

pub fn clear_endpoint_blacklist(&self)

Source

pub fn interfaces_manager(&self) -> &ComInterfaceManager

Source

pub fn socket_manager(&self) -> &ComInterfaceSocketManager

Trait Implementations§

Source§

impl Debug for ComHub

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.