1use std::path::{Path, PathBuf};
2use std::sync::Arc;
3
4#[derive(Clone, Debug, Eq, Hash, PartialEq)]
6pub enum Content {
7 Bytes(Arc<[u8]>),
8 File(PathBuf),
9}
10
11impl From<Vec<u8>> for Content {
12 fn from(bytes: Vec<u8>) -> Self {
13 Self::Bytes(bytes.into())
14 }
15}
16
17impl From<&[u8]> for Content {
18 fn from(bytes: &[u8]) -> Self {
19 Self::Bytes(bytes.into())
20 }
21}
22
23impl<const N: usize> From<&[u8; N]> for Content {
24 fn from(bytes: &[u8; N]) -> Self {
25 Self::from(bytes.as_slice())
26 }
27}
28
29impl From<PathBuf> for Content {
30 fn from(path: PathBuf) -> Self {
31 Self::File(path)
32 }
33}
34
35impl From<&Path> for Content {
36 fn from(path: &Path) -> Self {
37 Self::File(path.to_owned())
38 }
39}