sheave_core/flv/
not_flv_container.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
use std::{
    error::Error,
    fmt::{
        Display,
        Formatter,
        Result as FormatResult
    },
    io::{
        Error as IOError,
        ErrorKind
    }
};

#[derive(Debug)]
pub struct NotFlvContainer(String);

impl Display for NotFlvContainer {
    fn fmt(&self, f: &mut Formatter<'_>) -> FormatResult {
        writeln!(f, "Signature bytes are inconsistent: expected \"FLV\", actual {}.", &self.0)
    }
}

impl Error for NotFlvContainer {}

pub fn not_flv_container<'a>(signature_bytes: &'a [u8]) -> IOError {
    let signature = String::from_utf8(signature_bytes.into()).unwrap();
    IOError::new(
        ErrorKind::InvalidInput,
        NotFlvContainer(signature)
    )
}