Skip to main content

Datastore

Struct Datastore 

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

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

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

Implementations§

Source§

impl Datastore

Source

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

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

Source

pub async fn reserve( &self, amount: u64, entries: u32, ) -> Result<u32, DatastoreError>

Резервирует место под entries блоков общим объёмом amount байт. Возвращает идентификатор резерва для put и release_reserve.

Source

pub async fn release_reserve( &self, reservation: u32, queue: DatastoreQueue, ) -> Result<(), DatastoreError>

Освобождает резерв, полученный от reserve: место, которое не было занято, возвращается в общую квоту.

Source

pub async fn put( &self, key: HashCode, block_type: BlockType, data: &[u8], options: DatastorePutOptions, queue: DatastoreQueue, ) -> Result<(), DatastoreError>

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

Source

pub async fn remove( &self, key: HashCode, data: &[u8], queue: DatastoreQueue, ) -> Result<bool, DatastoreError>

Удаляет блок с точно таким ключом и содержимым. Ok(false) — блок не найден либо хранилище сообщило об ошибке (сервис их не различает).

Source

pub async fn get_key( &self, next_uid: u64, random: bool, key: Option<HashCode>, block_type: BlockType, queue: DatastoreQueue, ) -> Result<Option<Datum>, DatastoreError>

Один блок с наименьшим uid >= next_uid (или случайный при random). key = None — любой ключ, BlockType::ANY — любой тип. None также возвращается, если связь с сервисом была потеряна.

Source

pub async fn get_zero_anonymity( &self, next_uid: u64, block_type: BlockType, queue: DatastoreQueue, ) -> Result<Option<Datum>, DatastoreError>

Один блок с нулевой анонимностью и uid >= next_uid.

Source

pub async fn get_for_replication( &self, queue: DatastoreQueue, ) -> Result<Option<Datum>, DatastoreError>

Блок, который сервис выбрал для репликации.

Source

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

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

Source

pub async fn close_and_drop_database(self) -> Result<(), DatastoreError>

Отключается и просит сервис уничтожить всё содержимое хранилища. Необратимо.

Trait Implementations§

Source§

impl Drop for Datastore

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.