Skip to main content

Dht

Struct Dht 

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

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

При уничтожении соединение закрывается, а все его поиски и наблюдения останавливаются.

Implementations§

Source§

impl Dht

Source

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

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

Source

pub async fn connect_with_table_size( runtime: &GnunetRuntime, config: &Config, table_size: u32, ) -> Result<Self, DhtError>

То же, что connect, с указанием начального размера таблицы активных запросов в клиентской библиотеке GNUnet. Имеет смысл только при очень большом числе одновременных поисков.

Source

pub async fn put( &self, key: HashCode, block_type: BlockType, data: &[u8], options: DhtPutOptions, ) -> Result<(), DhtError>

Сохраняет блок в сети.

Возвращается, когда запрос передан сервису либо соединение с ним потеряно: GNUnet эти случаи не различает и сохранение в сети не подтверждает.

Source

pub async fn get( &self, block_type: BlockType, key: HashCode, options: DhtGetOptions, ) -> Result<DhtGet, DhtError>

Начинает поиск блоков типа block_type по ключу key.

Результаты приходят, пока поток не закрыт: об окончании поиска DHT не сообщает.

Source

pub async fn monitor( &self, block_type: BlockType, key: Option<HashCode>, options: DhtMonitorOptions, ) -> Result<DhtMonitor, DhtError>

Наблюдает запросы и блоки, проходящие через собственный узел.

key = None означает все ключи, BlockType::ANY — все типы.

Source

pub async fn hello_get(&self) -> Result<Option<String>, DhtError>

Запрашивает HELLO собственного узла в виде URL; None, если у сервиса его нет.

После переподключения к сервису запрос не повторяется: ожидание нужно ограничивать своим тайм-аутом.

Source

pub async fn hello_offer(&self, url: &str) -> Result<(), DhtError>

Передаёт сервису HELLO другого узла в виде URL, чтобы DHT попыталась с ним связаться.

Возвращается после передачи сообщения сервису; принял ли тот адрес, GNUnet не сообщает.

Source

pub async fn path_to_string( &self, path: &[DhtPathElement], ) -> Result<String, DhtError>

Текстовое представление пути для журнала.

Source

pub async fn verify_path( &self, result: &DhtResult, me: PeerId, ) -> Result<usize, DhtError>

Проверяет подписи пути результата от конца к началу; me — идентификатор собственного узла.

Возвращает 0, если все подписи верны; иначе индекс последнего верного элемента либо общую длину пути, если не верна ни одна. Подпись последнего шага не проверяется.

Source

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

Дожидается локального отключения. Все GET, monitor и незавершённые операции этого соединения останавливаются.

Trait Implementations§

Source§

impl Drop for Dht

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§

§

impl !RefUnwindSafe for Dht

§

impl !UnwindSafe for Dht

§

impl Freeze for Dht

§

impl Send for Dht

§

impl Sync for Dht

§

impl Unpin for Dht

§

impl UnsafeUnpin for Dht

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.