1 | //! The following is derived from Rust's |
2 | //! library/std/src/io/mod.rs at revision |
3 | //! dca3f1b786efd27be3b325ed1e01e247aa589c3b. |
4 | |
5 | /// Enumeration of possible methods to seek within an I/O object. |
6 | /// |
7 | /// It is used by the [`seek`] function. |
8 | /// |
9 | /// This is similar to [`std::io::SeekFrom`], however it adds platform-specific |
10 | /// seek options. |
11 | /// |
12 | /// [`seek`]: crate::fs::seek |
13 | #[derive (Copy, PartialEq, Eq, Clone, Debug)] |
14 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
15 | pub enum SeekFrom { |
16 | /// Sets the offset to the provided number of bytes. |
17 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
18 | Start(#[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] u64), |
19 | |
20 | /// Sets the offset to the size of this object plus the specified number of |
21 | /// bytes. |
22 | /// |
23 | /// It is possible to seek beyond the end of an object, but it's an error |
24 | /// to seek before byte 0. |
25 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
26 | End(#[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] i64), |
27 | |
28 | /// Sets the offset to the current position plus the specified number of |
29 | /// bytes. |
30 | /// |
31 | /// It is possible to seek beyond the end of an object, but it's an error |
32 | /// to seek before byte 0. |
33 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
34 | Current(#[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] i64), |
35 | |
36 | /// Sets the offset to the current position plus the specified number of |
37 | /// bytes, plus the distance to the next byte which is not in a hole. |
38 | /// |
39 | /// If the offset is in a hole at the end of the file, the seek will fail |
40 | /// with [`Errno::NXIO`]. |
41 | /// |
42 | /// [`Errno::NXIO`]: crate::io::Errno::NXIO |
43 | #[cfg (any(apple, freebsdlike, linux_kernel, solarish))] |
44 | Data(i64), |
45 | |
46 | /// Sets the offset to the current position plus the specified number of |
47 | /// bytes, plus the distance to the next byte which is in a hole. |
48 | /// |
49 | /// If there is no hole past the offset, it will be set to the end of the |
50 | /// file i.e. there is an implicit hole at the end of any file. |
51 | #[cfg (any(apple, freebsdlike, linux_kernel, solarish))] |
52 | Hole(i64), |
53 | } |
54 | |