Debian Codegraph @

third_party/rust/same-file/src/unknown.rs

raw
1 use std::fs::File;
2 use std::io;
3 use std::path::Path;
4
5 static ERROR_MESSAGE: &str = "same-file is not supported on this platform.";
6 // This implementation is to allow same-file to be compiled on
7 // unsupported platforms in case it was incidentally included
8 // as a transitive, unused dependency
9 #[derive(Debug, Hash)]
10 pub struct Handle;
11
12 impl Eq for Handle {}
13
14 impl PartialEq for Handle {
15 fn eq(&self, _other: &Handle) -> bool {
16 unreachable!(ERROR_MESSAGE);
17 }
18 }
19
20 impl Handle {
21 pub fn from_path<P: AsRef<Path>>(_p: P) -> io::Result<Handle> {
22 error()
23 }
24
25 pub fn from_file(_file: File) -> io::Result<Handle> {
26 error()
27 }
28
29 pub fn stdin() -> io::Result<Handle> {
30 error()
31 }
32
33 pub fn stdout() -> io::Result<Handle> {
34 error()
35 }
36
37 pub fn stderr() -> io::Result<Handle> {
38 error()
39 }
40
41 pub fn as_file(&self) -> &File {
42 unreachable!(ERROR_MESSAGE);
43 }
44
45 pub fn as_file_mut(&self) -> &mut File {
46 unreachable!(ERROR_MESSAGE);
47 }
48 }
49
50 fn error<T>() -> io::Result<T> {
51 Err(io::Error::new(io::ErrorKind::Other, ERROR_MESSAGE))
52 }