ouisync/db/
id.rs

1use rand::{
2    distributions::{Distribution, Standard},
3    Rng,
4};
5
6define_byte_array_wrapper! {
7    /// Database ID is a locally public random byte array that can be used by the apps using this
8    /// library to identify the database file. For example, if the app stores passwords externally
9    /// (e.g.  fingerprint biometric) it can do so under the DATABASE_ID as key. Note that the
10    /// RepositoryId could - in theory - also be used for this purpose, but in case the
11    /// database IDs are leaked to an adversary without the actual database files, the adversary
12    /// will not be able to link the DATABASE_ID to a corresponding repository. For that reason
13    /// database IDs may be preferable.
14    pub struct DatabaseId([u8; 16 /* 128 bit */]);
15}
16
17impl Distribution<DatabaseId> for Standard {
18    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> DatabaseId {
19        DatabaseId(self.sample(rng))
20    }
21}