sheave_core/handlers/
stream_got_exhausted.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::{
    error::Error,
    fmt::{
        Display,
        Formatter,
        Result as FormatResult
    },
    io::{
        Error as IOError,
        ErrorKind
    }
};

/// An error that stream has no data to write.
/// Note this is currently used as to mean sucessful termination.
#[derive(Debug)]
pub struct StreamGotExhausted;

impl Display for StreamGotExhausted {
    fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
        writeln!(f, "Stream got exhausted.")
    }
}

impl Error for StreamGotExhausted {}

/// A utility function of constructing an `StreamGotExhausted`
pub fn stream_got_exhausted() -> IOError {
    IOError::new(
        ErrorKind::Other,
        StreamGotExhausted
    )
}