chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

1
vendor/hostname/.cargo-checksum.json vendored Normal file
View File

@@ -0,0 +1 @@
{"files":{".cargo_vcs_info.json":"d53157770fa2adc61ef809b4672d027dd0a58e6774900fffbdd08214141a82e1",".editorconfig":"c021eda41c65403dc205b4d0231bf18d817b9cc98d265fb06535d0c97fcbb997",".github/FUNDING.yml":"5f37c8fa873462eb4c22940ff1eb96af7b15a06c9dc0a8ba11883a591e60bbcc",".github/dependabot.yml":"3747699615dd20e8b922013b4722dd961da0433da6768cf532ce5425a4431e8f",".github/workflows/ci.yml":"509fdc696e056e2917b80846acd8ac66952ab7078abb2fe4d019137b93fa04c6","Cargo.lock":"85f3044b134a7c90f97effe3e83437da735cdebb1da82abfb7316694b432c842","Cargo.toml":"0ec6d149b465517fa029a5f27687b65bfab491301dadd7e31ff3acae200104f9","Cargo.toml.orig":"854d66d583963b09c8e839a7908d22af99662462d31df99ac877902a6564f89c","LICENSE":"2e4213e573312c8c75e6e7e2c55a45283427e759432b56014afaf3c7d950a568","README.md":"46684e1be26c68812c08da2a44e8478e238690fad1f58e3e77ff627989ca7e31","examples/hostname.rs":"fb2de1da4f0e02524f0c78618a233dbe332c96e2dabba5a459cd515cba7f754b","src/lib.rs":"8f6d68de7dcc804508cc453c950b3ae4bf62a58d2d43cf1a2c611176465d631a","src/nix.rs":"960f41f06d86a0d19589c913b74183559a5664a941ee05c140bbade03d99d618","src/windows/bindings.rs":"51b2f4f629362da8f2f0bba1f7b6aa52bde2e29445fa61e9cf89a8fe9c6135d8","src/windows/mod.rs":"e87ed7057e02dbec8a52f63c20bf736b21d6e1ad131a59a60c778971789aef8c","tests/bindings.txt":"327f80de575492598f72c37cb4a38a59334601fff649b53040c187c4d52c5e8a","tests/codegen.rs":"0c1b43566ca12d9a5dc1730fceac5efa72aeab00e2fd55dd6926732eaeea17bd","tests/version.rs":"73301b7bfe500eada5ede66f0dce89bd3e354af50a8e7a123b02931cd5eb8e16"},"package":"617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd"}

6
vendor/hostname/.cargo_vcs_info.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"git": {
"sha1": "c697709235a03e6d5791f70b9c83d5eb9b51c197"
},
"path_in_vcs": ""
}

12
vendor/hostname/.editorconfig vendored Normal file
View File

@@ -0,0 +1,12 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.yml]
indent_size = 2

2
vendor/hostname/.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,2 @@
github: [djc]
patreon: dochtman

13
vendor/hostname/.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: weekly
time: "05:23"
open-pull-requests-limit: 99
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
time: "05:27"

277
vendor/hostname/.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,277 @@
on: push
name: Continuous integration
jobs:
lints:
name: Lints
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt, clippy
- name: Run rustfmt
if: matrix.os == 'ubuntu-latest'
run: |
cargo fmt --all -- --check
- name: Run clippy
run: |
cargo clippy --locked --all-targets --all-features -- -D warnings
tier1:
# Matches the Rust Tier 1 platform support
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-1-with-host-tools
name: Tier 1
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use_cross: true
- os: ubuntu-latest
target: i686-unknown-linux-gnu
use_cross: true
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
# TODO: Enable it back
# - os: windows-latest
# target: i686-pc-windows-gnu
- os: windows-latest
target: i686-pc-windows-msvc
use_cross: true
- os: windows-latest
target: x86_64-pc-windows-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
components: rustfmt
- uses: taiki-e/install-action@v2
with:
tool: cross
- name: Check without features
run: cargo check --locked --target=${{ matrix.target }}
- name: Check with all features enabled
run: ${{ env.CARGO_BINARY }} check --locked --all-features --target=${{ matrix.target }}
env:
CARGO_BINARY: ${{ matrix.use_cross == true && 'cross' || 'cargo' }}
- name: Run tests
run: ${{ env.CARGO_BINARY }} test --locked --all-features --target=${{ matrix.target }}
env:
CARGO_BINARY: ${{ matrix.use_cross == true && 'cross' || 'cargo' }}
tier2_with_host_tools:
# Matches Rust "Tier 2 with Host Tools" platform support
# For as much as possible
#
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools
name: Tier 2 (with Host Tools)
needs: tier1
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: aarch64-pc-windows-msvc
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: ubuntu-latest
target: arm-unknown-linux-gnueabi
- os: ubuntu-latest
target: arm-unknown-linux-gnueabihf
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
- os: ubuntu-latest
target: powerpc-unknown-linux-gnu
- os: ubuntu-latest
target: powerpc64-unknown-linux-gnu
- os: ubuntu-latest
target: powerpc64le-unknown-linux-gnu
- os: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
- os: ubuntu-latest
target: s390x-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
with:
tool: cross
- name: Run build
run: |
cross build --locked --all-features --target=${{ matrix.target }}
tier2_with_host_tools_via_cross:
# Matches Rust "Tier 2 with Host Tools" platform support
# For as much as possible, but where `cross` is needed for cross-compilation
#
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools
name: Tier 2 (with Host Tools, via Cross)
needs: tier1
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-freebsd
- x86_64-unknown-illumos
- x86_64-unknown-netbsd
steps:
- uses: actions/checkout@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
with:
tool: cross
- name: Run build
run: |
cross build --locked --all-features --target=${{ matrix.target }}
tier2_without_host_tools:
# Matches Rust "Tier 2 with host tools" platform support
# For as much as possible, but where `cross` is needed for cross-compilation
#
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools
name: Tier 2 (without Host Tools)
needs: tier1
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-ios
# `rust-std` is not available
# - os: ubuntu-latest
# target: aarch64-unknown-fuchsia
- os: ubuntu-latest
target: aarch64-linux-android
- os: ubuntu-latest
target: arm-linux-androideabi
- os: ubuntu-latest
target: arm-unknown-linux-musleabi
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
- os: ubuntu-latest
target: armv5te-unknown-linux-gnueabi
- os: ubuntu-latest
target: armv5te-unknown-linux-musleabi
- os: ubuntu-latest
target: armv7-linux-androideabi
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabi
- os: ubuntu-latest
target: armv7-unknown-linux-musleabi
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: i586-unknown-linux-gnu
- os: ubuntu-latest
target: i586-unknown-linux-musl
- os: ubuntu-latest
target: i686-linux-android
- os: ubuntu-latest
target: i686-unknown-freebsd
- os: ubuntu-latest
target: i686-unknown-linux-musl
- os: ubuntu-latest
target: sparc64-unknown-linux-gnu
- os: ubuntu-latest
target: sparcv9-sun-solaris
- os: ubuntu-latest
target: thumbv7neon-linux-androideabi
- os: ubuntu-latest
target: thumbv7neon-unknown-linux-gnueabihf
- os: ubuntu-latest
target: x86_64-linux-android
- os: ubuntu-latest
target: x86_64-pc-solaris
- os: ubuntu-latest
target: x86_64-unknown-linux-gnux32
steps:
- uses: actions/checkout@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
with:
tool: cross
- name: Run build
run: |
cross build --locked --all-features --target=${{ matrix.target }}
tier2_without_host_tools_default_features:
# Matches Rust "Tier 2 with host tools" platform support
# For as much as possible, but where `cross` is needed for cross-compilation
#
# The only difference from the `tier2_without_host_tools` group is that
# no optional crate features are enabled (e.g. Redox has `gethostname(2)`, but not the `sethostname(2)`)
#
# See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools
name: Tier 2 (without Host Tools)
needs: tier1
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-redox
steps:
- uses: actions/checkout@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
with:
tool: cross
- name: Run build (default features)
run: |
cross build --locked --target=${{ matrix.target }}
msrv:
name: MSRV
strategy:
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.74
- name: Check MSRV
run: cargo check --locked --lib --all-features

734
vendor/hostname/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,734 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "bitflags"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "bstr"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab"
dependencies = [
"memchr",
"regex-automata",
"serde",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "console"
version = "0.15.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8"
dependencies = [
"encode_unicode",
"libc",
"once_cell",
"windows-sys",
]
[[package]]
name = "displaydoc"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "encode_unicode"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
dependencies = [
"percent-encoding",
]
[[package]]
name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
[[package]]
name = "hostname"
version = "0.4.2"
dependencies = [
"cfg-if",
"libc",
"similar-asserts",
"version-sync",
"windows-bindgen",
"windows-link",
]
[[package]]
name = "icu_collections"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
dependencies = [
"displaydoc",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_locid"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
dependencies = [
"displaydoc",
"litemap",
"tinystr",
"writeable",
"zerovec",
]
[[package]]
name = "icu_locid_transform"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
dependencies = [
"displaydoc",
"icu_locid",
"icu_locid_transform_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_locid_transform_data"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d"
[[package]]
name = "icu_normalizer"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
dependencies = [
"displaydoc",
"icu_collections",
"icu_normalizer_data",
"icu_properties",
"icu_provider",
"smallvec",
"utf16_iter",
"utf8_iter",
"write16",
"zerovec",
]
[[package]]
name = "icu_normalizer_data"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7"
[[package]]
name = "icu_properties"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5"
dependencies = [
"displaydoc",
"icu_collections",
"icu_locid_transform",
"icu_properties_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_properties_data"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2"
[[package]]
name = "icu_provider"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
dependencies = [
"displaydoc",
"icu_locid",
"icu_provider_macros",
"stable_deref_trait",
"tinystr",
"writeable",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_provider_macros"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "idna"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
dependencies = [
"idna_adapter",
"smallvec",
"utf8_iter",
]
[[package]]
name = "idna_adapter"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71"
dependencies = [
"icu_normalizer",
"icu_properties",
]
[[package]]
name = "indexmap"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "itoa"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "libc"
version = "0.2.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
name = "litemap"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "once_cell"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "percent-encoding"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "proc-macro2"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [
"unicode-ident",
]
[[package]]
name = "pulldown-cmark"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
dependencies = [
"bitflags",
"memchr",
"unicase",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "ryu"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "semver"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
[[package]]
name = "serde"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
dependencies = [
"serde",
]
[[package]]
name = "similar"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
dependencies = [
"bstr",
"unicode-segmentation",
]
[[package]]
name = "similar-asserts"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b441962c817e33508847a22bd82f03a30cff43642dc2fae8b050566121eb9a"
dependencies = [
"console",
"similar",
]
[[package]]
name = "smallvec"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "syn"
version = "2.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "synstructure"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tinystr"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
dependencies = [
"displaydoc",
"zerovec",
]
[[package]]
name = "toml"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]
[[package]]
name = "unicase"
version = "2.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "unicode-segmentation"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "url"
version = "2.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
dependencies = [
"form_urlencoded",
"idna",
"percent-encoding",
]
[[package]]
name = "utf16_iter"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
[[package]]
name = "utf8_iter"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "version-sync"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "835169da0173ea373ddf5987632aac1f918967fbbe58195e304342282efa6089"
dependencies = [
"proc-macro2",
"pulldown-cmark",
"regex",
"semver",
"syn",
"toml",
"url",
]
[[package]]
name = "windows-bindgen"
version = "0.65.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5308a9704923cabf7c090f0c00a8328dec5551cee858b0b6347e5465e622a6f1"
dependencies = [
"serde",
"serde_json",
"windows-threading",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows-threading"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"
dependencies = [
"windows-link",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winnow"
version = "0.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
dependencies = [
"memchr",
]
[[package]]
name = "write16"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
[[package]]
name = "writeable"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "yoke"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40"
dependencies = [
"serde",
"stable_deref_trait",
"yoke-derive",
"zerofrom",
]
[[package]]
name = "yoke-derive"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]]
name = "zerofrom"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
dependencies = [
"proc-macro2",
"quote",
"syn",
"synstructure",
]
[[package]]
name = "zerovec"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079"
dependencies = [
"yoke",
"zerofrom",
"zerovec-derive",
]
[[package]]
name = "zerovec-derive"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

80
vendor/hostname/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,80 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.74"
name = "hostname"
version = "0.4.2"
build = false
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Cross-platform system's host name functions"
readme = "README.md"
keywords = [
"hostname",
"gethostname",
"sethostname",
]
categories = [
"api-bindings",
"os",
]
license = "MIT"
repository = "https://github.com/djc/hostname"
[package.metadata.docs.rs]
features = ["set"]
rustdoc-args = [
"--cfg",
"docsrs",
]
[features]
default = []
set = []
[lib]
name = "hostname"
path = "src/lib.rs"
[[example]]
name = "hostname"
path = "examples/hostname.rs"
[[test]]
name = "codegen"
path = "tests/codegen.rs"
[[test]]
name = "version"
path = "tests/version.rs"
[dependencies.cfg-if]
version = "1"
[dev-dependencies.similar-asserts]
version = "1.6.1"
[dev-dependencies.version-sync]
version = "0.9"
[dev-dependencies.windows-bindgen]
version = "0.65"
[target.'cfg(any(unix, target_os = "redox"))'.dependencies.libc]
version = "0.2"
[target.'cfg(target_os = "windows")'.dependencies.windows-link]
version = "0.2"

22
vendor/hostname/LICENSE vendored Normal file
View File

@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2016 fengcen
Copyright (c) 2019 svartalf
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

56
vendor/hostname/README.md vendored Normal file
View File

@@ -0,0 +1,56 @@
# hostname
[![Latest Version](https://img.shields.io/crates/v/hostname.svg)](https://crates.io/crates/hostname)
[![Latest Version](https://docs.rs/hostname/badge.svg)](https://docs.rs/hostname)
[![Build Status](https://github.com/djc/hostname/actions/workflows/ci.yml/badge.svg)](https://github.com/djc/hostname/actions)
![Minimum rustc Version](https://img.shields.io/badge/rustc-1.74+-green.svg)
![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg)
![crates.io](https://img.shields.io/crates/d/hostname)
> Cross-platform system's host name functions in Rust
## Supported platforms
- [POSIX-compliant](https://en.wikipedia.org/wiki/POSIX#POSIX-oriented_operating_systems) systems\
(Linux, macOS, Android, FreeBSD, OpenBSD, NetBSD, Solaris, Redox, and so on)
- Windows
## Rust version requirements
Since version `0.4.0` this crate requires Rust version `1.74` or greater.
This version is explicitly tested in CI
and may be bumped in any major or minor release as needed.\
Maintaining compatibility with older compilers is a priority though,
so the bar for bumping the minimum supported version is set very high.
Any changes to the supported minimum version will be called out in the release notes.
## Usage
Add the following dependency to your Cargo manifest:
```toml
[dependencies]
hostname = "^0.4"
```
Crate API provides two simple functions for retrieving and setting the system's host name:
```rust
use std::io;
fn main() -> io::Result<()> {
// Retrieve the hostname
dbg!(hostname::get()?);
// And set a new one
hostname::set("potato")?;
Ok(())
}
```
## License
hostname is primarily distributed under the terms of the MIT license
([LICENSE](LICENSE) or https://opensource.org/license/mit).

11
vendor/hostname/examples/hostname.rs vendored Normal file
View File

@@ -0,0 +1,11 @@
//! Naive re-implementation of the Linux `hostname` program.
use std::io;
fn main() -> io::Result<()> {
let name = hostname::get()?;
println!("{}", name.to_string_lossy());
Ok(())
}

128
vendor/hostname/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,128 @@
//! A crate with utilities to get and set the system's host name.
//!
//! ## Examples
#![cfg_attr(
feature = "set",
doc = r#"
Set and get the host name:
```rust,no_run
# use std::io;
# use std::ffi::OsStr;
# fn main() -> io::Result<()> {
hostname::set("potato")?;
let new_name = hostname::get()?;
assert_eq!(new_name, OsStr::new("potato"));
# Ok(())
# }
```
"#
)]
#![cfg_attr(
not(feature = "set"),
doc = r#"
Get the host name:
```rust,no_run
# use std::io;
# use std::ffi::OsStr;
# fn main() -> io::Result<()> {
let name = hostname::get()?;
println!("{:?}", name);
# Ok(())
# }
```
"#
)]
#![deny(
unused,
unused_imports,
unused_features,
bare_trait_objects,
missing_debug_implementations,
missing_docs,
nonstandard_style,
dead_code,
deprecated,
rust_2018_idioms,
trivial_casts,
unused_import_braces,
unused_results
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
use cfg_if::cfg_if;
#[cfg(feature = "set")]
use std::ffi::OsStr;
use std::ffi::OsString;
use std::io;
cfg_if! {
if #[cfg(any(unix, target_os = "redox"))] {
mod nix;
use crate::nix as sys;
} else if #[cfg(target_os = "windows")] {
mod windows;
use crate::windows as sys;
} else {
compile_error!("Unsupported target OS! Create an issue: https://github.com/djc/hostname/issues/new");
}
}
/// Return the system hostname.
///
/// ## Example
///
/// ```rust
/// # use std::io;
/// # fn main() -> io::Result<()> {
/// let name = hostname::get()?;
/// # Ok(())
/// # }
/// ```
///
/// ## Errors
///
/// If this function encounters any form of error, an error
/// variant will be returned; in practice it is rare to be happen.
pub fn get() -> io::Result<OsString> {
sys::get()
}
/// Set the system hostname.
///
/// This function is available only with `set` feature enabled (**disabled** by
/// default).
#[cfg_attr(
feature = "set",
doc = r#"
## Example
```rust,no_run
# use std::io;
# fn main() -> io::Result<()> {
hostname::set("potato")?;
# Ok(())
# }
```
"#
)]
/// ## Errors
///
/// In order to set new hostname, caller might need
/// to have the corresponding privilege
/// (`CAP_SYS_ADMIN` capability for Linux, administrator privileges for Windows,
/// and so on).\
/// An error variant will be returned if this function
/// will encounter a permission error or any other form of error.
///
/// ## Compatibility
///
/// * Will fail with a linkage error for Android API < 23 (see [#9](https://github.com/djc/hostname/issues/9#issuecomment-563991112))
#[cfg(feature = "set")]
#[cfg_attr(docsrs, doc(cfg(feature = "set")))]
pub fn set<T>(hostname: T) -> io::Result<()>
where
T: AsRef<OsStr>,
{
sys::set(hostname.as_ref())
}

127
vendor/hostname/src/nix.rs vendored Normal file
View File

@@ -0,0 +1,127 @@
#[cfg(feature = "set")]
use std::ffi::OsStr;
use std::ffi::OsString;
use std::io;
#[cfg(feature = "set")]
use std::os::unix::ffi::OsStrExt;
use std::os::unix::ffi::OsStringExt;
const _POSIX_HOST_NAME_MAX: libc::c_long = 255;
pub fn get() -> io::Result<OsString> {
// According to the POSIX specification,
// host names are limited to `HOST_NAME_MAX` bytes
//
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html
let limit = unsafe { libc::sysconf(libc::_SC_HOST_NAME_MAX) };
let size = libc::c_long::max(limit, _POSIX_HOST_NAME_MAX) as usize;
// Reserve additional space for terminating nul byte.
let mut buffer = vec![0u8; size + 1];
#[allow(trivial_casts)]
let result = unsafe { libc::gethostname(buffer.as_mut_ptr() as *mut libc::c_char, size) };
if result != 0 {
return Err(io::Error::last_os_error());
}
Ok(wrap_buffer(buffer))
}
fn wrap_buffer(mut bytes: Vec<u8>) -> OsString {
// Returned name might be truncated if it does not fit
// and `buffer` will not contain the trailing \0 in that case.
// Manually capping the buffer length here.
let end = bytes
.iter()
.position(|&byte| byte == 0x00)
.unwrap_or(bytes.len());
bytes.resize(end, 0x00);
OsString::from_vec(bytes)
}
#[cfg(feature = "set")]
pub fn set(hostname: &OsStr) -> io::Result<()> {
#[cfg(not(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "solaris",
target_os = "illumos"
)))]
#[allow(non_camel_case_types)]
type hostname_len_t = libc::size_t;
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "solaris",
target_os = "illumos"
))]
#[allow(non_camel_case_types)]
type hostname_len_t = libc::c_int;
#[allow(clippy::unnecessary_cast)]
// Cast is needed for the `libc::c_int` type
if hostname.len() > hostname_len_t::MAX as usize {
return Err(io::Error::other("hostname too long"));
}
let size = hostname.len() as hostname_len_t;
#[allow(trivial_casts)]
let result =
unsafe { libc::sethostname(hostname.as_bytes().as_ptr() as *const libc::c_char, size) };
if result != 0 {
Err(io::Error::last_os_error())
} else {
Ok(())
}
}
#[cfg(test)]
mod tests {
use std::ffi::OsStr;
use super::wrap_buffer;
// Happy path case: there is a correct null terminated C string in a buffer
// and a bunch of NULL characters from the pre-allocated buffer
#[test]
fn test_non_overflowed_buffer() {
let buf = b"potato\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".to_vec();
assert_eq!(wrap_buffer(buf), OsStr::new("potato"));
}
#[test]
fn test_empty_buffer() {
let buf = b"".to_vec();
assert_eq!(wrap_buffer(buf), OsStr::new(""));
}
#[test]
fn test_filled_with_null_buffer() {
let buf = b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".to_vec();
assert_eq!(wrap_buffer(buf), OsStr::new(""));
}
// Hostname value had overflowed the buffer, so it was truncated
// and according to the POSIX documentation of the `gethostname`:
//
// > it is unspecified whether the returned name is null-terminated.
#[test]
fn test_overflowed_buffer() {
let buf = b"potat".to_vec();
assert_eq!(wrap_buffer(buf), OsStr::new("potat"));
}
}

15
vendor/hostname/src/windows/bindings.rs vendored Normal file
View File

@@ -0,0 +1,15 @@
#![allow(
non_snake_case,
non_upper_case_globals,
non_camel_case_types,
dead_code,
clippy::all
)]
windows_link::link!("kernel32.dll" "system" fn GetComputerNameExW(nametype : COMPUTER_NAME_FORMAT, lpbuffer : PWSTR, nsize : *mut u32) -> BOOL);
windows_link::link!("kernel32.dll" "system" fn SetComputerNameExW(nametype : COMPUTER_NAME_FORMAT, lpbuffer : PCWSTR) -> BOOL);
pub type BOOL = i32;
pub type COMPUTER_NAME_FORMAT = i32;
pub const ComputerNamePhysicalDnsHostname: COMPUTER_NAME_FORMAT = 5i32;
pub type PCWSTR = *const u16;
pub type PWSTR = *mut u16;

64
vendor/hostname/src/windows/mod.rs vendored Normal file
View File

@@ -0,0 +1,64 @@
#[cfg(feature = "set")]
use std::ffi::OsStr;
use std::ffi::OsString;
use std::io;
#[cfg(feature = "set")]
use std::os::windows::ffi::OsStrExt;
use std::os::windows::ffi::OsStringExt;
use std::ptr;
mod bindings;
use bindings::{ComputerNamePhysicalDnsHostname, GetComputerNameExW, PWSTR};
pub fn get() -> io::Result<OsString> {
let mut size = 0;
unsafe {
// Don't care much about the result here,
// it is guaranteed to return an error,
// since we passed the NULL pointer as a buffer
let result =
GetComputerNameExW(ComputerNamePhysicalDnsHostname, ptr::null_mut(), &mut size);
debug_assert_eq!(result, 0);
};
let mut buffer = Vec::with_capacity(size as usize);
let result = unsafe {
GetComputerNameExW(
ComputerNamePhysicalDnsHostname,
PWSTR::from(buffer.as_mut_ptr()),
&mut size,
)
};
match result {
0 => Err(io::Error::last_os_error()),
_ => {
unsafe {
buffer.set_len(size as usize);
}
Ok(OsString::from_wide(&buffer))
}
}
}
#[cfg(feature = "set")]
pub fn set(hostname: &OsStr) -> io::Result<()> {
use bindings::{SetComputerNameExW, PCWSTR};
let mut buffer = hostname.encode_wide().collect::<Vec<_>>();
buffer.push(0x00); // Appending the null terminator
let result = unsafe {
SetComputerNameExW(
ComputerNamePhysicalDnsHostname,
PCWSTR::from(buffer.as_ptr()),
)
};
match result {
0 => Err(io::Error::last_os_error()),
_ => Ok(()),
}
}

6
vendor/hostname/tests/bindings.txt vendored Normal file
View File

@@ -0,0 +1,6 @@
--out src/windows/bindings.rs
--flat --sys --no-comment
--filter
ComputerNamePhysicalDnsHostname
GetComputerNameExW
SetComputerNameExW

33
vendor/hostname/tests/codegen.rs vendored Normal file
View File

@@ -0,0 +1,33 @@
use std::fs;
use std::process::Command;
use windows_bindgen::bindgen;
#[test]
fn gen_bindings() {
let output = "src/windows/bindings.rs";
let existing = fs::read_to_string(output).unwrap();
bindgen(["--no-deps", "--etc", "tests/bindings.txt"]).unwrap();
let out = Command::new("rustfmt")
.arg("--edition=2021")
.arg(output)
.output()
.unwrap();
dbg!(String::from_utf8(out.stdout).unwrap());
dbg!(String::from_utf8(out.stderr).unwrap());
assert!(out.status.success());
// Check the output is the same as before.
// Depending on the git configuration the file may have been checked out with `\r\n` newlines or
// with `\n`. Compare line-by-line to ignore this difference.
let mut new = fs::read_to_string(output).unwrap();
if existing.contains("\r\n") && !new.contains("\r\n") {
new = new.replace("\n", "\r\n");
} else if !existing.contains("\r\n") && new.contains("\r\n") {
new = new.replace("\r\n", "\n");
}
similar_asserts::assert_eq!(existing, new);
}

9
vendor/hostname/tests/version.rs vendored Normal file
View File

@@ -0,0 +1,9 @@
#[test]
fn test_readme_deps() {
version_sync::assert_markdown_deps_updated!("README.md");
}
#[test]
fn test_html_root_url() {
version_sync::assert_html_root_url_updated!("src/lib.rs");
}