Skip to main content

Pils

Struct Pils 

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

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

Незавершённые запросы клиентская библиотека GNUnet сама повторяет после переподключения; уничтожение Future отменяет запрос. Если сервис недоступен, запрос ждёт неограниченно.

Implementations§

Source§

impl Pils

Source

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

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

Source

pub fn identity_changes(&self) -> Receiver<Option<PilsIdentity>>

Приёмник watch с последним известным идентификатором и его изменениями. None, пока сервис не сообщил первый.

Source

pub async fn identity(&self) -> Result<Option<PeerId>, PilsError>

Текущий идентификатор узла; None, пока он неизвестен.

Source

pub async fn identity_hash(&self) -> Result<Option<HashCode>, PilsError>

Хеш текущего идентификатора; None, пока он неизвестен.

Source

pub async fn sign( &self, purpose: u32, payload: &[u8], ) -> Result<(PeerId, PeerSignature), PilsError>

Подписывает данные ключом узла.

purpose — назначение подписи: число, которое не даёт выдать подпись, сделанную для одного протокола, за подпись для другого. Возвращается и идентификатор, которым сделана подпись: он может смениться между запросом и ответом.

Source

pub async fn sign_hello( &self, addresses: &[&str], expiration: SystemTime, ) -> Result<(PeerId, PeerSignature), PilsError>

Подписывает HELLO с данными адресами и сроком действия.

Source

pub async fn kem_decaps( &self, encapsulation: &[u8; 32], ) -> Result<[u8; 32], PilsError>

Восстанавливает общий секрет из инкапсуляции KEM ключом узла.

Source

pub async fn ecdh(&self, public: &[u8; 32]) -> Result<HashCode, PilsError>

Выполняет ECDH между ключом узла и открытым ключом public.

Source

pub async fn feed_addresses(&self, addresses: &[&str]) -> Result<(), PilsError>

Сообщает сервису новый набор адресов узла; сервис отвечает обновлением идентификатора с этими адресами.

Это операция транспортного уровня: работающий TRANSPORT подаёт свои адреса сам и заменит поданные здесь.

Если GNUnet собран с HELLO_DETERMINISTIC_PID_DERIVATION, ключ узла выводится из набора адресов и идентификатор при этом меняется. В проверенной сборке флаг выключен: идентификатор остаётся прежним.

Source

pub fn hash_addresses(addresses: &[&str]) -> Result<HashCode, PilsError>

Хеш набора адресов, как его считает PILS.

Source

pub fn derive_key( seed_key: &[u8], addresses_hash: &HashCode, ) -> Option<PeerPrivateKey>

Выводит ключ узла из главного ключа и хеша адресов. None для пустого главного ключа.

Source

pub async fn enable_private_key(&self) -> Result<(), PilsError>

Загружает главный ключ узла из файла, указанного в [PEER] PRIVATE_KEY, чтобы клиент мог сам выводить закрытый ключ. Требует доступа к файлу ключа.

Source

pub async fn private_key(&self) -> Result<Option<PeerPrivateKey>, PilsError>

Закрытый ключ текущего идентификатора.

None, если enable_private_key не вызывался, идентификатор ещё неизвестен или ключ из файла ему не соответствует.

Source

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

Отменяет незавершённые запросы и дожидается закрытия соединения.

Trait Implementations§

Source§

impl Drop for Pils

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 Pils

§

impl !UnwindSafe for Pils

§

impl Freeze for Pils

§

impl Send for Pils

§

impl Sync for Pils

§

impl Unpin for Pils

§

impl UnsafeUnpin for Pils

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.