sheave_core/handlers/
stream_got_exhausted.rs

1use std::{
2    error::Error,
3    fmt::{
4        Display,
5        Formatter,
6        Result as FormatResult
7    },
8    io::{
9        Error as IOError,
10        ErrorKind
11    }
12};
13
14/// An error that stream has no data to write.
15///
16/// Note this is currently used as to mean sucessful termination.
17#[derive(Debug)]
18pub struct StreamGotExhausted;
19
20impl Display for StreamGotExhausted {
21    fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
22        writeln!(f, "Stream got exhausted.")
23    }
24}
25
26impl Error for StreamGotExhausted {}
27
28/// A utility function of constructing an `StreamGotExhausted` error.
29pub fn stream_got_exhausted() -> IOError {
30    IOError::new(
31        ErrorKind::Other,
32        StreamGotExhausted
33    )
34}
35