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`] trait. |
8 | /// |
9 | /// [`Seek`]: std::io::Seek |
10 | #[derive (Copy, PartialEq, Eq, Clone, Debug)] |
11 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
12 | pub enum SeekFrom { |
13 | /// Sets the offset to the provided number of bytes. |
14 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
15 | Start(#[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] u64), |
16 | |
17 | /// Sets the offset to the size of this object plus the specified number of |
18 | /// bytes. |
19 | /// |
20 | /// It is possible to seek beyond the end of an object, but it's an error |
21 | /// to seek before byte 0. |
22 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
23 | End(#[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] i64), |
24 | |
25 | /// Sets the offset to the current position plus the specified number of |
26 | /// bytes. |
27 | /// |
28 | /// It is possible to seek beyond the end of an object, but it's an error |
29 | /// to seek before byte 0. |
30 | #[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] |
31 | Current(#[cfg_attr (staged_api, stable(feature = "rust1" , since = "1.0.0" ))] i64), |
32 | |
33 | /// Sets the offset to the current position plus the specified number of bytes, |
34 | /// plus the distance to the next byte which is not in a hole. |
35 | /// |
36 | /// If the offset is in a hole at the end of the file, the seek will produce |
37 | /// an `NXIO` error. |
38 | #[cfg (any(freebsdlike, target_os = "linux" , target_os = "solaris" ))] |
39 | Data(i64), |
40 | |
41 | /// Sets the offset to the current position plus the specified number of bytes, |
42 | /// plus the distance to the next byte which is in a hole. |
43 | /// |
44 | /// If there is no hole past the offset, it will be set to the end of the file |
45 | /// i.e. there is an implicit hole at the end of any file. |
46 | #[cfg (any(freebsdlike, target_os = "linux" , target_os = "solaris" ))] |
47 | Hole(i64), |
48 | } |
49 | |