Skip to main content

windows_strings/
lib.rs

1#![doc = include_str!("../readme.md")]
2#![cfg_attr(
3    windows,
4    debugger_visualizer(natvis_file = "../windows-strings.natvis")
5)]
6#![cfg_attr(all(not(feature = "std")), no_std)]
7
8// `HSTRING` and its supporting types are cross-platform: the only Win32 dependency is the
9// heap allocator, which `hstring_header` swaps at compile time. On Windows it uses the
10// process heap (so HSTRINGs interoperate with native code); elsewhere it uses the Rust
11// global allocator.
12//
13// `BSTR` and the `bindings` module are inherently Win32 - `BSTR` is part of the OLE
14// Automation ABI and must use `SysAllocStringLen`/`SysFreeString` so callers across the
15// FFI boundary can free strings allocated here - and therefore stay gated to Windows.
16
17extern crate alloc;
18use alloc::string::String;
19
20#[cfg(windows)]
21mod bstr;
22#[cfg(windows)]
23pub use bstr::*;
24
25mod hstring;
26pub use hstring::*;
27
28mod hstring_builder;
29pub use hstring_builder::*;
30
31mod hstring_header;
32use hstring_header::*;
33
34#[cfg(windows)]
35#[expect(clippy::upper_case_acronyms)]
36mod bindings;
37
38mod decode;
39use decode::*;
40
41mod ref_count;
42use ref_count::*;
43
44mod literals;
45pub use literals::*;
46
47mod pcstr;
48pub use pcstr::*;
49
50mod pcwstr;
51pub use pcwstr::*;
52
53mod pstr;
54pub use pstr::*;
55
56mod pwstr;
57pub use pwstr::*;
58
59unsafe extern "C" {
60    fn strlen(s: *const core::ffi::c_char) -> usize;
61}