mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-27 22:13:12 -08:00
feat(API): SupplyKeypair endpoint
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
use std::{borrow::Borrow, io};
|
||||
|
||||
use anyhow::ensure;
|
||||
|
||||
pub trait IoErrorKind {
|
||||
fn io_error_kind(&self) -> io::ErrorKind;
|
||||
}
|
||||
@@ -108,3 +110,21 @@ impl<T: io::Read> ReadNonblockingWithBoringErrorsHandledExt for T {
|
||||
nonblocking_handle_io_errors(|| self.read(buf))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ReadExt {
|
||||
fn read_exact_til_end(&mut self, buf: &mut [u8]) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
impl<T> ReadExt for T
|
||||
where
|
||||
T: std::io::Read,
|
||||
{
|
||||
fn read_exact_til_end(&mut self, buf: &mut [u8]) -> anyhow::Result<()> {
|
||||
self.read_exact(buf)?;
|
||||
ensure!(
|
||||
self.read(&mut [0u8; 8])? == 0,
|
||||
"Read source longer than buffer"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user