Skip to main content

ServerStorage

Struct ServerStorage 

Source
pub struct ServerStorage { /* private fields */ }

Implementations§

Source§

impl ServerStorage

Source

pub fn new() -> Self

Create a new ServerStorage instance

Source

pub fn add_ephemeral_keys( &mut self, journalist_id: Uuid, keys: Vec<SignedKeyBundlePublic>, )

Add ephemeral keys for a journalist

Source

pub fn pop_random_ephemeral_keys<R: RngCore + CryptoRng>( &mut self, journalist_id: Uuid, rng: &mut R, ) -> Option<SignedKeyBundlePublic>

Get a random ephemeral key set for a journalist and remove it from the pool Returns None if no keys are available for this journalist

Note: This method deletes the ephemeral key from storage. The returned key is permanently removed from the journalist’s ephemeral key pool.

Source

pub fn get_all_ephemeral_keys<R: RngCore + CryptoRng>( &mut self, rng: &mut R, ) -> Vec<(Uuid, SignedKeyBundlePublic)>

Get random ephemeral keys for all journalists Returns a vector of (journalist_id, ephemeral_keys) pairs Only includes journalists that have available keys

Note: This method deletes the ephemeral keys from storage. Each call removes the returned keys from the journalist’s ephemeral key pool.

Source

pub fn ephemeral_keys_count(&self, journalist_id: Uuid) -> usize

Check how many ephemeral keys are available for a journalist

Source

pub fn has_ephemeral_keys(&self, journalist_id: Uuid) -> bool

Check if a journalist has any ephemeral keys available

Source

pub fn get_journalists( &self, ) -> &HashMap<Uuid, (VerifyingKey, DHPublicKey, MessagePublicKey, Signature<JournalistLongTermKey>, SignedLongtermPubKeyBytes, Signature<NewsroomOnJournalist>)>

Get all journalists

Source

pub fn add_journalist( &mut self, journalist: Enrollment, newsroom_signature: Signature<NewsroomOnJournalist>, ) -> Uuid

Add a journalist to storage and return the generated UUID

Source

pub fn find_journalist_by_verifying_key( &self, verifying_key: &VerifyingKey, ) -> Option<Uuid>

Find a journalist by their verifying key Returns the journalist ID if found

TODO: Remove?

Source

pub fn get_messages(&self) -> &HashMap<Uuid, Envelope>

Get all messages

Source

pub fn add_message(&mut self, message_id: Uuid, message: Envelope)

Add a message to storage

Trait Implementations§

Source§

impl Default for ServerStorage

Source§

fn default() -> ServerStorage

Returns the “default value” for a type. 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
§

impl<T> Classify for T

§

type Classified = T

§

fn classify(self) -> T

§

impl<T> Classify for T

§

type Classified = T

§

fn classify(self) -> T

§

impl<T> Declassify for T

§

type Declassified = T

§

fn declassify(self) -> T

§

impl<T> Declassify for T

§

type Declassified = T

§

fn declassify(self) -> T

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V