pub struct Core { /* private fields */ }Expand description
Соединение с сервисом CORE.
Держит в памяти список соседей и рассылает события об его изменениях. Можно клонировать: копии разделяют одно соединение.
Implementations§
Source§impl Core
impl Core
Sourcepub async fn connect_with_options(
runtime: &GnunetRuntime,
config: &Config,
router: MessageRouter,
options: CoreQueueOptions,
) -> Result<Self, CoreError>
pub async fn connect_with_options( runtime: &GnunetRuntime, config: &Config, router: MessageRouter, options: CoreQueueOptions, ) -> Result<Self, CoreError>
То же, что connect, с явными ограничениями очереди
входящих сообщений.
Sourcepub async fn connect_messages(
runtime: &GnunetRuntime,
config: &Config,
message_types: &[MessageType],
options: CoreQueueOptions,
) -> Result<(Self, CoreMessages), CoreError>
pub async fn connect_messages( runtime: &GnunetRuntime, config: &Config, message_types: &[MessageType], options: CoreQueueOptions, ) -> Result<(Self, CoreMessages), CoreError>
Подключается к CORE и возвращает входящие сообщения потоком.
message_types — типы, которые клиент хочет получать. Каждое
сообщение приходит копией вместе с идентификатором отправителя.
Sourcepub async fn connect_messages_with_service(
runtime: &GnunetRuntime,
config: &Config,
message_types: &[MessageType],
options: CoreQueueOptions,
service: CoreServiceInfo,
) -> Result<(Self, CoreMessages), CoreError>
pub async fn connect_messages_with_service( runtime: &GnunetRuntime, config: &Config, message_types: &[MessageType], options: CoreQueueOptions, service: CoreServiceInfo, ) -> Result<(Self, CoreMessages), CoreError>
То же, что connect_messages, с указанием
сведений о службе, которые CORE сообщает соседям.
Sourcepub fn receive_status(&self) -> Receiver<CoreReceiveStatus>
pub fn receive_status(&self) -> Receiver<CoreReceiveStatus>
Приёмник watch с состоянием приёма сообщений.
Sourcepub async fn close(self) -> Result<(), RuntimeError>
pub async fn close(self) -> Result<(), RuntimeError>
Закрывает соединение, у всех копий сразу.
Sourcepub fn peer_events_results(
&self,
) -> impl Stream<Item = Result<PeerEvent, CoreError>> + '_
pub fn peer_events_results( &self, ) -> impl Stream<Item = Result<PeerEvent, CoreError>> + '_
События о соседях в виде потока Result: пропуск событий отставшим
читателем виден как CoreError::EventsLagged.
Sourcepub fn my_identity(&self) -> PeerId
pub fn my_identity(&self) -> PeerId
Идентификатор собственного узла.
Sourcepub fn connected_peer_info(&self) -> Vec<CorePeerInfo>
pub fn connected_peer_info(&self) -> Vec<CorePeerInfo>
Текущий список соседей вместе с их классом.
Sourcepub fn connected_peers(&self) -> Vec<PeerId>
pub fn connected_peers(&self) -> Vec<PeerId>
Текущий список соседей. GNUnet 0.29 включает в него и собственный узел.
Sourcepub fn is_peer_connected(&self, peer: PeerId) -> bool
pub fn is_peer_connected(&self, peer: PeerId) -> bool
true, если с узлом сейчас есть сессия. Проверяется по локальному
списку, который ведётся по событиям CORE.
Sourcepub fn peer_events(&self) -> impl Stream<Item = PeerEvent> + '_
pub fn peer_events(&self) -> impl Stream<Item = PeerEvent> + '_
События о соседях в виде потока. Если читатель отстаёт, пропущенные
события отбрасываются молча; чтобы узнавать о пропусках, есть
peer_events_results.
Sourcepub async fn send(
&self,
peer: PeerId,
envelope: Envelope,
) -> Result<(), CoreError>
👎Deprecated: use send_accepted() to observe local MQ enqueue
pub async fn send( &self, peer: PeerId, envelope: Envelope, ) -> Result<(), CoreError>
use send_accepted() to observe local MQ enqueue
Устаревшее имя send_accepted.
Sourcepub async fn send_accepted(
&self,
peer: PeerId,
envelope: Envelope,
) -> Result<(), CoreError>
pub async fn send_accepted( &self, peer: PeerId, envelope: Envelope, ) -> Result<(), CoreError>
Отправляет сообщение соседу.
Возвращается, когда сообщение принято в локальную очередь CORE. Это не
подтверждение доставки: его CORE не даёт. Если сессии с узлом нет,
возвращается CoreError::PeerNotConnected.
Sourcepub async fn monitor(
runtime: &GnunetRuntime,
config: &Config,
) -> Result<CoreMonitor, CoreError>
pub async fn monitor( runtime: &GnunetRuntime, config: &Config, ) -> Result<CoreMonitor, CoreError>
Наблюдение за состоянием обмена ключами с соседями: средство диагностики, не требующее обычного соединения с CORE.
Sourcepub async fn monitor_with_options(
runtime: &GnunetRuntime,
config: &Config,
options: CoreQueueOptions,
) -> Result<CoreMonitor, CoreError>
pub async fn monitor_with_options( runtime: &GnunetRuntime, config: &Config, options: CoreQueueOptions, ) -> Result<CoreMonitor, CoreError>
То же, что monitor, с явными ограничениями очереди.
Sourcepub fn connect<'f1, 'f2>() -> CoreConnectBuilder<'f1, 'f2>
pub fn connect<'f1, 'f2>() -> CoreConnectBuilder<'f1, 'f2>
Подключается к CORE. Входящие сообщения разбирают обработчики,
зарегистрированные в router; типы сообщений берутся из него же.
Обработчики выполняются в задаче tokio, а не в потоке планировщика GNUnet.