Skip to main content

Namestore

Struct Namestore 

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

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

При уничтожении соединение закрывается, незавершённые операции и обходы отменяются.

Implementations§

Source§

impl Namestore

Source

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

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

Source

pub async fn store( &self, zone: &PrivateKey, label: &str, records: &[GnsRecord], ) -> Result<(), NamestoreError>

Заменяет набор записей метки. Пустой набор удаляет метку.

Source

pub async fn store_many( &self, zone: &PrivateKey, sets: &[(String, Vec<GnsRecord>)], ) -> Result<usize, NamestoreError>

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

Source

pub async fn lookup( &self, zone: &PrivateKey, label: &str, filter: RecordFilter, ) -> Result<Vec<GnsRecord>, NamestoreError>

Записи метки; пустой список, если метки нет.

Source

pub async fn zone_to_name( &self, zone: &PrivateKey, target: &PublicKey, ) -> Result<Option<(String, Vec<GnsRecord>)>, NamestoreError>

Ищет в zone метку, делегирующую зоне target: возвращает метку и её записи.

Выполняется обходом зоны, поэтому время работы растёт с числом меток. Предназначенная для этого функция клиентской библиотеки GNUnet 0.29 аварийно завершает процесс, когда делегирования нет, и не используется.

Source

pub async fn edit_begin( &self, zone: &PrivateKey, label: &str, editor_hint: &str, ) -> Result<RecordSetEdit, NamestoreError>

Ставит на метку рекомендательную блокировку с подсказкой editor_hint и возвращает текущие записи.

Блокировка никому не мешает писать: это способ сообщить другим редакторам, что метку сейчас правят. Если подсказка уже стояла и отличается от переданной, она возвращается в RecordSetEdit::previous_editor_hint.

Если связь с сервисом пропадёт до ответа, клиентская библиотека GNUnet отбросит запрос, никого не уведомив: ожидание нужно ограничивать своим тайм-аутом.

Source

pub async fn edit_cancel( &self, zone: &PrivateKey, label: &str, editor_hint: &str, replacement: &str, ) -> Result<(), NamestoreError>

Заменяет блокировку editor_hint, если она всё ещё стоит, на replacement.

Замена должна иметь ту же длину, что и текущая подсказка, иначе возвращается NamestoreError::ReplacementLength: сервис GNUnet 0.29 при разной длине разрывает соединение. Снять блокировку пустой строкой из-за этого нельзя.

Source

pub async fn zone_iterate( &self, zone: Option<&PrivateKey>, options: ZoneStreamOptions, ) -> Result<ZoneIteration, NamestoreError>

Обходит наборы записей зоны; zone = None означает все зоны. Поток заканчивается после последнего набора.

Source

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

Дожидается локального отключения; незавершённые операции и обходы этого соединения отменяются.

Trait Implementations§

Source§

impl Drop for Namestore

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.