Skip to main content

core/io/
mod.rs

1//! Traits, helpers, and type definitions for core I/O functionality.
2
3mod borrowed_buf;
4mod cursor;
5mod error;
6mod impls;
7mod io_slice;
8#[unstable(feature = "core_io", issue = "154046")]
9pub mod prelude;
10mod seek;
11mod size_hint;
12mod util;
13mod write;
14
15#[unstable(feature = "core_io_borrowed_buf", issue = "117693")]
16pub use self::borrowed_buf::{BorrowedBuf, BorrowedCursor};
17#[unstable(feature = "raw_os_error_ty", issue = "107792")]
18pub use self::error::RawOsError;
19#[unstable(feature = "io_const_error_internals", issue = "none")]
20pub use self::error::SimpleMessage;
21#[unstable(feature = "io_const_error", issue = "133448")]
22pub use self::error::const_error;
23#[unstable(feature = "core_io", issue = "154046")]
24pub use self::{
25    cursor::Cursor,
26    error::{Error, ErrorKind, Result},
27    io_slice::{IoSlice, IoSliceMut},
28    seek::{Seek, SeekFrom},
29    util::{Chain, Empty, Repeat, Sink, Take, empty, repeat, sink},
30    write::Write,
31};
32#[doc(hidden)]
33#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
34pub use self::{
35    cursor::{
36        WriteThroughCursor, slice_write, slice_write_all, slice_write_all_vectored,
37        slice_write_vectored,
38    },
39    error::{Custom, CustomOwner, OsFunctions},
40    seek::stream_len_default,
41    size_hint::SizeHint,
42    util::{chain, take},
43    write::default_write_vectored,
44};
45
46/// Marks that a type `T` can have IO traits such as [`Seek`], [`Write`], etc. automatically
47/// implemented for handle types like [`Arc`][arc] as well.
48///
49/// This trait should only be implemented for types where `<&T as Trait>::method(&mut &value, ..)`
50/// would be identical to `<T as Trait>::method(&mut value, ..)`.
51///
52/// [`File`][file] passes this test, as operations on `&File` and `File` both affect
53/// the same underlying file.
54/// `[u8]` fails, because any modification to `&mut &[u8]` would only affect a temporary
55/// and be lost after the method has been called.
56///
57// FIXME(#74481): Hard-links required to link from `core` to `std`
58/// [file]: ../../std/fs/struct.File.html
59/// [arc]: ../../alloc/sync/struct.Arc.html
60/// [`Write`]: crate::io::Write
61/// [`Seek`]: crate::io::Seek
62#[doc(hidden)]
63#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
64pub trait IoHandle {}