pub struct Cadet { /* private fields */ }Expand description
Соединение с сервисом CADET.
Через него открывают порты и каналы. Можно клонировать: копии
разделяют одно соединение; оно закрывается вместе с последней копией
или по Cadet::close.
Implementations§
Source§impl Cadet
impl Cadet
Sourcepub async fn connect(
runtime: &GnunetRuntime,
config: &Config,
) -> Result<Self, RuntimeError>
pub async fn connect( runtime: &GnunetRuntime, config: &Config, ) -> Result<Self, RuntimeError>
Подключается к сервису CADET.
Sourcepub async fn channels_for(
&self,
peer: PeerId,
) -> Result<Vec<CadetChannelInfo>, CadetError>
pub async fn channels_for( &self, peer: PeerId, ) -> Result<Vec<CadetChannelInfo>, CadetError>
Каналы между собственным узлом и узлом peer. Средство диагностики.
Sourcepub async fn list_peers(&self) -> Result<Vec<CadetPeerInfo>, CadetError>
pub async fn list_peers(&self) -> Result<Vec<CadetPeerInfo>, CadetError>
Узлы, известные CADET. Средство диагностики.
Sourcepub async fn paths_to(
&self,
peer: PeerId,
) -> Result<Vec<CadetPathInfo>, CadetError>
pub async fn paths_to( &self, peer: PeerId, ) -> Result<Vec<CadetPathInfo>, CadetError>
Известные пути к узлу. Средство диагностики.
Sourcepub async fn list_tunnels(&self) -> Result<Vec<CadetTunnelInfo>, CadetError>
pub async fn list_tunnels(&self) -> Result<Vec<CadetTunnelInfo>, CadetError>
Действующие туннели. Средство диагностики.
Sourcepub async fn open_channel(
&self,
destination: PeerId,
port: CadetPort,
router: CadetMessageRouter,
) -> Result<Channel, CadetError>
pub async fn open_channel( &self, destination: PeerId, port: CadetPort, router: CadetMessageRouter, ) -> Result<Channel, CadetError>
Открывает канал к порту port узла destination; входящие сообщения
разбирает router.
Возвращается, когда канал готов к отправке, то есть окно отправки
стало положительным. Пока путь к узлу не найден, вызов ждёт; ожидание
стоит ограничивать тайм-аутом. Если Future уничтожен, создание канала
отменяется.
Sourcepub async fn open_channel_with_options(
&self,
destination: PeerId,
port: CadetPort,
router: CadetMessageRouter,
options: CadetQueueOptions,
) -> Result<Channel, CadetError>
pub async fn open_channel_with_options( &self, destination: PeerId, port: CadetPort, router: CadetMessageRouter, options: CadetQueueOptions, ) -> Result<Channel, CadetError>
То же, что open_channel, с явными
ограничениями очереди сообщений.
Sourcepub async fn open_channel_messages(
&self,
destination: PeerId,
port: CadetPort,
message_types: &[MessageType],
options: CadetQueueOptions,
) -> Result<Channel, CadetError>
pub async fn open_channel_messages( &self, destination: PeerId, port: CadetPort, message_types: &[MessageType], options: CadetQueueOptions, ) -> Result<Channel, CadetError>
Открывает канал, входящие сообщения которого читаются потоком.
message_types — типы, которые канал принимает. Поток забирают из
канала через Channel::take_messages. Уничтожение потока закрывает
канал.
Sourcepub fn open_port(
&self,
port: CadetPort,
router: CadetMessageRouter,
) -> Result<PortListener, CadetError>
pub fn open_port( &self, port: CadetPort, router: CadetMessageRouter, ) -> Result<PortListener, CadetError>
Блокирующий вариант open_port_async,
оставлен для совместимости: останавливает вызывающий поток до
открытия порта.
Sourcepub async fn open_port_async(
&self,
port: CadetPort,
router: CadetMessageRouter,
) -> Result<PortListener, CadetError>
pub async fn open_port_async( &self, port: CadetPort, router: CadetMessageRouter, ) -> Result<PortListener, CadetError>
Открывает порт: начинает принимать входящие каналы. Сообщения в них
разбирает router.
Sourcepub async fn open_port_with_options(
&self,
port: CadetPort,
router: CadetMessageRouter,
options: CadetQueueOptions,
) -> Result<PortListener, CadetError>
pub async fn open_port_with_options( &self, port: CadetPort, router: CadetMessageRouter, options: CadetQueueOptions, ) -> Result<PortListener, CadetError>
То же, что open_port_async, с явными
ограничениями очередей.
Sourcepub async fn open_port_messages(
&self,
port: CadetPort,
message_types: &[MessageType],
options: CadetQueueOptions,
) -> Result<PortListener, CadetError>
pub async fn open_port_messages( &self, port: CadetPort, message_types: &[MessageType], options: CadetQueueOptions, ) -> Result<PortListener, CadetError>
Открывает порт, входящие каналы которого отдают сообщения потоком
(см. Channel::take_messages). message_types — типы, которые
каналы принимают.
Sourcepub async fn close(self) -> Result<(), CadetError>
pub async fn close(self) -> Result<(), CadetError>
Закрывает соединение со всеми его каналами и портами, включая принадлежащие копиям.