Skip to content

Commit eb206ad

Browse files
committed
implement Io::uuid in terms of Io::thread_rng
1 parent 0292e1e commit eb206ad

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

libsql-wal/src/io/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ pub trait Io: Send + Sync + 'static {
3030
// todo: create an async counterpart
3131
fn tempfile(&self) -> io::Result<Self::TempFile>;
3232
fn now(&self) -> DateTime<Utc>;
33-
fn uuid(&self) -> Uuid;
3433
fn hard_link(&self, src: &Path, dst: &Path) -> io::Result<()>;
3534
fn with_rng<F, R>(&self, f: F) -> R
3635
where
3736
F: FnOnce(&mut Self::Rng) -> R;
37+
fn uuid(&self) -> uuid::Uuid {
38+
self.with_rng(|rng| {
39+
let n: u128 = rng.gen();
40+
Uuid::from_u128(n)
41+
})
42+
}
3843
}
3944

4045
#[derive(Default, Debug, Clone, Copy)]

0 commit comments

Comments
 (0)