Skip to main content

PeerStore

Struct PeerStore 

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

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

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

Implementations§

Source§

impl PeerStore

Source

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

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

Source

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

Закрывает соединение у всех копий сразу; незавершённые операции отменяются.

Source

pub async fn store( &self, sub_system: &str, peer: PeerId, key: &str, value: &[u8], expiry: SystemTime, option: StoreOption, ) -> Result<(), PeerStoreError>

Сохраняет запись.

option определяет судьбу прежних записей с той же тройкой «подсистема, узел, ключ»: добавить к ним ещё одну или заменить их.

Source

pub fn iterate( &self, sub_system: &str, peer: Option<PeerId>, key: Option<&str>, ) -> Iteration

Читает записи подсистемы sub_system. peer и key сужают отбор; None означает «любые». Поток заканчивается после последней записи.

Source

pub fn iterate_with_options( &self, sub_system: &str, peer: Option<PeerId>, key: Option<&str>, options: PeerStoreStreamOptions, ) -> Iteration

То же, что iterate, с явными ограничениями очереди. Записи запрашиваются у сервиса порциями: следующая — когда предыдущая прочитана.

Source

pub fn watch( &self, sub_system: &str, peer: Option<PeerId>, key: Option<&str>, ) -> PeerStoreWatch

Читает существующие записи и продолжает следить за изменениями.

Когда исходные записи переданы, поле PeerStoreWatch::synced становится true; дальше приходят только изменения. Поток не заканчивается сам.

Source

pub fn watch_changes( &self, sub_system: &str, peer: Option<PeerId>, key: Option<&str>, ) -> PeerStoreWatch

Следит только за новыми изменениями, без существующих записей.

Source

pub fn watch_with_options( &self, sub_system: &str, peer: Option<PeerId>, key: Option<&str>, options: PeerStoreStreamOptions, ) -> PeerStoreWatch

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

Source

pub fn watch_changes_with_options( &self, sub_system: &str, peer: Option<PeerId>, key: Option<&str>, options: PeerStoreStreamOptions, ) -> PeerStoreWatch

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

Source

pub async fn hello_add(&self, hello: &[u8]) -> Result<(), PeerStoreError>

Добавляет адреса узла из сообщения HELLO в двоичном виде.

Если Future уничтожен до ответа, ожидание отменяется, но запись, уже принятая сервисом, может быть выполнена.

Source

pub async fn hello_add_uri(&self, uri: &str) -> Result<(), PeerStoreError>

Добавляет адреса узла из подписанного HELLO в виде URI (gnunet://hello/…), например полученного от Pils другого узла или команды gnunet-hello.

Trait Implementations§

Source§

impl Clone for PeerStore

Source§

fn clone(&self) -> PeerStore

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§

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.