Made some progress towards effectful programs

This commit is contained in:
2026-04-18 13:25:03 +00:00
parent 286040c3ec
commit 6eed6b9831
7 changed files with 241 additions and 23 deletions

View File

@@ -1,3 +1,4 @@
use std::io;
use std::num::NonZero;
use chrono::{DateTime, Utc};
@@ -58,6 +59,20 @@ pub struct IoError {
pub message: String,
pub kind: IoErrorKind,
}
impl From<io::Error> for IoError {
fn from(value: io::Error) -> Self {
Self {
message: value.to_string(),
kind: match value.kind() {
io::ErrorKind::Interrupted
| io::ErrorKind::BrokenPipe
| io::ErrorKind::NetworkDown
| io::ErrorKind::ConnectionReset => IoErrorKind::Interrupted,
_ => IoErrorKind::Other,
},
}
}
}
#[derive(Clone, Debug, Coding)]
pub enum ReadLimit {
@@ -69,7 +84,9 @@ pub enum ReadLimit {
/// Read all available data from a stream. If the returned vector is empty, the
/// stream has reached its end.
#[derive(Clone, Debug, Coding, Hierarchy)]
pub struct ReadReq(pub ReadLimit);
pub struct ReadReq {
pub limit: ReadLimit,
}
impl Request for ReadReq {
type Response = Result<Vec<u8>, IoError>;
}