Skip to main content

Cadet

Struct Cadet 

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

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

Через него открывают порты и каналы. Можно клонировать: копии разделяют одно соединение; оно закрывается вместе с последней копией или по Cadet::close.

Implementations§

Source§

impl Cadet

Source

pub async fn connect( runtime: &GnunetRuntime, config: &Config, ) -> Result<Self, RuntimeError>

Подключается к сервису CADET.

Source

pub async fn channels_for( &self, peer: PeerId, ) -> Result<Vec<CadetChannelInfo>, CadetError>

Каналы между собственным узлом и узлом peer. Средство диагностики.

Source

pub async fn list_peers(&self) -> Result<Vec<CadetPeerInfo>, CadetError>

Узлы, известные CADET. Средство диагностики.

Source

pub async fn paths_to( &self, peer: PeerId, ) -> Result<Vec<CadetPathInfo>, CadetError>

Известные пути к узлу. Средство диагностики.

Source

pub async fn list_tunnels(&self) -> Result<Vec<CadetTunnelInfo>, CadetError>

Действующие туннели. Средство диагностики.

Source

pub async fn open_channel( &self, destination: PeerId, port: CadetPort, router: CadetMessageRouter, ) -> Result<Channel, CadetError>

Открывает канал к порту port узла destination; входящие сообщения разбирает router.

Возвращается, когда канал готов к отправке, то есть окно отправки стало положительным. Пока путь к узлу не найден, вызов ждёт; ожидание стоит ограничивать тайм-аутом. Если Future уничтожен, создание канала отменяется.

Source

pub async fn open_channel_with_options( &self, destination: PeerId, port: CadetPort, router: CadetMessageRouter, options: CadetQueueOptions, ) -> Result<Channel, CadetError>

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

Source

pub async fn open_channel_messages( &self, destination: PeerId, port: CadetPort, message_types: &[MessageType], options: CadetQueueOptions, ) -> Result<Channel, CadetError>

Открывает канал, входящие сообщения которого читаются потоком.

message_types — типы, которые канал принимает. Поток забирают из канала через Channel::take_messages. Уничтожение потока закрывает канал.

Source

pub fn open_port( &self, port: CadetPort, router: CadetMessageRouter, ) -> Result<PortListener, CadetError>

Блокирующий вариант open_port_async, оставлен для совместимости: останавливает вызывающий поток до открытия порта.

Source

pub async fn open_port_async( &self, port: CadetPort, router: CadetMessageRouter, ) -> Result<PortListener, CadetError>

Открывает порт: начинает принимать входящие каналы. Сообщения в них разбирает router.

Source

pub async fn open_port_with_options( &self, port: CadetPort, router: CadetMessageRouter, options: CadetQueueOptions, ) -> Result<PortListener, CadetError>

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

Source

pub async fn open_port_messages( &self, port: CadetPort, message_types: &[MessageType], options: CadetQueueOptions, ) -> Result<PortListener, CadetError>

Открывает порт, входящие каналы которого отдают сообщения потоком (см. Channel::take_messages). message_types — типы, которые каналы принимают.

Source

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

Закрывает соединение со всеми его каналами и портами, включая принадлежащие копиям.

Trait Implementations§

Source§

impl Clone for Cadet

Source§

fn clone(&self) -> Cadet

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 Cadet

§

impl !UnwindSafe for Cadet

§

impl Freeze for Cadet

§

impl Send for Cadet

§

impl Sync for Cadet

§

impl Unpin for Cadet

§

impl UnsafeUnpin for Cadet

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.