feat(API): SupplyKeypair endpoint

This commit is contained in:
Karolin Varner
2024-08-11 00:47:27 +02:00
parent 7a31b57227
commit edf1e774c1
14 changed files with 570 additions and 7 deletions

View File

@@ -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(())
}
}