io_fs/
error.rs

1//! Filesystem coroutines errors.
2
3use thiserror::Error;
4
5use crate::io::FsIo;
6
7/// Errors that can occur during any filesystem coroutine progression.
8///
9/// Only coroutine misuses should lead to these error variants.
10#[derive(Clone, Debug, Error)]
11pub enum FsError {
12    /// The coroutine input is missing or has already been used.
13    ///
14    /// Occurs when the coroutine is called twice without processing
15    /// I/O requests, which should not happen if the runtime process
16    /// correctly I/O requests.
17    #[error("Missing input: path missing or already consumed")]
18    MissingInput,
19
20    /// The coroutine received an invalid argument.
21    ///
22    /// Occurs when the coroutine receives an I/O response from
23    /// another coroutine, which should not happen if the runtime maps
24    /// correctly the arguments.
25    #[error("Invalid argument: expected {0}, got {1:?}")]
26    InvalidArgument(&'static str, FsIo),
27}
28
29/// Output emitted after a coroutine finishes its progression.
30#[derive(Clone, Debug)]
31pub enum FsResult<T = ()> {
32    /// The coroutine has successfully terminated its progression.
33    Ok(T),
34
35    /// An error occured during the coroutine progression.
36    Err(FsError),
37
38    /// A filesystem I/O needs to be performed to make the coroutine
39    /// progress.
40    Io(FsIo),
41}