Files
tubestation/third_party/rust/windows-strings/readme.md
Jim Blandy 4d7ca2a448 Bug 1910150: Update windows-rs to 0.58. r=glandium,supply-chain-reviewers
Update the `windows` Microsoft Windows binding crate to 0.58.

- Update `taskcluster/kinds/fetch/toolchains.yml` to request version
  0.58 of the `windows` crate.
- Update `build/rust/windows/Cargo.toml` to present itself as 0.58.
- Vendor the following new crates into `third_party/rust`:
    - windows-core
    - windows-implement
    - windows-interface
    - windows-result
    - windows-strings
- Update `supply-chain/imports.lock` as necessary.

Differential Revision: https://phabricator.services.mozilla.com/D218694
2024-08-07 16:00:47 +00:00

896 B

Windows string types

The windows-strings crate provides common Windows string types used by various Windows APIs.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-strings]
version = "0.1"

Use the Windows string types as needed:

use windows_strings::*;

const A: PCSTR = s!("ansi");
const W: PCWSTR = w!("wide");

fn main() -> Result<()> {
    let b = BSTR::from("bstr");
    let h = HSTRING::from("hstring");

    assert_eq!(b, "bstr");
    assert_eq!(h, "hstring");

    assert_eq!(unsafe { A.to_string()? }, "ansi");
    assert_eq!(unsafe { W.to_string()? }, "wide");

    Ok(())
}