Skip to main content

Channel

Struct Channel 

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

Канал CADET до другого узла.

При уничтожении канал закрывается.

Implementations§

Source§

impl Channel

Source

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

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

Source

pub fn take_messages(&mut self) -> Option<CadetMessages>

Забирает поток входящих сообщений. Есть только у каналов, открытых через Cadet::open_channel_messages или пришедших из Cadet::open_port_messages; забрать его можно один раз.

Source

pub fn peer(&self) -> PeerId

Узел на другом конце канала.

Source

pub fn window(&self) -> Receiver<u32>

Приёмник watch с окном отправки: сколько сообщений CADET сейчас готов принять от этого узла. Ноль означает, что получатель не успевает.

Source

pub fn disconnect_events(&self) -> Receiver<bool>

Приёмник watch, который становится true, когда канал разорван другой стороной или сетью.

Source

pub fn is_disconnected(&self) -> bool

true, если канал уже разорван.

Source

pub fn send(&self, envelope: Envelope) -> Result<(), CadetError>

👎Deprecated:

use send_accepted().await to observe local MQ acceptance

Устаревший вариант send_accepted: ставит сообщение в очередь и не сообщает, принято ли оно.

Source

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

Отправляет сообщение. Возвращается, когда оно принято в локальную очередь канала.

Очередь не ограничена: при отправке быстрее, чем канал передаёт, она растёт. Для потока данных лучше подходит send_transmitted. Доставка удалённому приложению не подтверждается.

Source

pub async fn send_transmitted( &self, envelope: Envelope, ) -> Result<(), CadetError>

Отправляет сообщение и ждёт, пока оно действительно передано сервису CADET.

Передача происходит, только когда окно отправки открыто, поэтому отправка по одному сообщению таким способом и есть управление потоком: в локальной очереди ничего не копится. Если канал закрылся раньше, возвращается CadetError::Closed. Уничтожение Future сообщение из очереди не убирает.

Source

pub fn receive_done(&self)

Подтверждает последнее принятое сообщение канала с обработчиками, не дожидаясь возврата из обработчика.

Source

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

Закрывает канал и дожидается, пока это будет сделано.

Trait Implementations§

Source§

impl Drop for Channel

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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, 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.