summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/io/stdio.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/io/stdio.rs')
-rw-r--r--vendor/rustix/src/io/stdio.rs96
1 files changed, 78 insertions, 18 deletions
diff --git a/vendor/rustix/src/io/stdio.rs b/vendor/rustix/src/io/stdio.rs
index f9d03a701..caa8183c2 100644
--- a/vendor/rustix/src/io/stdio.rs
+++ b/vendor/rustix/src/io/stdio.rs
@@ -8,9 +8,9 @@
//! stdio streams.
#![allow(unsafe_code)]
-use crate::imp;
-use crate::io::OwnedFd;
-use imp::fd::{BorrowedFd, FromRawFd, RawFd};
+use crate::backend;
+use crate::fd::OwnedFd;
+use backend::fd::{BorrowedFd, FromRawFd, RawFd};
/// `STDIN_FILENO`—Standard input, borrowed.
///
@@ -36,9 +36,10 @@ use imp::fd::{BorrowedFd, FromRawFd, RawFd};
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html
/// [Linux]: https://man7.org/linux/man-pages/man3/stdin.3.html
+#[doc(alias = "STDIN_FILENO")]
#[inline]
-pub unsafe fn stdin() -> BorrowedFd<'static> {
- BorrowedFd::borrow_raw(imp::io::types::STDIN_FILENO as RawFd)
+pub const unsafe fn stdin() -> BorrowedFd<'static> {
+ BorrowedFd::borrow_raw(backend::io::types::STDIN_FILENO as RawFd)
}
/// `STDIN_FILENO`—Standard input, owned.
@@ -65,11 +66,10 @@ pub unsafe fn stdin() -> BorrowedFd<'static> {
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html
/// [Linux]: https://man7.org/linux/man-pages/man3/stdin.3.html
+#[doc(alias = "STDIN_FILENO")]
#[inline]
pub unsafe fn take_stdin() -> OwnedFd {
- OwnedFd::from(imp::fd::OwnedFd::from_raw_fd(
- imp::io::types::STDIN_FILENO as RawFd,
- ))
+ backend::fd::OwnedFd::from_raw_fd(backend::io::types::STDIN_FILENO as RawFd)
}
/// `STDOUT_FILENO`—Standard output, borrowed.
@@ -97,9 +97,10 @@ pub unsafe fn take_stdin() -> OwnedFd {
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdout.html
/// [Linux]: https://man7.org/linux/man-pages/man3/stdout.3.html
+#[doc(alias = "STDOUT_FILENO")]
#[inline]
-pub unsafe fn stdout() -> BorrowedFd<'static> {
- BorrowedFd::borrow_raw(imp::io::types::STDOUT_FILENO as RawFd)
+pub const unsafe fn stdout() -> BorrowedFd<'static> {
+ BorrowedFd::borrow_raw(backend::io::types::STDOUT_FILENO as RawFd)
}
/// `STDOUT_FILENO`—Standard output, owned.
@@ -126,11 +127,10 @@ pub unsafe fn stdout() -> BorrowedFd<'static> {
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdout.html
/// [Linux]: https://man7.org/linux/man-pages/man3/stdout.3.html
+#[doc(alias = "STDOUT_FILENO")]
#[inline]
pub unsafe fn take_stdout() -> OwnedFd {
- OwnedFd::from(imp::fd::OwnedFd::from_raw_fd(
- imp::io::types::STDOUT_FILENO as RawFd,
- ))
+ backend::fd::OwnedFd::from_raw_fd(backend::io::types::STDOUT_FILENO as RawFd)
}
/// `STDERR_FILENO`—Standard error, borrowed.
@@ -157,9 +157,10 @@ pub unsafe fn take_stdout() -> OwnedFd {
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html
/// [Linux]: https://man7.org/linux/man-pages/man3/stderr.3.html
+#[doc(alias = "STDERR_FILENO")]
#[inline]
-pub unsafe fn stderr() -> BorrowedFd<'static> {
- BorrowedFd::borrow_raw(imp::io::types::STDERR_FILENO as RawFd)
+pub const unsafe fn stderr() -> BorrowedFd<'static> {
+ BorrowedFd::borrow_raw(backend::io::types::STDERR_FILENO as RawFd)
}
/// `STDERR_FILENO`—Standard error, owned.
@@ -186,9 +187,68 @@ pub unsafe fn stderr() -> BorrowedFd<'static> {
///
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html
/// [Linux]: https://man7.org/linux/man-pages/man3/stderr.3.html
+#[doc(alias = "STDERR_FILENO")]
#[inline]
pub unsafe fn take_stderr() -> OwnedFd {
- OwnedFd::from(imp::fd::OwnedFd::from_raw_fd(
- imp::io::types::STDERR_FILENO as RawFd,
- ))
+ backend::fd::OwnedFd::from_raw_fd(backend::io::types::STDERR_FILENO as RawFd)
+}
+
+/// `STDIN_FILENO`—Standard input, raw.
+///
+/// This is similar to [`stdin`], however it returns a `RawFd`.
+///
+/// # Other hazards
+///
+/// This has the same hazards as [`stdin`].
+///
+/// # References
+/// - [POSIX]
+/// - [Linux]
+///
+/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html
+/// [Linux]: https://man7.org/linux/man-pages/man3/stdin.3.html
+#[doc(alias = "STDIN_FILENO")]
+#[inline]
+pub const fn raw_stdin() -> RawFd {
+ backend::io::types::STDIN_FILENO as RawFd
+}
+
+/// `STDOUT_FILENO`—Standard output, raw.
+///
+/// This is similar to [`stdout`], however it returns a `RawFd`.
+///
+/// # Other hazards
+///
+/// This has the same hazards as [`stdout`].
+///
+/// # References
+/// - [POSIX]
+/// - [Linux]
+///
+/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stdout.html
+/// [Linux]: https://man7.org/linux/man-pages/man3/stdout.3.html
+#[doc(alias = "STDOUT_FILENO")]
+#[inline]
+pub const fn raw_stdout() -> RawFd {
+ backend::io::types::STDOUT_FILENO as RawFd
+}
+
+/// `STDERR_FILENO`—Standard error, raw.
+///
+/// This is similar to [`stderr`], however it returns a `RawFd`.
+///
+/// # Other hazards
+///
+/// This has the same hazards as [`stderr`].
+///
+/// # References
+/// - [POSIX]
+/// - [Linux]
+///
+/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html
+/// [Linux]: https://man7.org/linux/man-pages/man3/stderr.3.html
+#[doc(alias = "STDERR_FILENO")]
+#[inline]
+pub const fn raw_stderr() -> RawFd {
+ backend::io::types::STDERR_FILENO as RawFd
}