Skip to main content

ax_io/seek/
impls.rs

1#[cfg(feature = "alloc")]
2use alloc::boxed::Box;
3
4use crate::{Result, Seek, SeekFrom};
5
6// =============================================================================
7// Forwarding implementations
8
9impl<S: Seek + ?Sized> Seek for &mut S {
10    #[inline]
11    fn seek(&mut self, pos: SeekFrom) -> Result<u64> {
12        (**self).seek(pos)
13    }
14
15    #[inline]
16    fn rewind(&mut self) -> Result<()> {
17        (**self).rewind()
18    }
19
20    #[inline]
21    fn stream_len(&mut self) -> Result<u64> {
22        (**self).stream_len()
23    }
24
25    #[inline]
26    fn stream_position(&mut self) -> Result<u64> {
27        (**self).stream_position()
28    }
29
30    #[inline]
31    fn seek_relative(&mut self, offset: i64) -> Result<()> {
32        (**self).seek_relative(offset)
33    }
34}
35
36#[cfg(feature = "alloc")]
37impl<S: Seek + ?Sized> Seek for Box<S> {
38    #[inline]
39    fn seek(&mut self, pos: SeekFrom) -> Result<u64> {
40        (**self).seek(pos)
41    }
42
43    #[inline]
44    fn rewind(&mut self) -> Result<()> {
45        (**self).rewind()
46    }
47
48    #[inline]
49    fn stream_len(&mut self) -> Result<u64> {
50        (**self).stream_len()
51    }
52
53    #[inline]
54    fn stream_position(&mut self) -> Result<u64> {
55        (**self).stream_position()
56    }
57
58    #[inline]
59    fn seek_relative(&mut self, offset: i64) -> Result<()> {
60        (**self).seek_relative(offset)
61    }
62}