Skip to main content

Core

Struct Core 

Source
pub struct Core { /* private fields */ }
Expand description

Соединение с сервисом CORE.

Держит в памяти список соседей и рассылает события об его изменениях. Можно клонировать: копии разделяют одно соединение.

Implementations§

Source§

impl Core

Source

pub async fn connect_with_options( runtime: &GnunetRuntime, config: &Config, router: MessageRouter, options: CoreQueueOptions, ) -> Result<Self, CoreError>

То же, что connect, с явными ограничениями очереди входящих сообщений.

Source

pub async fn connect_messages( runtime: &GnunetRuntime, config: &Config, message_types: &[MessageType], options: CoreQueueOptions, ) -> Result<(Self, CoreMessages), CoreError>

Подключается к CORE и возвращает входящие сообщения потоком.

message_types — типы, которые клиент хочет получать. Каждое сообщение приходит копией вместе с идентификатором отправителя.

Source

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 сообщает соседям.

Source

pub fn receive_status(&self) -> Receiver<CoreReceiveStatus>

Приёмник watch с состоянием приёма сообщений.

Source

pub async fn close(self) -> Result<(), RuntimeError>

Закрывает соединение, у всех копий сразу.

Source

pub fn peer_events_results( &self, ) -> impl Stream<Item = Result<PeerEvent, CoreError>> + '_

События о соседях в виде потока Result: пропуск событий отставшим читателем виден как CoreError::EventsLagged.

Source

pub fn my_identity(&self) -> PeerId

Идентификатор собственного узла.

Source

pub fn connected_peer_info(&self) -> Vec<CorePeerInfo>

Текущий список соседей вместе с их классом.

Source

pub fn connected_peers(&self) -> Vec<PeerId>

Текущий список соседей. GNUnet 0.29 включает в него и собственный узел.

Source

pub fn is_peer_connected(&self, peer: PeerId) -> bool

true, если с узлом сейчас есть сессия. Проверяется по локальному списку, который ведётся по событиям CORE.

Source

pub fn peer_events(&self) -> impl Stream<Item = PeerEvent> + '_

События о соседях в виде потока. Если читатель отстаёт, пропущенные события отбрасываются молча; чтобы узнавать о пропусках, есть peer_events_results.

Source

pub async fn send( &self, peer: PeerId, envelope: Envelope, ) -> Result<(), CoreError>

👎Deprecated:

use send_accepted() to observe local MQ enqueue

Устаревшее имя send_accepted.

Source

pub async fn send_accepted( &self, peer: PeerId, envelope: Envelope, ) -> Result<(), CoreError>

Отправляет сообщение соседу.

Возвращается, когда сообщение принято в локальную очередь CORE. Это не подтверждение доставки: его CORE не даёт. Если сессии с узлом нет, возвращается CoreError::PeerNotConnected.

Source

pub async fn monitor( runtime: &GnunetRuntime, config: &Config, ) -> Result<CoreMonitor, CoreError>

Наблюдение за состоянием обмена ключами с соседями: средство диагностики, не требующее обычного соединения с CORE.

Source

pub async fn monitor_with_options( runtime: &GnunetRuntime, config: &Config, options: CoreQueueOptions, ) -> Result<CoreMonitor, CoreError>

То же, что monitor, с явными ограничениями очереди.

Source

pub fn connect<'f1, 'f2>() -> CoreConnectBuilder<'f1, 'f2>

Подключается к CORE. Входящие сообщения разбирают обработчики, зарегистрированные в router; типы сообщений берутся из него же.

Обработчики выполняются в задаче tokio, а не в потоке планировщика GNUnet.

Trait Implementations§

Source§

impl Clone for Core

Source§

fn clone(&self) -> Core

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Core

§

impl !UnwindSafe for Core

§

impl Freeze for Core

§

impl Send for Core

§

impl Sync for Core

§

impl Unpin for Core

§

impl UnsafeUnpin for Core

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.