1use crate::boxed::Box;
2use crate::io::{self, Seek, SeekFrom, SizeHint};
3#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
4use crate::sync::Arc;
5
6#[doc(hidden)]
10#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
11impl<T> SizeHint for Box<T> {
12 #[inline]
13 fn lower_bound(&self) -> usize {
14 SizeHint::lower_bound(&**self)
15 }
16
17 #[inline]
18 fn upper_bound(&self) -> Option<usize> {
19 SizeHint::upper_bound(&**self)
20 }
21}
22
23#[stable(feature = "rust1", since = "1.0.0")]
24impl<S: Seek + ?Sized> Seek for Box<S> {
25 #[inline]
26 fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
27 (**self).seek(pos)
28 }
29
30 #[inline]
31 fn rewind(&mut self) -> io::Result<()> {
32 (**self).rewind()
33 }
34
35 #[inline]
36 fn stream_len(&mut self) -> io::Result<u64> {
37 (**self).stream_len()
38 }
39
40 #[inline]
41 fn stream_position(&mut self) -> io::Result<u64> {
42 (**self).stream_position()
43 }
44
45 #[inline]
46 fn seek_relative(&mut self, offset: i64) -> io::Result<()> {
47 (**self).seek_relative(offset)
48 }
49}
50
51#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
55#[stable(feature = "io_traits_arc", since = "1.73.0")]
56impl<S: Seek + ?Sized> Seek for Arc<S>
57where
58 for<'a> &'a S: Seek,
59 S: crate::io::IoHandle,
60{
61 #[inline]
62 fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
63 (&**self).seek(pos)
64 }
65
66 #[inline]
67 fn rewind(&mut self) -> io::Result<()> {
68 (&**self).rewind()
69 }
70
71 #[inline]
72 fn stream_len(&mut self) -> io::Result<u64> {
73 (&**self).stream_len()
74 }
75
76 #[inline]
77 fn stream_position(&mut self) -> io::Result<u64> {
78 (&**self).stream_position()
79 }
80
81 #[inline]
82 fn seek_relative(&mut self, offset: i64) -> io::Result<()> {
83 (&**self).seek_relative(offset)
84 }
85}