about summary refs log tree commit diff
path: root/library/std/src/ffi/mod.rs
AgeCommit message (Collapse)AuthorLines
2025-06-06Rollup merge of #140418 - tgross35:std-c-size_t, r=workingjubileeGuillaume Gomez-0/+2
Reexport types from `c_size_t` in `std` These are unstably available in `core` and should be in `std` too, but are not currently reexported. Resolve this here. Tracking issue: https://github.com/rust-lang/rust/issues/88345
2025-05-21limit impls of `VaArgSafe` to just types that are actually safeFolkert de Vries-1/+1
8 and 16-bit integers are subject to upcasting in C, and hence are not reliably safe. users should perform their own casting and deal with the consequences
2025-05-12update version placeholdersPietro Albini-1/+1
2025-04-28Reexport types from `c_size_t` in `std`Trevor Gross-0/+2
These are unstably available in `core` and should be in `std` too, but are not currently reexported. Resolve this here.
2025-04-27Rollup merge of #137439 - clarfonthey:c-str-module, r=tgross35Matthias Krüger-1/+1
Stabilise `std::ffi::c_str` This finished FCP in #112134 but never actually got a stabilisation PR. Since the FCP in #120048 recently passed to add the `os_str` module, it would be nice to also merge this too, to ensure that both get added in the next version. Note: The added stability attributes which *somehow* were able to be omitted before (rustc bug?) were added based on the fact that they were added in 302551388b1942bb4216bb5a15d9d55cee3643a8, which ended up in 1.85.0. Closes: https://github.com/rust-lang/rust/issues/112134 r? libs-api
2025-04-09replace version placeholderBoxy-1/+1
2025-02-22Stabilise c_str_moduleltdk-1/+1
2025-02-20Stabilise `os_str_display`riverbl-1/+1
2024-12-26docs: inline `std::ffi::c_str` types to `std::ffi`Michael Howell-5/+5
Rustdoc has no way to show that an item is stable, but only at a different path. `std::ffi::c_str::NulError` is not stable, but `std::ffi::NulError` is. To avoid marking these types as unstable when someone just wants to follow a link from `CString`, inline them into their stable paths.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-5/+5
2024-07-29Reformat `use` declarations.Nicholas Nethercote-30/+22
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-03-10Rollup merge of #112136 - clarfonthey:ffi-c_str, r=cuviperMatthias Krüger-6/+26
Add std::ffi::c_str module ACP: rust-lang/libs-team#134 `std::ffi` docs before change: ![Structs: VaList, VaListImpl, CStr, CString, FromBytesWithNulError, FromVecWithNulError, IntoStringError, NulError, OsStr, OsString](https://github.com/rust-lang/rust/assets/15850505/b2cf3534-30f9-4ef0-a655-bacdc3a19e17) `std::ffi` docs after change: ![Re-exports: self::c_str::{FromBytesWithNulError, FromBytesUntilNulError, FromVecWithNulError, NulError, IntoStringError} ; Modules: c_str ; Structs: VaList, VaListImpl, CStr, CString, OsStr, OsString](https://github.com/rust-lang/rust/assets/15850505/23aa6964-da7a-4942-bbf7-42bde2146f9e) (note: I'm omitting the `c_int`, etc. stuff from the screenshots since it's the same in both. this doesn't just delete those types)
2024-02-28Rollup merge of #120051 - riverbl:os-str-display, r=m-ou-seGuillaume Gomez-1/+3
Add `display` method to `OsStr` Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public (see https://github.com/rust-lang/libs-team/issues/326#issuecomment-1894160023). - ACP: https://github.com/rust-lang/libs-team/issues/326 - Tracking issue: #120048
2024-02-22Add std::ffi::c_str modulesltdk-6/+26
2024-01-21Move `OsStr::slice_encoded_bytes` validation to platform modulesJan Verbeek-0/+7
On Windows and UEFI this improves performance and error messaging. On other platforms we optimize the fast path a bit more. This also prepares for later relaxing the checks on certain platforms.
2024-01-18Add `display` method to `OsStr`riverbl-1/+3
Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode. Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`. This change also makes the `std::ffi::os_str` module public.
2023-09-01fix(std): Rename os_str_bytes to encoded_bytesEd Page-2/+2
2023-08-22Replace version placeholders with 1.73.0Mark Rousskov-1/+1
2023-07-14Re-export core::ffi::FromBytesUntilNulError in std::ffiAllen Wild-0/+2
Like the other CStr and CString error types, make a re-export for std::ffi::FromBytesUntilNulError. This seems to have slipped through the cracks in the cstr_from_bytes_until_nul implementation and core_c_str migration. Tracking Issue: #95027
2023-03-27Allow access to `OsStr` bytesEd Page-0/+8
`OsStr` has historically kept its implementation details private out of concern for locking us into a specific encoding on Windows. This is an alternative to #95290 which proposed specifying the encoding on Windows. Instead, this only specifies that for cross-platform code, `OsStr`'s encoding is a superset of UTF-8 and defines rules for safely interacting with it At minimum, this can greatly simplify the `os_str_bytes` crate and every arg parser that interacts with `OsStr` directly (which is most of those that support invalid UTF-8).
2022-07-15Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friendsJosh Triplett-18/+4
Stabilize the `core_c_str` and `alloc_c_string` feature gates. Change `std::ffi` to re-export these types rather than creating type aliases, since they now have matching stability.
2022-07-13Stabilize `core::ffi:c_*` and rexport in `std::ffi`Josh Triplett-0/+6
This only stabilizes the base types, not the non-zero variants, since those have their own separate tracking issue and have not gone through FCP to stabilize.
2022-05-27docs: Don't imply that OsStr on Unix is always UTF-8Xiretza-1/+1
The methods in `OsStrExt` consume and return `&[u8]` and don't perform any UTF-8 checks.
2022-04-27Revert "Re-export core::ffi types from std::ffi"Josh Triplett-9/+0
This reverts commit 9aed829fe6cdf5eaf278c6c3972f7acd0830887d. Fixes https://github.com/rust-lang/rust/issues/96435 , a regression in crates doing `use std::ffi::*;` and `use std::os::raw::*;`. We can re-add this re-export once the `core::ffi` types are stable, and thus the `std::os::raw` types can become re-exports as well, which will avoid the conflict. (Type aliases to the same type still conflict, but re-exports of the same type don't.)
2022-04-14library: Use type aliases to make `CStr(ing)` in libcore/liballoc unstableVadim Petrochenkov-4/+14
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-5/+6
2022-03-02Re-export core::ffi types from std::ffibstrie-0/+9
2021-12-02Emphasise that an OsStr[ing] is not necessarily a platform stringChris Denton-10/+13
2021-10-20fix 'since' version numberNathan Stocks-1/+1
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2021-10-20stabilize CString::from_vec_with_nul[_unchecked]Nathan Stocks-1/+1
2021-09-25Rollup merge of #89216 - r00ster91:bigo, r=dtolnayManish Goregaokar-2/+2
Consistent big O notation This makes the big O time complexity notation in places with markdown support more consistent. Inspired by #89210
2021-09-25Apply 16 commits (squashed)Frank Steffahn-24/+24
---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::fmt ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::{rc, sync} ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::string ---------- Fix spacing for links inside code blocks in alloc::vec ---------- Fix spacing for links inside code blocks in core::option ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in core::result ---------- Fix spacing for links inside code blocks in core::{iter::{self, iterator}, stream::stream, poll} ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{fs, path} ---------- Fix spacing for links inside code blocks in std::{collections, time} ---------- Fix spacing for links inside code blocks in and make formatting of `&str`-like types consistent in std::ffi::{c_str, os_str} ---------- Fix spacing for links inside code blocks, and improve link tooltips in std::ffi ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{io::{self, buffered::{bufreader, bufwriter}, cursor, util}, net::{self, addr}} ---------- Fix typo in link to `into` for `OsString` docs ---------- Remove tooltips that will probably become redundant in the future ---------- Apply suggestions from code review Replacing `…std/primitive.reference.html` paths with just `reference` Co-authored-by: Joshua Nelson <github@jyn.dev> ---------- Also replace `…std/primitive.reference.html` paths with just `reference` in `core::pin`
2021-09-24consistent big O notationr00ster91-2/+2
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-1/+1
same search
2021-06-23Use HTTPS links where possibleSmitty-2/+2
2020-08-13Move to intra doc links in std::ffiAlexis Bourget-27/+15
2020-07-27mv std libs to library/mark-0/+180