• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ensc / r-tftpd / 6048507855

01 Sep 2023 07:52AM UTC coverage: 55.722% (-0.1%) from 55.834%
6048507855

push

github

ensc
CI: use f38

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>

1305 of 2342 relevant lines covered (55.72%)

162.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.0
/src/fetcher/fetcher.rs
1
#[derive(Debug)]
×
2
pub enum Fetcher {
3
    File(Box<super::File>),
×
4
    Memory(Box<super::Memory>),
×
5
    #[cfg(feature = "proxy")]
6
    Uri(Box<super::Uri>),
×
7
}
8

9
impl Fetcher {
10
    #[instrument(level = "trace")]
72✔
11
    pub fn new_file(path: &std::path::Path) -> Self {
36✔
12
        Self::File(Box::new(super::file::File::new(path)))
36✔
13
    }
14

15
    #[cfg(feature = "proxy")]
16
    #[instrument(level = "trace")]
×
17
    pub fn new_uri(uri: &url::Url) -> Self {
×
18
        Self::Uri(Box::new(super::Uri::new(uri)))
×
19
    }
20

21
    #[cfg(test)]
22
    pub fn new_memory(buf: &[u8]) -> Self {
2✔
23
        Self::Memory(Box::new(super::memory::Memory::new(buf)))
2✔
24
    }
2✔
25

26
    pub fn is_mmaped(&self) -> bool {
42✔
27
        match self {
42✔
28
            Self::File(f)        => f.is_mmaped(),
36✔
29
            Self::Memory(_)        => true,
6✔
30
            #[cfg(feature = "proxy")]
31
            Self::Uri(_)        => false,
×
32
        }
33
    }
42✔
34

35
    #[instrument(level = "trace")]
180✔
36
    pub async fn open(&mut self) -> crate::Result<()> {
72✔
37
        match self {
36✔
38
            Self::File(f)        => f.open(),
36✔
39
            Self::Memory(m)        => m.open(),
×
40
            #[cfg(feature = "proxy")]
41
            Self::Uri(u)        => Ok(u.open().await?),
×
42
        }
43
    }
44

45
    #[instrument(level = "trace", ret)]
252✔
46
    pub async fn get_size(&self) -> Option<u64> {
72✔
47
        match self {
36✔
48
            Self::File(f)        => f.get_size(),
36✔
49
            Self::Memory(m)        => m.get_size(),
×
50
            #[cfg(feature = "proxy")]
51
            Self::Uri(u)        => u.get_size().await,
×
52
        }
53
    }
54

55
    //#[instrument(level = "trace", skip(buf), ret)]
56
    pub async fn read(&mut self, buf: &mut [u8]) -> crate::Result<usize>
2,196✔
57
    {
2,196✔
58
        match self {
1,098✔
59
            Self::File(f)        => f.read(buf).await,
1,098✔
60
            Self::Memory(m)        => m.read(buf).await,
×
61
            #[cfg(feature = "proxy")]
62
            Self::Uri(u)        => Ok(u.read(buf).await?),
×
63
        }
64
    }
2,196✔
65

66
    #[instrument(level = "trace")]
20✔
67
    pub fn read_mmap(&mut self, cnt: usize) -> crate::Result<&[u8]>
10✔
68
    {
69
        match self {
10✔
70
            Self::File(f)        => f.read_mmap(cnt),
×
71
            Self::Memory(m)        => m.read_mmap(cnt),
10✔
72
            #[cfg(feature = "proxy")]
73
            Self::Uri(_)        => unimplemented!(),
×
74
        }
75
    }
76

77
    pub fn is_eof(&self) -> bool
1,109✔
78
    {
79
        match self {
1,109✔
80
            Self::File(f)        => f.is_eof(),
1,098✔
81
            Self::Memory(m)        => m.is_eof(),
11✔
82
            #[cfg(feature = "proxy")]
83
            Self::Uri(u)        => u.is_eof(),
×
84
        }
85
    }
1,109✔
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc