Compare commits
No commits in common. "25af4686806fa6e3c17888fed9174983a5a94e40" and "a6dcbb6eaf14c98e0c9fc439ebb5442371d04bf3" have entirely different histories.
25af468680
...
a6dcbb6eaf
44 changed files with 1219 additions and 738 deletions
571
Cargo.lock
generated
571
Cargo.lock
generated
|
|
@ -11,12 +11,152 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
||||
|
||||
[[package]]
|
||||
name = "aquamarine"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a941c39708478e8eea39243b5983f1c42d2717b3620ee91f4a52115fd02ac43f"
|
||||
dependencies = [
|
||||
"itertools 0.9.0",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "autocxx"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ae6bbbec65d053b6fd803a4d63d21d0bd4a92f84f917847f216fec8bb8ae6ae"
|
||||
dependencies = [
|
||||
"aquamarine",
|
||||
"autocxx-macro",
|
||||
"cxx",
|
||||
"moveit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocxx-bindgen"
|
||||
version = "0.73.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecaaf84d9cf1a772409c0abdac7d2477a31fd890dbdf606d8f684dc60129aa94"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools 0.13.0",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocxx-build"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b16fa879472d80dc40ca826a59347772b3f15e69a7a74df41c4935942f62cf30"
|
||||
dependencies = [
|
||||
"autocxx-engine",
|
||||
"env_logger",
|
||||
"indexmap 1.9.3",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocxx-engine"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9866b109f7091a3470a49906d35c7f34597828be8885508e9395d1194f8283ca"
|
||||
dependencies = [
|
||||
"aquamarine",
|
||||
"autocxx-bindgen",
|
||||
"autocxx-parser",
|
||||
"cc",
|
||||
"cxx-gen",
|
||||
"indexmap 1.9.3",
|
||||
"indoc",
|
||||
"itertools 0.10.5",
|
||||
"log",
|
||||
"miette",
|
||||
"once_cell",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"regex_static",
|
||||
"rustversion",
|
||||
"serde_json",
|
||||
"syn 2.0.117",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocxx-macro"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c26712d744702e6fe61fdc618cc107a581a009ec8bfaffc67707d82501dbd907"
|
||||
dependencies = [
|
||||
"autocxx-parser",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocxx-parser"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6bcfc473ec409e612fb0e0c5c4a1b5b7611eca2bac71bc27b3cda98f15a25124"
|
||||
dependencies = [
|
||||
"indexmap 1.9.3",
|
||||
"itertools 0.10.5",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn 2.0.117",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.72.1"
|
||||
|
|
@ -33,7 +173,7 @@ dependencies = [
|
|||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -78,6 +218,43 @@ dependencies = [
|
|||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
|
||||
|
||||
[[package]]
|
||||
name = "codespan-reporting"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"termcolor",
|
||||
"unicode-width 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.6.3"
|
||||
|
|
@ -94,6 +271,81 @@ version = "0.0.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52560adf09603e58c9a7ee1fe1dcb95a16927b17c127f0ac02d6e768a0e25bc1"
|
||||
|
||||
[[package]]
|
||||
name = "cxx"
|
||||
version = "1.0.194"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "747d8437319e3a2f43d93b341c137927ca70c0f5dabeea7a005a73665e247c7e"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cxx-build",
|
||||
"cxxbridge-cmd",
|
||||
"cxxbridge-flags",
|
||||
"cxxbridge-macro",
|
||||
"foldhash 0.2.0",
|
||||
"link-cplusplus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxx-build"
|
||||
version = "1.0.194"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0f4697d190a142477b16aef7da8a99bfdc41e7e8b1687583c0d23a79c7afc1e"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"codespan-reporting",
|
||||
"indexmap 2.13.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"scratch",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxx-gen"
|
||||
version = "0.7.194"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "035b6c61a944483e8a4b2ad4fb8b13830d63491bd004943716ad16d85dcc64bc"
|
||||
dependencies = [
|
||||
"codespan-reporting",
|
||||
"indexmap 2.13.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-cmd"
|
||||
version = "1.0.194"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0956799fa8678d4c50eed028f2de1c0552ae183c76e976cf7ca8c4e36a7c328"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"codespan-reporting",
|
||||
"indexmap 2.13.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-flags"
|
||||
version = "1.0.194"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23384a836ab4f0ad98ace7e3955ad2de39de42378ab487dc28d3990392cb283a"
|
||||
|
||||
[[package]]
|
||||
name = "cxxbridge-macro"
|
||||
version = "1.0.194"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6acc6b5822b9526adfb4fc377b67128fdd60aac757cc4a741a6278603f763cf"
|
||||
dependencies = [
|
||||
"indexmap 2.13.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "doxygen-bindgen"
|
||||
version = "0.1.3"
|
||||
|
|
@ -124,6 +376,19 @@ version = "1.15.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
|
|
@ -158,6 +423,12 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.32"
|
||||
|
|
@ -212,13 +483,19 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
"foldhash 0.1.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -233,12 +510,38 @@ version = "0.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown 0.12.3",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.13.0"
|
||||
|
|
@ -251,6 +554,30 @@ dependencies = [
|
|||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
|
|
@ -297,6 +624,15 @@ dependencies = [
|
|||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f78c730aaa7d0b9336a299029ea49f9ee53b0ed06e9202e8cb7db9bae7b8c82"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
|
|
@ -324,12 +660,44 @@ version = "2.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||
|
||||
[[package]]
|
||||
name = "miette"
|
||||
version = "5.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"
|
||||
dependencies = [
|
||||
"miette-derive",
|
||||
"once_cell",
|
||||
"thiserror",
|
||||
"unicode-width 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miette-derive"
|
||||
version = "5.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "moveit"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87d7335204cb6ef7bd647fa6db0be3e4d7aa25b5823a7aa030027ddf512cefba"
|
||||
dependencies = [
|
||||
"cxx",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nixide"
|
||||
version = "0.1.0"
|
||||
|
|
@ -346,10 +714,11 @@ dependencies = [
|
|||
name = "nixide-sys"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"autocxx",
|
||||
"autocxx-build",
|
||||
"bindgen",
|
||||
"cc",
|
||||
"doxygen-bindgen",
|
||||
"heck",
|
||||
"itertools 0.14.0",
|
||||
"pkg-config",
|
||||
"serial_test",
|
||||
|
|
@ -413,7 +782,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -458,7 +851,7 @@ dependencies = [
|
|||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -469,15 +862,55 @@ checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
|
|||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
||||
|
||||
[[package]]
|
||||
name = "regex_static"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6126d61c5e4b41929098f73b42fc1d257116cc95d19739248c51591f77cc0021"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"regex",
|
||||
"regex_static_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex_static_impl"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c3755019886a70e772e6360b0b58501d75cf7dc17a53e08aa97e59ecb2c2bc5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex-syntax 0.6.29",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex_static_macro"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79b15495fd034158635bc8b762a132dfc83864d6992aeda1ffabf01b03b611a1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"regex_static_impl",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.1"
|
||||
|
|
@ -497,6 +930,12 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "scc"
|
||||
version = "2.4.0"
|
||||
|
|
@ -512,6 +951,12 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "scratch"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2"
|
||||
|
||||
[[package]]
|
||||
name = "sdd"
|
||||
version = "3.0.10"
|
||||
|
|
@ -531,6 +976,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -550,7 +996,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -589,7 +1035,7 @@ checksum = "0a7d91949b85b0d2fb687445e448b40d322b6b3e4af6b44a29b21d9a5f33e6d9"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -616,6 +1062,23 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4af28eeb7c18ac2dbdb255d40bee63f203120e1db6b0024b177746ebec7049c1"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.117"
|
||||
|
|
@ -640,18 +1103,65 @@ dependencies = [
|
|||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.2+wasi-0.2.9"
|
||||
|
|
@ -687,7 +1197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
"indexmap 2.13.0",
|
||||
"wasm-encoder",
|
||||
"wasmparser",
|
||||
]
|
||||
|
|
@ -700,10 +1210,41 @@ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
|
|||
dependencies = [
|
||||
"bitflags",
|
||||
"hashbrown 0.15.5",
|
||||
"indexmap",
|
||||
"indexmap 2.13.0",
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
|
|
@ -747,9 +1288,9 @@ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"indexmap 2.13.0",
|
||||
"prettyplease",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wasm-metadata",
|
||||
"wit-bindgen-core",
|
||||
"wit-component",
|
||||
|
|
@ -765,7 +1306,7 @@ dependencies = [
|
|||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.117",
|
||||
"wit-bindgen-core",
|
||||
"wit-bindgen-rust",
|
||||
]
|
||||
|
|
@ -778,7 +1319,7 @@ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"indexmap",
|
||||
"indexmap 2.13.0",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
|
|
@ -797,7 +1338,7 @@ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"id-arena",
|
||||
"indexmap",
|
||||
"indexmap 2.13.0",
|
||||
"log",
|
||||
"semver",
|
||||
"serde",
|
||||
|
|
|
|||
3
TODO.md
3
TODO.md
|
|
@ -1,3 +0,0 @@
|
|||
- [ ] rename all `::std::os::raw` instances to ``::core::ffi`
|
||||
|
||||
- [ ] I probably don't need my implementations of `NixError` and `NixVerbosity` now, I could just re-export them for sys
|
||||
52
flake.nix
52
flake.nix
|
|
@ -96,6 +96,32 @@
|
|||
nixForBindings
|
||||
];
|
||||
|
||||
# bindgen uses clang to generate bindings, but it doesn't know where to
|
||||
# find our stdenv cc's headers, so when it's gcc, we need to tell it.
|
||||
postConfigure = lib.optionalString pkgs.stdenv.cc.isGNU ''
|
||||
#!/usr/bin/env bash
|
||||
# REF: https://github.com/nixops4/nix-bindings-rust/blob/main/bindgen-gcc.sh
|
||||
# Rust bindgen uses Clang to generate bindings, but that means that it can't
|
||||
# find the "system" or compiler headers when the stdenv compiler is GCC.
|
||||
# This script tells it where to find them.
|
||||
|
||||
echo "Extending BINDGEN_EXTRA_CLANG_ARGS with system include paths..." 2>&1
|
||||
BINDGEN_EXTRA_CLANG_ARGS="$${BINDGEN_EXTRA_CLANG_ARGS:-}"
|
||||
export BINDGEN_EXTRA_CLANG_ARGS
|
||||
include_paths=$(
|
||||
echo | $NIX_CC_UNWRAPPED -v -E -x c - 2>&1 \
|
||||
| awk '/#include <...> search starts here:/{flag=1;next} \
|
||||
/End of search list./{flag=0} \
|
||||
flag==1 {print $1}'
|
||||
)
|
||||
for path in $include_paths; do
|
||||
echo " - $path" 2>&1
|
||||
BINDGEN_EXTRA_CLANG_ARGS="$BINDGEN_EXTRA_CLANG_ARGS -I$path"
|
||||
done
|
||||
'';
|
||||
|
||||
shellHook = postConfigure;
|
||||
|
||||
env = let
|
||||
inherit (llvmPackages) llvm libclang;
|
||||
in {
|
||||
|
|
@ -155,6 +181,32 @@
|
|||
nixForBindings
|
||||
];
|
||||
|
||||
# bindgen uses clang to generate bindings, but it doesn't know where to
|
||||
# find our stdenv cc's headers, so when it's gcc, we need to tell it.
|
||||
postConfigure = lib.optionalString pkgs.stdenv.cc.isGNU ''
|
||||
#!/usr/bin/env bash
|
||||
# REF: https://github.com/nixops4/nix-bindings-rust/blob/main/bindgen-gcc.sh
|
||||
# Rust bindgen uses Clang to generate bindings, but that means that it can't
|
||||
# find the "system" or compiler headers when the stdenv compiler is GCC.
|
||||
# This script tells it where to find them.
|
||||
|
||||
echo "Extending BINDGEN_EXTRA_CLANG_ARGS with system include paths..." 2>&1
|
||||
BINDGEN_EXTRA_CLANG_ARGS="$${BINDGEN_EXTRA_CLANG_ARGS:-}"
|
||||
export BINDGEN_EXTRA_CLANG_ARGS
|
||||
include_paths=$(
|
||||
echo | $NIX_CC_UNWRAPPED -v -E -x c - 2>&1 \
|
||||
| awk '/#include <...> search starts here:/{flag=1;next} \
|
||||
/End of search list./{flag=0} \
|
||||
flag==1 {print $1}'
|
||||
)
|
||||
for path in $include_paths; do
|
||||
echo " - $path" 2>&1
|
||||
BINDGEN_EXTRA_CLANG_ARGS="$BINDGEN_EXTRA_CLANG_ARGS -I$path"
|
||||
done
|
||||
'';
|
||||
|
||||
shellHook = postConfigure;
|
||||
|
||||
env = let
|
||||
inherit (llvmPackages) llvm libclang;
|
||||
in {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ build = "build.rs"
|
|||
targets = [ "x86_64-unknown-linux-gnu" ]
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
path = "lib.rs"
|
||||
|
||||
# NOTE: `[features]` have a 1-1 correspondence to the
|
||||
# NOTE: shared libraries produced by the Nix C API.
|
||||
|
|
@ -28,14 +28,15 @@ nix-flake-c = []
|
|||
nix-main-c = []
|
||||
|
||||
[build-dependencies]
|
||||
itertools = "0.14.0"
|
||||
heck = "0.5.0"
|
||||
|
||||
# rust-bindgen
|
||||
bindgen = { default-features = false, features = [ "logging", "runtime" ], version = "0.72.1" }
|
||||
doxygen-bindgen = "0.1.3"
|
||||
itertools = "0.14.0"
|
||||
pkg-config.workspace = true
|
||||
cc.workspace = true
|
||||
autocxx-build = "0.30.0"
|
||||
|
||||
[dev-dependencies]
|
||||
serial_test = "3.4.0"
|
||||
|
||||
[dependencies]
|
||||
autocxx = "0.30.0"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::{env, fs};
|
||||
|
||||
use bindgen::RustEdition;
|
||||
use bindgen::callbacks::{ItemKind, ParseCallbacks};
|
||||
use heck::ToSnekCase;
|
||||
use heck::ToUpperCamelCase;
|
||||
use bindgen::callbacks::ParseCallbacks;
|
||||
use itertools::Itertools;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -23,57 +19,7 @@ impl ParseCallbacks for DoxygenCallbacks {
|
|||
}
|
||||
}
|
||||
|
||||
/// Bindfmt is just the name im giving to the callbacks
|
||||
/// that handle renaming C/C++ tokens.
|
||||
#[derive(Debug)]
|
||||
struct BindfmtCallbacks;
|
||||
|
||||
#[inline]
|
||||
fn strip_variant_prefix(
|
||||
prefix: &'static str,
|
||||
enum_name: &str,
|
||||
variant: &str,
|
||||
) -> Result<String, String> {
|
||||
variant
|
||||
.strip_prefix(prefix)
|
||||
.map(str::to_owned)
|
||||
.ok_or(format!(
|
||||
"[bindfmt] enum {enum_name} expected prefix \"{prefix}\" but got {}",
|
||||
&variant
|
||||
))
|
||||
}
|
||||
|
||||
impl ParseCallbacks for BindfmtCallbacks {
|
||||
fn enum_variant_name(
|
||||
&self,
|
||||
_enum_name: Option<&str>,
|
||||
_original_variant_name: &str,
|
||||
_variant_value: bindgen::callbacks::EnumVariantValue,
|
||||
) -> Option<String> {
|
||||
let variant = _original_variant_name.to_upper_camel_case();
|
||||
|
||||
_enum_name.map(|enum_name| match enum_name.to_upper_camel_case().as_ref() {
|
||||
"NixVerbosity" => strip_variant_prefix("NixLvl", enum_name, &variant).unwrap(),
|
||||
"NixErr" => strip_variant_prefix("NixErr", enum_name, &variant)
|
||||
.or_else(|_| strip_variant_prefix("Nix", enum_name, &variant))
|
||||
.unwrap(),
|
||||
"ValueType" => strip_variant_prefix("NixType", enum_name, &variant).unwrap(),
|
||||
_ => variant,
|
||||
})
|
||||
}
|
||||
|
||||
fn item_name(&self, _item_info: bindgen::callbacks::ItemInfo) -> Option<String> {
|
||||
Some(match _item_info.kind {
|
||||
ItemKind::Type => _item_info.name.to_upper_camel_case(),
|
||||
_ => _item_info.name.to_snek_case(),
|
||||
})
|
||||
}
|
||||
|
||||
fn include_file(&self, _filename: &str) {
|
||||
eprintln!("[debug] including file: {}", _filename);
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING: NOTE: the random panic occurs when you're missing imports!!
|
||||
const LIBS: &[&'static str] = &[
|
||||
#[cfg(feature = "nix-util-c")]
|
||||
"nix-util-c",
|
||||
|
|
@ -90,8 +36,14 @@ const LIBS: &[&'static str] = &[
|
|||
];
|
||||
|
||||
fn main() {
|
||||
let include_paths: Vec<PathBuf> = LIBS
|
||||
.iter()
|
||||
// Invalidate the built crate if the binding headers change
|
||||
// println!("cargo::rerun-if-changed=include");
|
||||
|
||||
let lib_args: Vec<String> = vec![ /* EXTRA ARGS */ ]
|
||||
.into_iter()
|
||||
.map(|s: &str| s.to_owned())
|
||||
.chain(
|
||||
LIBS.iter()
|
||||
.map(|&name| {
|
||||
let lib = pkg_config::probe_library(name)
|
||||
.expect(&format!("Unable to find .pc file for {}", name));
|
||||
|
|
@ -101,50 +53,25 @@ fn main() {
|
|||
}
|
||||
|
||||
lib.include_paths
|
||||
.into_iter()
|
||||
.map(|p| format!("-I{}", p.display()))
|
||||
})
|
||||
.flatten()
|
||||
.flatten(),
|
||||
)
|
||||
.unique()
|
||||
.collect();
|
||||
|
||||
let clang_args: Vec<String> = vec!["-x", "c++", "-std=c++23"]
|
||||
.into_iter()
|
||||
.map(|s: &str| s.to_owned())
|
||||
.chain(include_paths.iter().map(|p| format!("-I{}", p.display())))
|
||||
.collect();
|
||||
|
||||
dbg!(&clang_args);
|
||||
dbg!(&lib_args);
|
||||
|
||||
let mut builder = bindgen::Builder::default()
|
||||
.rust_edition(RustEdition::Edition2024)
|
||||
.clang_args(clang_args)
|
||||
// .enable_cxx_namespaces()
|
||||
.clang_args(lib_args)
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||
// Add `doxygen_bindgen` callbacks
|
||||
.parse_callbacks(Box::new(DoxygenCallbacks))
|
||||
.parse_callbacks(Box::new(BindfmtCallbacks))
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||
// Format generated bindings with rustfmt
|
||||
.formatter(bindgen::Formatter::Rustfmt)
|
||||
.rustfmt_configuration_file(std::fs::canonicalize("rustfmt.toml").ok())
|
||||
.allowlist_file(r".*nix_api_[a-z]+\.h")
|
||||
// Wrap all unsafe operations in unsafe blocks
|
||||
.layout_tests(true)
|
||||
.use_core() // use ::core instead of ::std
|
||||
.ctypes_prefix("::core::ffi") // use ::core::ffi instead of ::std::os::raw
|
||||
.time_phases(true)
|
||||
.wrap_unsafe_ops(true)
|
||||
.trust_clang_mangling(true)
|
||||
.respect_cxx_access_specs(true)
|
||||
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false })
|
||||
.translate_enum_integer_types(false)
|
||||
.size_t_is_usize(true)
|
||||
.use_distinct_char16_t(false)
|
||||
.generate_comments(false)
|
||||
.generate_cstr(true) // use &CStr instead of &[u8]
|
||||
.fit_macro_constants(true)
|
||||
.explicit_padding(true)
|
||||
.enable_cxx_namespaces()
|
||||
.represent_cxx_operators(true)
|
||||
.enable_function_attribute_detection()
|
||||
.raw_line("/** These bindings were auto-generated for the Nixide project (https://github.com/cry128/nixide) */");
|
||||
.rustfmt_configuration_file(std::fs::canonicalize("rustfmt.toml").ok());
|
||||
|
||||
// Register the input headers we would like to generate bindings for
|
||||
builder = LIBS
|
||||
|
|
@ -153,7 +80,7 @@ fn main() {
|
|||
let path = format!("include/{}.h", lib.strip_suffix("-c").unwrap());
|
||||
assert!(fs::exists(&path).unwrap());
|
||||
// Invalidate the built crate if the binding headers change
|
||||
println!("cargo::rerun-if-changed={path}");
|
||||
// println!("cargo::rerun-if-changed={path}");
|
||||
path
|
||||
})
|
||||
.fold(builder, |builder, path| builder.header(path));
|
||||
|
|
|
|||
17
nixide-sys/lib.rs
Normal file
17
nixide-sys/lib.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
//! # nixide-sys
|
||||
//!
|
||||
//! Unsafe direct FFI bindings to libnix C API.
|
||||
//!
|
||||
//! ## Safety
|
||||
//!
|
||||
//! These bindings are generated automatically and map directly to the C API.
|
||||
//! They are unsafe to use directly. Prefer using the high-level safe API in the
|
||||
//! parent crate unless you know what you're doing.
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(rustdoc::bare_urls)]
|
||||
#![allow(rustdoc::invalid_html_tags)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
||||
impl Display for crate::ValueType {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
Debug::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
|
@ -1 +0,0 @@
|
|||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
|
@ -1 +0,0 @@
|
|||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
#![allow(unused_imports)]
|
||||
|
||||
#[cfg(feature = "nix-expr-c")]
|
||||
mod expr;
|
||||
#[cfg(feature = "nix-expr-c")]
|
||||
pub use expr::*;
|
||||
|
||||
#[cfg(feature = "nix-fetchers-c")]
|
||||
mod fetchers;
|
||||
#[cfg(feature = "nix-fetchers-c")]
|
||||
pub use fetchers::*;
|
||||
|
||||
#[cfg(feature = "nix-flake-c")]
|
||||
mod flake;
|
||||
#[cfg(feature = "nix-flake-c")]
|
||||
pub use flake::*;
|
||||
|
||||
#[cfg(feature = "nix-main-c")]
|
||||
mod main;
|
||||
#[cfg(feature = "nix-main-c")]
|
||||
pub use main::*;
|
||||
|
||||
#[cfg(feature = "nix-store-c")]
|
||||
mod store;
|
||||
#[cfg(feature = "nix-store-c")]
|
||||
pub use store::*;
|
||||
|
||||
#[cfg(feature = "nix-util-c")]
|
||||
mod util;
|
||||
#[cfg(feature = "nix-util-c")]
|
||||
pub use util::*;
|
||||
|
|
@ -1 +0,0 @@
|
|||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
||||
impl Display for crate::NixErr {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
Debug::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for crate::NixVerbosity {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
Debug::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
//! # nixide-sys
|
||||
//!
|
||||
//! Unsafe direct FFI bindings to `libnix` C API.
|
||||
//!
|
||||
//! ## Safety
|
||||
//!
|
||||
//! These bindings are generated automatically and map directly to the C API.
|
||||
//! They are unsafe to use directly. Prefer using the high-level safe API in the
|
||||
//! parent crate unless you know what you're doing.
|
||||
//!
|
||||
//! The [nixide] crate should also act as good explanation of how
|
||||
//! these bindings, and hence `libnix` itself, are expected to be used.
|
||||
|
||||
mod bindings {
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(rustdoc::bare_urls)]
|
||||
#![allow(rustdoc::invalid_html_tags)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
}
|
||||
pub use bindings::root::*;
|
||||
|
||||
mod exts;
|
||||
#[allow(unused_imports)]
|
||||
pub use exts::*;
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# `nixide-sys/tests`
|
||||
These tests are modified from the ones provided by [github:nixops4/nix-bindings-rust](https://github.com/nixops4/nix-bindings-rust)
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
#![cfg(feature = "nix-expr-c")]
|
||||
#![cfg(test)]
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ptr;
|
||||
|
||||
use serial_test::serial;
|
||||
use std::{
|
||||
ffi::{CStr, CString},
|
||||
ptr,
|
||||
};
|
||||
|
||||
use nixide_sys::*;
|
||||
use serial_test::serial;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
|
|
@ -15,13 +16,13 @@ fn eval_init_and_state_build() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok, "nix_libutil_init failed: {err}");
|
||||
assert_eq!(err, nix_err_NIX_OK, "nix_libutil_init failed: {err}");
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok, "nix_libstore_init failed: {err}");
|
||||
assert_eq!(err, nix_err_NIX_OK, "nix_libstore_init failed: {err}");
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok, "nix_libexpr_init failed: {err}");
|
||||
assert_eq!(err, nix_err_NIX_OK, "nix_libexpr_init failed: {err}");
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -30,7 +31,7 @@ fn eval_init_and_state_build() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -50,20 +51,20 @@ fn eval_simple_expression() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok, "nix_libutil_init failed: {err}");
|
||||
assert_eq!(err, nix_err_NIX_OK, "nix_libutil_init failed: {err}");
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok, "nix_libstore_init failed: {err}");
|
||||
assert_eq!(err, nix_err_NIX_OK, "nix_libstore_init failed: {err}");
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok, "nix_libexpr_init failed: {err}");
|
||||
assert_eq!(err, nix_err_NIX_OK, "nix_libexpr_init failed: {err}");
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
||||
let builder = nix_eval_state_builder_new(ctx, store);
|
||||
assert!(!builder.is_null());
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), NixErr::Ok);
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -75,11 +76,11 @@ fn eval_simple_expression() {
|
|||
assert!(!value.is_null());
|
||||
|
||||
let eval_err = nix_expr_eval_from_string(ctx, state, expr.as_ptr(), path.as_ptr(), value);
|
||||
assert_eq!(eval_err, NixErr::Ok);
|
||||
assert_eq!(eval_err, nix_err_NIX_OK);
|
||||
|
||||
// Force the value (should not be a thunk)
|
||||
let force_err = nix_value_force(ctx, state, value);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
nix_state_free(state);
|
||||
nix_eval_state_builder_free(builder);
|
||||
|
|
@ -95,25 +96,25 @@ fn value_construction_and_inspection() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
let builder = nix_eval_state_builder_new(ctx, store);
|
||||
assert!(!builder.is_null());
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), NixErr::Ok);
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), nix_err_NIX_OK);
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
||||
// Int
|
||||
let int_val = nix_alloc_value(ctx, state);
|
||||
assert!(!int_val.is_null());
|
||||
assert_eq!(nix_init_int(ctx, int_val, 42), NixErr::Ok);
|
||||
assert_eq!(nix_get_type(ctx, int_val), ValueType::Int);
|
||||
assert_eq!(nix_init_int(ctx, int_val, 42), nix_err_NIX_OK);
|
||||
assert_eq!(nix_get_type(ctx, int_val), ValueType_NIX_TYPE_INT);
|
||||
assert_eq!(nix_get_int(ctx, int_val), 42);
|
||||
|
||||
// Float
|
||||
|
|
@ -121,30 +122,30 @@ fn value_construction_and_inspection() {
|
|||
assert!(!float_val.is_null());
|
||||
assert_eq!(
|
||||
nix_init_float(ctx, float_val, std::f64::consts::PI),
|
||||
NixErr::Ok
|
||||
nix_err_NIX_OK
|
||||
);
|
||||
assert_eq!(nix_get_type(ctx, float_val), ValueType::Float);
|
||||
assert_eq!(nix_get_type(ctx, float_val), ValueType_NIX_TYPE_FLOAT);
|
||||
assert!((nix_get_float(ctx, float_val) - std::f64::consts::PI).abs() < 1e-10);
|
||||
|
||||
// Bool
|
||||
let bool_val = nix_alloc_value(ctx, state);
|
||||
assert!(!bool_val.is_null());
|
||||
assert_eq!(nix_init_bool(ctx, bool_val, true), NixErr::Ok);
|
||||
assert_eq!(nix_get_type(ctx, bool_val), ValueType::Bool);
|
||||
assert_eq!(nix_init_bool(ctx, bool_val, true), nix_err_NIX_OK);
|
||||
assert_eq!(nix_get_type(ctx, bool_val), ValueType_NIX_TYPE_BOOL);
|
||||
assert!(nix_get_bool(ctx, bool_val));
|
||||
|
||||
// Null
|
||||
let null_val = nix_alloc_value(ctx, state);
|
||||
assert!(!null_val.is_null());
|
||||
assert_eq!(nix_init_null(ctx, null_val), NixErr::Ok);
|
||||
assert_eq!(nix_get_type(ctx, null_val), ValueType::Null);
|
||||
assert_eq!(nix_init_null(ctx, null_val), nix_err_NIX_OK);
|
||||
assert_eq!(nix_get_type(ctx, null_val), ValueType_NIX_TYPE_NULL);
|
||||
|
||||
// String
|
||||
let string_val = nix_alloc_value(ctx, state);
|
||||
assert!(!string_val.is_null());
|
||||
let s = CString::new("hello world").unwrap();
|
||||
assert_eq!(nix_init_string(ctx, string_val, s.as_ptr()), NixErr::Ok);
|
||||
assert_eq!(nix_get_type(ctx, string_val), ValueType::String);
|
||||
assert_eq!(nix_init_string(ctx, string_val, s.as_ptr()), nix_err_NIX_OK);
|
||||
assert_eq!(nix_get_type(ctx, string_val), ValueType_NIX_TYPE_STRING);
|
||||
extern "C" fn string_cb(
|
||||
start: *const ::std::os::raw::c_char,
|
||||
n: ::std::os::raw::c_uint,
|
||||
|
|
@ -158,7 +159,7 @@ fn value_construction_and_inspection() {
|
|||
let mut got: Option<String> = None;
|
||||
assert_eq!(
|
||||
nix_get_string(ctx, string_val, Some(string_cb), (&raw mut got).cast()),
|
||||
NixErr::Ok
|
||||
nix_err_NIX_OK
|
||||
);
|
||||
assert_eq!(got.as_deref(), Some("hello world"));
|
||||
|
||||
|
|
@ -168,9 +169,9 @@ fn value_construction_and_inspection() {
|
|||
let p = CString::new("/nix/store/foo").unwrap();
|
||||
assert_eq!(
|
||||
nix_init_path_string(ctx, state, path_val, p.as_ptr()),
|
||||
NixErr::Ok
|
||||
nix_err_NIX_OK
|
||||
);
|
||||
assert_eq!(nix_get_type(ctx, path_val), ValueType::Path);
|
||||
assert_eq!(nix_get_type(ctx, path_val), ValueType_NIX_TYPE_PATH);
|
||||
let path_ptr = nix_get_path_string(ctx, path_val);
|
||||
assert!(!path_ptr.is_null());
|
||||
let path_str = CStr::from_ptr(path_ptr).to_string_lossy();
|
||||
|
|
@ -191,17 +192,17 @@ fn list_and_attrset_manipulation() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
let builder = nix_eval_state_builder_new(ctx, store);
|
||||
assert!(!builder.is_null());
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), NixErr::Ok);
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), nix_err_NIX_OK);
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
||||
|
|
@ -219,15 +220,15 @@ fn list_and_attrset_manipulation() {
|
|||
nix_list_builder_insert(ctx, list_builder, 2, v3);
|
||||
|
||||
let list_val = nix_alloc_value(ctx, state);
|
||||
assert_eq!(nix_make_list(ctx, list_builder, list_val), NixErr::Ok);
|
||||
assert_eq!(nix_get_type(ctx, list_val), ValueType::List);
|
||||
assert_eq!(nix_make_list(ctx, list_builder, list_val), nix_err_NIX_OK);
|
||||
assert_eq!(nix_get_type(ctx, list_val), ValueType_NIX_TYPE_LIST);
|
||||
assert_eq!(nix_get_list_size(ctx, list_val), 3);
|
||||
|
||||
// Get elements by index
|
||||
for i in 0..3 {
|
||||
let elem = nix_get_list_byidx(ctx, list_val, state, i);
|
||||
assert!(!elem.is_null());
|
||||
assert_eq!(nix_get_type(ctx, elem), ValueType::Int);
|
||||
assert_eq!(nix_get_type(ctx, elem), ValueType_NIX_TYPE_INT);
|
||||
assert_eq!(nix_get_int(ctx, elem), i64::from(i + 1));
|
||||
}
|
||||
|
||||
|
|
@ -247,19 +248,19 @@ fn list_and_attrset_manipulation() {
|
|||
nix_bindings_builder_insert(ctx, attr_builder, bar.as_ptr(), bar_val);
|
||||
|
||||
let attr_val = nix_alloc_value(ctx, state);
|
||||
assert_eq!(nix_make_attrs(ctx, attr_val, attr_builder), NixErr::Ok);
|
||||
assert_eq!(nix_get_type(ctx, attr_val), ValueType::Attrs);
|
||||
assert_eq!(nix_make_attrs(ctx, attr_val, attr_builder), nix_err_NIX_OK);
|
||||
assert_eq!(nix_get_type(ctx, attr_val), ValueType_NIX_TYPE_ATTRS);
|
||||
assert_eq!(nix_get_attrs_size(ctx, attr_val), 2);
|
||||
|
||||
// Get by name
|
||||
let foo_got = nix_get_attr_byname(ctx, attr_val, state, foo.as_ptr());
|
||||
assert!(!foo_got.is_null());
|
||||
assert_eq!(nix_get_type(ctx, foo_got), ValueType::Int);
|
||||
assert_eq!(nix_get_type(ctx, foo_got), ValueType_NIX_TYPE_INT);
|
||||
assert_eq!(nix_get_int(ctx, foo_got), 42);
|
||||
|
||||
let bar_got = nix_get_attr_byname(ctx, attr_val, state, bar.as_ptr());
|
||||
assert!(!bar_got.is_null());
|
||||
assert_eq!(nix_get_type(ctx, bar_got), ValueType::String);
|
||||
assert_eq!(nix_get_type(ctx, bar_got), ValueType_NIX_TYPE_STRING);
|
||||
|
||||
// Has attr
|
||||
assert!(nix_has_attr_byname(ctx, attr_val, state, foo.as_ptr()));
|
||||
|
|
@ -281,17 +282,17 @@ fn function_application_and_force() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
let builder = nix_eval_state_builder_new(ctx, store);
|
||||
assert!(!builder.is_null());
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), NixErr::Ok);
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), nix_err_NIX_OK);
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
||||
|
|
@ -302,7 +303,7 @@ fn function_application_and_force() {
|
|||
assert!(!fn_val.is_null());
|
||||
assert_eq!(
|
||||
nix_expr_eval_from_string(ctx, state, expr.as_ptr(), path.as_ptr(), fn_val),
|
||||
NixErr::Ok
|
||||
nix_err_NIX_OK
|
||||
);
|
||||
|
||||
// Argument: 41
|
||||
|
|
@ -314,16 +315,16 @@ fn function_application_and_force() {
|
|||
assert!(!result_val.is_null());
|
||||
assert_eq!(
|
||||
nix_value_call(ctx, state, fn_val, arg_val, result_val),
|
||||
NixErr::Ok
|
||||
nix_err_NIX_OK
|
||||
);
|
||||
|
||||
// Force result
|
||||
assert_eq!(nix_value_force(ctx, state, result_val), NixErr::Ok);
|
||||
assert_eq!(nix_get_type(ctx, result_val), ValueType::Int);
|
||||
assert_eq!(nix_value_force(ctx, state, result_val), nix_err_NIX_OK);
|
||||
assert_eq!(nix_get_type(ctx, result_val), ValueType_NIX_TYPE_INT);
|
||||
assert_eq!(nix_get_int(ctx, result_val), 42);
|
||||
|
||||
// Deep force (should be a no-op for int)
|
||||
assert_eq!(nix_value_force_deep(ctx, state, result_val), NixErr::Ok);
|
||||
assert_eq!(nix_value_force_deep(ctx, state, result_val), nix_err_NIX_OK);
|
||||
|
||||
nix_state_free(state);
|
||||
nix_eval_state_builder_free(builder);
|
||||
|
|
@ -339,17 +340,17 @@ fn error_handling_invalid_expression() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
let builder = nix_eval_state_builder_new(ctx, store);
|
||||
assert!(!builder.is_null());
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), NixErr::Ok);
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), nix_err_NIX_OK);
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
||||
|
|
@ -359,7 +360,7 @@ fn error_handling_invalid_expression() {
|
|||
let value = nix_alloc_value(ctx, state);
|
||||
assert!(!value.is_null());
|
||||
let eval_err = nix_expr_eval_from_string(ctx, state, expr.as_ptr(), path.as_ptr(), value);
|
||||
assert_ne!(eval_err, NixErr::Ok);
|
||||
assert_ne!(eval_err, nix_err_NIX_OK);
|
||||
|
||||
nix_state_free(state);
|
||||
nix_eval_state_builder_free(builder);
|
||||
|
|
@ -375,24 +376,24 @@ fn realised_string_and_gc() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
let builder = nix_eval_state_builder_new(ctx, store);
|
||||
assert!(!builder.is_null());
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), NixErr::Ok);
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), nix_err_NIX_OK);
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
||||
// String value
|
||||
let string_val = nix_alloc_value(ctx, state);
|
||||
let s = CString::new("hello world").unwrap();
|
||||
assert_eq!(nix_init_string(ctx, string_val, s.as_ptr()), NixErr::Ok);
|
||||
assert_eq!(nix_init_string(ctx, string_val, s.as_ptr()), nix_err_NIX_OK);
|
||||
|
||||
// Realise string
|
||||
let realised = nix_string_realise(ctx, state, string_val, false);
|
||||
|
|
@ -421,18 +422,18 @@ fn big_thunk_evaluation() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
||||
let builder = nix_eval_state_builder_new(ctx, store);
|
||||
assert!(!builder.is_null());
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), NixErr::Ok);
|
||||
assert_eq!(nix_eval_state_builder_load(ctx, builder), nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -445,10 +446,10 @@ fn big_thunk_evaluation() {
|
|||
assert!(!value.is_null());
|
||||
|
||||
let eval_err = nix_expr_eval_from_string(ctx, state, expr.as_ptr(), path.as_ptr(), value);
|
||||
assert_eq!(eval_err, NixErr::Ok);
|
||||
assert_eq!(eval_err, nix_err_NIX_OK);
|
||||
|
||||
// The top-level should be an attrset
|
||||
assert_eq!(nix_get_type(ctx, value), ValueType::Attrs);
|
||||
assert_eq!(nix_get_type(ctx, value), ValueType_NIX_TYPE_ATTRS);
|
||||
|
||||
// Get "result" attribute (ts should be a thunk initially)
|
||||
let result_name = CString::new("result").unwrap();
|
||||
|
|
@ -457,9 +458,9 @@ fn big_thunk_evaluation() {
|
|||
|
||||
// Force the result
|
||||
let force_err = nix_value_force(ctx, state, result_val);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
assert_eq!(nix_get_type(ctx, result_val), ValueType::Int);
|
||||
assert_eq!(nix_get_type(ctx, result_val), ValueType_NIX_TYPE_INT);
|
||||
assert_eq!(nix_get_int(ctx, result_val), 13); // ((1+2)*3)+4 = 13
|
||||
|
||||
// Get "other" attribute
|
||||
|
|
@ -468,9 +469,9 @@ fn big_thunk_evaluation() {
|
|||
assert!(!other_val.is_null());
|
||||
|
||||
let force_err2 = nix_value_force(ctx, state, other_val);
|
||||
assert_eq!(force_err2, NixErr::Ok);
|
||||
assert_eq!(force_err2, nix_err_NIX_OK);
|
||||
|
||||
assert_eq!(nix_get_type(ctx, other_val), ValueType::Int);
|
||||
assert_eq!(nix_get_type(ctx, other_val), ValueType_NIX_TYPE_INT);
|
||||
assert_eq!(nix_get_int(ctx, other_val), 3); // 1+2 = 3
|
||||
|
||||
nix_state_free(state);
|
||||
|
|
@ -488,13 +489,13 @@ fn multi_argument_function_calls() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -503,7 +504,7 @@ fn multi_argument_function_calls() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -517,15 +518,15 @@ fn multi_argument_function_calls() {
|
|||
|
||||
let eval_err =
|
||||
nix_expr_eval_from_string(ctx, state, expr.as_ptr(), path.as_ptr(), func_value);
|
||||
assert_eq!(eval_err, NixErr::Ok);
|
||||
assert_eq!(eval_err, nix_err_NIX_OK);
|
||||
|
||||
// Force evaluation of the function
|
||||
let force_err = nix_value_force(ctx, state, func_value);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
// Verify it's a function
|
||||
let func_type = nix_get_type(ctx, func_value);
|
||||
assert_eq!(func_type, ValueType::Function);
|
||||
assert_eq!(func_type, ValueType_NIX_TYPE_FUNCTION);
|
||||
|
||||
// Create arguments
|
||||
let arg1 = nix_alloc_value(ctx, state);
|
||||
|
|
@ -534,8 +535,8 @@ fn multi_argument_function_calls() {
|
|||
|
||||
let init_arg1_err = nix_init_int(ctx, arg1, 10);
|
||||
let init_arg2_err = nix_init_int(ctx, arg2, 20);
|
||||
assert_eq!(init_arg1_err, NixErr::Ok);
|
||||
assert_eq!(init_arg2_err, NixErr::Ok);
|
||||
assert_eq!(init_arg1_err, nix_err_NIX_OK);
|
||||
assert_eq!(init_arg2_err, nix_err_NIX_OK);
|
||||
|
||||
// Test multi-argument call using nix_value_call_multi
|
||||
let mut args = [arg1, arg2];
|
||||
|
|
@ -543,15 +544,15 @@ fn multi_argument_function_calls() {
|
|||
assert!(!result.is_null());
|
||||
|
||||
let call_err = nix_value_call_multi(ctx, state, func_value, 2, args.as_mut_ptr(), result);
|
||||
assert_eq!(call_err, NixErr::Ok);
|
||||
assert_eq!(call_err, nix_err_NIX_OK);
|
||||
|
||||
// Force the result
|
||||
let force_result_err = nix_value_force(ctx, state, result);
|
||||
assert_eq!(force_result_err, NixErr::Ok);
|
||||
assert_eq!(force_result_err, nix_err_NIX_OK);
|
||||
|
||||
// Check result type and value
|
||||
let result_type = nix_get_type(ctx, result);
|
||||
assert_eq!(result_type, ValueType::Int);
|
||||
assert_eq!(result_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let result_value = nix_get_int(ctx, result);
|
||||
assert_eq!(result_value, 30); // 10 + 20
|
||||
|
|
@ -576,13 +577,13 @@ fn curried_function_evaluation() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -591,7 +592,7 @@ fn curried_function_evaluation() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -605,7 +606,7 @@ fn curried_function_evaluation() {
|
|||
|
||||
let eval_err =
|
||||
nix_expr_eval_from_string(ctx, state, expr.as_ptr(), path.as_ptr(), func_value);
|
||||
assert_eq!(eval_err, NixErr::Ok);
|
||||
assert_eq!(eval_err, nix_err_NIX_OK);
|
||||
|
||||
// Create three arguments
|
||||
let arg1 = nix_alloc_value(ctx, state);
|
||||
|
|
@ -623,15 +624,15 @@ fn curried_function_evaluation() {
|
|||
assert!(!result.is_null());
|
||||
|
||||
let call_err = nix_value_call_multi(ctx, state, func_value, 3, args.as_mut_ptr(), result);
|
||||
assert_eq!(call_err, NixErr::Ok);
|
||||
assert_eq!(call_err, nix_err_NIX_OK);
|
||||
|
||||
// Force the result
|
||||
let force_result_err = nix_value_force(ctx, state, result);
|
||||
assert_eq!(force_result_err, NixErr::Ok);
|
||||
assert_eq!(force_result_err, nix_err_NIX_OK);
|
||||
|
||||
// Check result
|
||||
let result_type = nix_get_type(ctx, result);
|
||||
assert_eq!(result_type, ValueType::Int);
|
||||
assert_eq!(result_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let result_value = nix_get_int(ctx, result);
|
||||
assert_eq!(result_value, 30); // 5 + 10 + 15
|
||||
|
|
@ -641,42 +642,42 @@ fn curried_function_evaluation() {
|
|||
assert!(!partial1.is_null());
|
||||
|
||||
let partial_call1_err = nix_value_call(ctx, state, func_value, arg1, partial1);
|
||||
assert_eq!(partial_call1_err, NixErr::Ok);
|
||||
assert_eq!(partial_call1_err, nix_err_NIX_OK);
|
||||
|
||||
// partial1 should still be a function
|
||||
let force_partial1_err = nix_value_force(ctx, state, partial1);
|
||||
assert_eq!(force_partial1_err, NixErr::Ok);
|
||||
assert_eq!(force_partial1_err, nix_err_NIX_OK);
|
||||
|
||||
let partial1_type = nix_get_type(ctx, partial1);
|
||||
assert_eq!(partial1_type, ValueType::Function);
|
||||
assert_eq!(partial1_type, ValueType_NIX_TYPE_FUNCTION);
|
||||
|
||||
// Apply second argument
|
||||
let partial2 = nix_alloc_value(ctx, state);
|
||||
assert!(!partial2.is_null());
|
||||
|
||||
let partial_call2_err = nix_value_call(ctx, state, partial1, arg2, partial2);
|
||||
assert_eq!(partial_call2_err, NixErr::Ok);
|
||||
assert_eq!(partial_call2_err, nix_err_NIX_OK);
|
||||
|
||||
// partial2 should still be a function
|
||||
let force_partial2_err = nix_value_force(ctx, state, partial2);
|
||||
assert_eq!(force_partial2_err, NixErr::Ok);
|
||||
assert_eq!(force_partial2_err, nix_err_NIX_OK);
|
||||
|
||||
let partial2_type = nix_get_type(ctx, partial2);
|
||||
assert_eq!(partial2_type, ValueType::Function);
|
||||
assert_eq!(partial2_type, ValueType_NIX_TYPE_FUNCTION);
|
||||
|
||||
// Apply final argument
|
||||
let final_result = nix_alloc_value(ctx, state);
|
||||
assert!(!final_result.is_null());
|
||||
|
||||
let final_call_err = nix_value_call(ctx, state, partial2, arg3, final_result);
|
||||
assert_eq!(final_call_err, NixErr::Ok);
|
||||
assert_eq!(final_call_err, nix_err_NIX_OK);
|
||||
|
||||
// Force and check final result
|
||||
let force_final_err = nix_value_force(ctx, state, final_result);
|
||||
assert_eq!(force_final_err, NixErr::Ok);
|
||||
assert_eq!(force_final_err, nix_err_NIX_OK);
|
||||
|
||||
let final_type = nix_get_type(ctx, final_result);
|
||||
assert_eq!(final_type, ValueType::Int);
|
||||
assert_eq!(final_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let final_value = nix_get_int(ctx, final_result);
|
||||
assert_eq!(final_value, 30); // same result as multi-arg call
|
||||
|
|
@ -705,13 +706,13 @@ fn thunk_creation_with_init_apply() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -720,7 +721,7 @@ fn thunk_creation_with_init_apply() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -734,33 +735,33 @@ fn thunk_creation_with_init_apply() {
|
|||
|
||||
let eval_err =
|
||||
nix_expr_eval_from_string(ctx, state, func_expr.as_ptr(), path.as_ptr(), func_value);
|
||||
assert_eq!(eval_err, NixErr::Ok);
|
||||
assert_eq!(eval_err, nix_err_NIX_OK);
|
||||
|
||||
// Create an argument
|
||||
let arg = nix_alloc_value(ctx, state);
|
||||
assert!(!arg.is_null());
|
||||
|
||||
let init_arg_err = nix_init_int(ctx, arg, 21);
|
||||
assert_eq!(init_arg_err, NixErr::Ok);
|
||||
assert_eq!(init_arg_err, nix_err_NIX_OK);
|
||||
|
||||
// Create a thunk using nix_init_apply (lazy evaluation)
|
||||
let thunk = nix_alloc_value(ctx, state);
|
||||
assert!(!thunk.is_null());
|
||||
|
||||
let apply_err = nix_init_apply(ctx, thunk, func_value, arg);
|
||||
assert_eq!(apply_err, NixErr::Ok);
|
||||
assert_eq!(apply_err, nix_err_NIX_OK);
|
||||
|
||||
// Initially, the thunk should be of type THUNK
|
||||
let thunk_type = nix_get_type(ctx, thunk);
|
||||
assert_eq!(thunk_type, ValueType::Thunk);
|
||||
assert_eq!(thunk_type, ValueType_NIX_TYPE_THUNK);
|
||||
|
||||
// Force evaluation of the thunk
|
||||
let force_err = nix_value_force(ctx, state, thunk);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
// After forcing, it should be an integer
|
||||
let forced_type = nix_get_type(ctx, thunk);
|
||||
assert_eq!(forced_type, ValueType::Int);
|
||||
assert_eq!(forced_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let result_value = nix_get_int(ctx, thunk);
|
||||
assert_eq!(result_value, 42); // 21 * 2
|
||||
|
|
@ -784,13 +785,13 @@ fn lookup_path_configuration() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -813,10 +814,10 @@ fn lookup_path_configuration() {
|
|||
builder,
|
||||
lookup_path_ptrs_null_terminated.as_mut_ptr(),
|
||||
);
|
||||
assert_eq!(set_lookup_err, NixErr::Ok);
|
||||
assert_eq!(set_lookup_err, nix_err_NIX_OK);
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -835,12 +836,12 @@ fn lookup_path_configuration() {
|
|||
// The evaluation might succeed or fail depending on Nix version and
|
||||
// configuration The important thing is that setting the lookup path
|
||||
// didn't crash
|
||||
if eval_err == NixErr::Ok {
|
||||
if eval_err == nix_err_NIX_OK {
|
||||
let force_err = nix_value_force(ctx, state, result);
|
||||
if force_err == NixErr::Ok {
|
||||
if force_err == nix_err_NIX_OK {
|
||||
let result_type = nix_get_type(ctx, result);
|
||||
// nixPath should be a list
|
||||
assert_eq!(result_type, ValueType::List);
|
||||
assert_eq!(result_type, ValueType_NIX_TYPE_LIST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -861,13 +862,13 @@ fn complex_nested_evaluation() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -876,7 +877,7 @@ fn complex_nested_evaluation() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -906,7 +907,7 @@ fn complex_nested_evaluation() {
|
|||
|
||||
// Complex expressions may fail sometimes, check for both success
|
||||
// and error
|
||||
if eval_err != NixErr::Ok {
|
||||
if eval_err != nix_err_NIX_OK {
|
||||
// If evaluation fails, skip the rest of the test
|
||||
nix_value_decref(ctx, result);
|
||||
nix_state_free(state);
|
||||
|
|
@ -918,7 +919,7 @@ fn complex_nested_evaluation() {
|
|||
|
||||
// Force deep evaluation
|
||||
let force_err = nix_value_force_deep(ctx, state, result);
|
||||
if force_err != NixErr::Ok {
|
||||
if force_err != nix_err_NIX_OK {
|
||||
// If forcing fails, skip the rest of the test
|
||||
nix_value_decref(ctx, result);
|
||||
nix_state_free(state);
|
||||
|
|
@ -930,7 +931,7 @@ fn complex_nested_evaluation() {
|
|||
|
||||
// Verify result structure
|
||||
let result_type = nix_get_type(ctx, result);
|
||||
assert_eq!(result_type, ValueType::Attrs);
|
||||
assert_eq!(result_type, ValueType_NIX_TYPE_ATTRS);
|
||||
|
||||
let attrs_size = nix_get_attrs_size(ctx, result);
|
||||
assert_eq!(attrs_size, 2); // original, sum
|
||||
|
|
@ -941,7 +942,7 @@ fn complex_nested_evaluation() {
|
|||
assert!(!sum_value.is_null());
|
||||
|
||||
let sum_type = nix_get_type(ctx, sum_value);
|
||||
assert_eq!(sum_type, ValueType::Int);
|
||||
assert_eq!(sum_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let sum_result = nix_get_int(ctx, sum_value);
|
||||
assert_eq!(sum_result, 15); // 1 + 2 + 3 + 4 + 5
|
||||
|
|
@ -951,7 +952,7 @@ fn complex_nested_evaluation() {
|
|||
let original_value = nix_get_attr_byname(ctx, result, state, original_key.as_ptr());
|
||||
if !original_value.is_null() {
|
||||
let original_type = nix_get_type(ctx, original_value);
|
||||
assert_eq!(original_type, ValueType::List);
|
||||
assert_eq!(original_type, ValueType_NIX_TYPE_LIST);
|
||||
|
||||
let original_size = nix_get_list_size(ctx, original_value);
|
||||
assert_eq!(original_size, 5);
|
||||
|
|
@ -960,7 +961,7 @@ fn complex_nested_evaluation() {
|
|||
let first_elem = nix_get_list_byidx(ctx, original_value, state, 0);
|
||||
if !first_elem.is_null() {
|
||||
let first_elem_type = nix_get_type(ctx, first_elem);
|
||||
assert_eq!(first_elem_type, ValueType::Int);
|
||||
assert_eq!(first_elem_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let first_elem_value = nix_get_int(ctx, first_elem);
|
||||
assert_eq!(first_elem_value, 1);
|
||||
|
|
@ -984,13 +985,13 @@ fn evaluation_error_handling() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -999,7 +1000,7 @@ fn evaluation_error_handling() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -1013,7 +1014,7 @@ fn evaluation_error_handling() {
|
|||
|
||||
let eval_err =
|
||||
nix_expr_eval_from_string(ctx, state, invalid_expr.as_ptr(), path.as_ptr(), result);
|
||||
assert_ne!(eval_err, NixErr::Ok); // should fail
|
||||
assert_ne!(eval_err, nix_err_NIX_OK); // should fail
|
||||
|
||||
// Clear error for next test
|
||||
nix_clear_err(ctx);
|
||||
|
|
@ -1033,14 +1034,14 @@ fn evaluation_error_handling() {
|
|||
);
|
||||
|
||||
// May succeed at parse time but fail during evaluation
|
||||
if eval_err2 == NixErr::Ok {
|
||||
if eval_err2 == nix_err_NIX_OK {
|
||||
let force_err = nix_value_force(ctx, state, result2);
|
||||
assert_ne!(force_err, NixErr::Ok); // should fail during forcing
|
||||
assert_ne!(force_err, nix_err_NIX_OK); // should fail during forcing
|
||||
}
|
||||
|
||||
// Test error information retrieval
|
||||
let error_code = nix_err_code(ctx);
|
||||
assert_ne!(error_code, NixErr::Ok);
|
||||
assert_ne!(error_code, nix_err_NIX_OK);
|
||||
|
||||
// Try to get error message
|
||||
let mut error_len: std::os::raw::c_uint = 0;
|
||||
|
|
@ -1064,7 +1065,7 @@ fn evaluation_error_handling() {
|
|||
|
||||
let eval_func_err =
|
||||
nix_expr_eval_from_string(ctx, state, func_expr.as_ptr(), path.as_ptr(), func_value);
|
||||
assert_eq!(eval_func_err, NixErr::Ok);
|
||||
assert_eq!(eval_func_err, nix_err_NIX_OK);
|
||||
|
||||
// Try to call with wrong number of arguments.
|
||||
// The function expects 2, but we give 1
|
||||
|
|
@ -1086,12 +1087,12 @@ fn evaluation_error_handling() {
|
|||
);
|
||||
|
||||
// This should succeed but result should be a partially applied function
|
||||
if call_err == NixErr::Ok {
|
||||
if call_err == nix_err_NIX_OK {
|
||||
let force_err = nix_value_force(ctx, state, result3);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
let result_type = nix_get_type(ctx, result3);
|
||||
assert_eq!(result_type, ValueType::Function); // partially applied
|
||||
assert_eq!(result_type, ValueType_NIX_TYPE_FUNCTION); // partially applied
|
||||
}
|
||||
|
||||
// Clean up
|
||||
|
|
@ -1115,13 +1116,13 @@ fn builtin_function_calls() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -1130,7 +1131,7 @@ fn builtin_function_calls() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -1144,7 +1145,7 @@ fn builtin_function_calls() {
|
|||
|
||||
let eval_length_err =
|
||||
nix_expr_eval_from_string(ctx, state, length_expr.as_ptr(), path.as_ptr(), length_func);
|
||||
assert_eq!(eval_length_err, NixErr::Ok);
|
||||
assert_eq!(eval_length_err, nix_err_NIX_OK);
|
||||
|
||||
// Create a list to test with
|
||||
let list_expr = CString::new("[1 2 3 4 5]").unwrap();
|
||||
|
|
@ -1153,20 +1154,20 @@ fn builtin_function_calls() {
|
|||
|
||||
let eval_list_err =
|
||||
nix_expr_eval_from_string(ctx, state, list_expr.as_ptr(), path.as_ptr(), test_list);
|
||||
assert_eq!(eval_list_err, NixErr::Ok);
|
||||
assert_eq!(eval_list_err, nix_err_NIX_OK);
|
||||
|
||||
// Call length function with the list
|
||||
let length_result = nix_alloc_value(ctx, state);
|
||||
assert!(!length_result.is_null());
|
||||
|
||||
let call_length_err = nix_value_call(ctx, state, length_func, test_list, length_result);
|
||||
assert_eq!(call_length_err, NixErr::Ok);
|
||||
assert_eq!(call_length_err, nix_err_NIX_OK);
|
||||
|
||||
let force_length_err = nix_value_force(ctx, state, length_result);
|
||||
assert_eq!(force_length_err, NixErr::Ok);
|
||||
assert_eq!(force_length_err, nix_err_NIX_OK);
|
||||
|
||||
let length_type = nix_get_type(ctx, length_result);
|
||||
assert_eq!(length_type, ValueType::Int);
|
||||
assert_eq!(length_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let length_value = nix_get_int(ctx, length_result);
|
||||
assert_eq!(length_value, 5);
|
||||
|
|
@ -1178,7 +1179,7 @@ fn builtin_function_calls() {
|
|||
|
||||
let eval_map_err =
|
||||
nix_expr_eval_from_string(ctx, state, map_expr.as_ptr(), path.as_ptr(), map_func);
|
||||
assert_eq!(eval_map_err, NixErr::Ok);
|
||||
assert_eq!(eval_map_err, nix_err_NIX_OK);
|
||||
|
||||
// Create a simple function to map: (x: x * 2)
|
||||
let double_expr = CString::new("(x: x * 2)").unwrap();
|
||||
|
|
@ -1187,7 +1188,7 @@ fn builtin_function_calls() {
|
|||
|
||||
let eval_double_err =
|
||||
nix_expr_eval_from_string(ctx, state, double_expr.as_ptr(), path.as_ptr(), double_func);
|
||||
assert_eq!(eval_double_err, NixErr::Ok);
|
||||
assert_eq!(eval_double_err, nix_err_NIX_OK);
|
||||
|
||||
// Call map with the function and list
|
||||
let mut args = [double_func, test_list];
|
||||
|
|
@ -1196,13 +1197,13 @@ fn builtin_function_calls() {
|
|||
|
||||
let call_map_err =
|
||||
nix_value_call_multi(ctx, state, map_func, 2, args.as_mut_ptr(), map_result);
|
||||
assert_eq!(call_map_err, NixErr::Ok);
|
||||
assert_eq!(call_map_err, nix_err_NIX_OK);
|
||||
|
||||
let force_map_err = nix_value_force(ctx, state, map_result);
|
||||
assert_eq!(force_map_err, NixErr::Ok);
|
||||
assert_eq!(force_map_err, nix_err_NIX_OK);
|
||||
|
||||
let map_result_type = nix_get_type(ctx, map_result);
|
||||
assert_eq!(map_result_type, ValueType::List);
|
||||
assert_eq!(map_result_type, ValueType_NIX_TYPE_LIST);
|
||||
|
||||
let map_result_size = nix_get_list_size(ctx, map_result);
|
||||
assert_eq!(map_result_size, 5);
|
||||
|
|
@ -1212,10 +1213,10 @@ fn builtin_function_calls() {
|
|||
assert!(!first_mapped.is_null());
|
||||
|
||||
let force_first_err = nix_value_force(ctx, state, first_mapped);
|
||||
assert_eq!(force_first_err, NixErr::Ok);
|
||||
assert_eq!(force_first_err, nix_err_NIX_OK);
|
||||
|
||||
let first_mapped_type = nix_get_type(ctx, first_mapped);
|
||||
assert_eq!(first_mapped_type, ValueType::Int);
|
||||
assert_eq!(first_mapped_type, ValueType_NIX_TYPE_INT);
|
||||
|
||||
let first_mapped_value = nix_get_int(ctx, first_mapped);
|
||||
assert_eq!(first_mapped_value, 2); // 1 * 2
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@
|
|||
|
||||
use std::ptr;
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
use nixide_sys::*;
|
||||
use serial_test::serial;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
|
|
@ -33,13 +32,13 @@ fn flake_settings_add_to_eval_state_builder() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -54,8 +53,9 @@ fn flake_settings_add_to_eval_state_builder() {
|
|||
let err = nix_flake_settings_add_to_eval_state_builder(ctx, settings, builder);
|
||||
// Accept OK or ERR_UNKNOWN (depends on Nix build/config)
|
||||
assert!(
|
||||
err == NixErr::Ok || err == NixErr::Unknown,
|
||||
"nix_flake_settings_add_to_eval_state_builder returned unexpected error code: {err}"
|
||||
err == nix_err_NIX_OK || err == nix_err_NIX_ERR_UNKNOWN,
|
||||
"nix_flake_settings_add_to_eval_state_builder returned unexpected error \
|
||||
code: {err}"
|
||||
);
|
||||
|
||||
nix_flake_settings_free(settings);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@
|
|||
|
||||
use std::ffi::CString;
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
use nixide_sys::*;
|
||||
use serial_test::serial;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
|
|
@ -15,13 +14,13 @@ fn value_reference_counting() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -30,7 +29,7 @@ fn value_reference_counting() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -41,11 +40,11 @@ fn value_reference_counting() {
|
|||
|
||||
// Initialize with an integer
|
||||
let init_err = nix_init_int(ctx, value, 42);
|
||||
assert_eq!(init_err, NixErr::Ok);
|
||||
assert_eq!(init_err, nix_err_NIX_OK);
|
||||
|
||||
// Test value-specific reference counting
|
||||
let incref_err = nix_value_incref(ctx, value);
|
||||
assert_eq!(incref_err, NixErr::Ok);
|
||||
assert_eq!(incref_err, nix_err_NIX_OK);
|
||||
|
||||
// Value should still be valid after increment
|
||||
let int_val = nix_get_int(ctx, value);
|
||||
|
|
@ -53,7 +52,7 @@ fn value_reference_counting() {
|
|||
|
||||
// Test decrement
|
||||
let decref_err = nix_value_decref(ctx, value);
|
||||
assert_eq!(decref_err, NixErr::Ok);
|
||||
assert_eq!(decref_err, nix_err_NIX_OK);
|
||||
|
||||
// Value should still be valid (original reference still exists)
|
||||
let int_val2 = nix_get_int(ctx, value);
|
||||
|
|
@ -61,7 +60,7 @@ fn value_reference_counting() {
|
|||
|
||||
// Final decrement (should not crash)
|
||||
let final_decref_err = nix_value_decref(ctx, value);
|
||||
assert_eq!(final_decref_err, NixErr::Ok);
|
||||
assert_eq!(final_decref_err, nix_err_NIX_OK);
|
||||
|
||||
// Clean up
|
||||
nix_state_free(state);
|
||||
|
|
@ -79,13 +78,13 @@ fn general_gc_reference_counting() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -94,7 +93,7 @@ fn general_gc_reference_counting() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -108,19 +107,19 @@ fn general_gc_reference_counting() {
|
|||
value,
|
||||
CString::new("test string for GC").unwrap().as_ptr(),
|
||||
);
|
||||
assert_eq!(init_err, NixErr::Ok);
|
||||
assert_eq!(init_err, nix_err_NIX_OK);
|
||||
|
||||
// Test general GC reference counting
|
||||
let gc_incref_err = nix_gc_incref(ctx, value as *const ::std::os::raw::c_void);
|
||||
assert_eq!(gc_incref_err, NixErr::Ok);
|
||||
assert_eq!(gc_incref_err, nix_err_NIX_OK);
|
||||
|
||||
// Value should still be accessible
|
||||
let value_type = nix_get_type(ctx, value);
|
||||
assert_eq!(value_type, ValueType::String);
|
||||
assert_eq!(value_type, ValueType_NIX_TYPE_STRING);
|
||||
|
||||
// Test GC decrement
|
||||
let gc_decref_err = nix_gc_decref(ctx, value as *const ::std::os::raw::c_void);
|
||||
assert_eq!(gc_decref_err, NixErr::Ok);
|
||||
assert_eq!(gc_decref_err, nix_err_NIX_OK);
|
||||
|
||||
// Final cleanup
|
||||
nix_value_decref(ctx, value);
|
||||
|
|
@ -139,13 +138,13 @@ fn manual_garbage_collection() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -154,7 +153,7 @@ fn manual_garbage_collection() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -165,7 +164,7 @@ fn manual_garbage_collection() {
|
|||
let value = nix_alloc_value(ctx, state);
|
||||
if !value.is_null() {
|
||||
let init_err = nix_init_int(ctx, value, i);
|
||||
if init_err == NixErr::Ok {
|
||||
if init_err == nix_err_NIX_OK {
|
||||
values.push(value);
|
||||
}
|
||||
}
|
||||
|
|
@ -197,13 +196,13 @@ fn value_copying_and_memory_management() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -212,7 +211,7 @@ fn value_copying_and_memory_management() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -223,20 +222,20 @@ fn value_copying_and_memory_management() {
|
|||
|
||||
let test_string = CString::new("test string for copying").unwrap();
|
||||
let init_err = nix_init_string(ctx, original, test_string.as_ptr());
|
||||
assert_eq!(init_err, NixErr::Ok);
|
||||
assert_eq!(init_err, nix_err_NIX_OK);
|
||||
|
||||
// Create copy
|
||||
let copy = nix_alloc_value(ctx, state);
|
||||
assert!(!copy.is_null());
|
||||
|
||||
let copy_err = nix_copy_value(ctx, copy, original);
|
||||
assert_eq!(copy_err, NixErr::Ok);
|
||||
assert_eq!(copy_err, nix_err_NIX_OK);
|
||||
|
||||
// Verify copy has same type and can be accessed
|
||||
let original_type = nix_get_type(ctx, original);
|
||||
let copy_type = nix_get_type(ctx, copy);
|
||||
assert_eq!(original_type, copy_type);
|
||||
assert_eq!(copy_type, ValueType::String);
|
||||
assert_eq!(copy_type, ValueType_NIX_TYPE_STRING);
|
||||
|
||||
// Test string contents using callback
|
||||
unsafe extern "C" fn string_callback(
|
||||
|
|
@ -269,22 +268,20 @@ fn value_copying_and_memory_management() {
|
|||
|
||||
// Both should have the same string content
|
||||
assert_eq!(original_string, copy_string);
|
||||
assert!(
|
||||
original_string
|
||||
assert!(original_string
|
||||
.as_deref()
|
||||
.unwrap_or("")
|
||||
.contains("test string")
|
||||
);
|
||||
.contains("test string"));
|
||||
|
||||
// Test reference counting on both values
|
||||
let incref_orig = nix_value_incref(ctx, original);
|
||||
let incref_copy = nix_value_incref(ctx, copy);
|
||||
assert_eq!(incref_orig, NixErr::Ok);
|
||||
assert_eq!(incref_copy, NixErr::Ok);
|
||||
assert_eq!(incref_orig, nix_err_NIX_OK);
|
||||
assert_eq!(incref_copy, nix_err_NIX_OK);
|
||||
|
||||
// Values should still be accessible after increment
|
||||
assert_eq!(nix_get_type(ctx, original), ValueType::String);
|
||||
assert_eq!(nix_get_type(ctx, copy), ValueType::String);
|
||||
assert_eq!(nix_get_type(ctx, original), ValueType_NIX_TYPE_STRING);
|
||||
assert_eq!(nix_get_type(ctx, copy), ValueType_NIX_TYPE_STRING);
|
||||
|
||||
// Clean up with decrements
|
||||
nix_value_decref(ctx, original);
|
||||
|
|
@ -307,13 +304,13 @@ fn complex_value_memory_management() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -322,7 +319,7 @@ fn complex_value_memory_management() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -346,7 +343,7 @@ fn complex_value_memory_management() {
|
|||
let _ = nix_init_string(ctx, val1, name_str.as_ptr());
|
||||
|
||||
let insert_err1 = nix_bindings_builder_insert(ctx, bindings_builder1, key1.as_ptr(), val1);
|
||||
assert_eq!(insert_err1, NixErr::Ok);
|
||||
assert_eq!(insert_err1, nix_err_NIX_OK);
|
||||
|
||||
let key2 = CString::new("value").unwrap();
|
||||
let val2 = nix_alloc_value(ctx, state);
|
||||
|
|
@ -354,14 +351,14 @@ fn complex_value_memory_management() {
|
|||
let _ = nix_init_int(ctx, val2, 42);
|
||||
|
||||
let insert_err2 = nix_bindings_builder_insert(ctx, bindings_builder1, key2.as_ptr(), val2);
|
||||
assert_eq!(insert_err2, NixErr::Ok);
|
||||
assert_eq!(insert_err2, nix_err_NIX_OK);
|
||||
|
||||
let make_attrs_err1 = nix_make_attrs(ctx, attrs1, bindings_builder1);
|
||||
assert_eq!(make_attrs_err1, NixErr::Ok);
|
||||
assert_eq!(make_attrs_err1, nix_err_NIX_OK);
|
||||
|
||||
// Insert first attrs into list
|
||||
let list_insert_err1 = nix_list_builder_insert(ctx, list_builder, 0, attrs1);
|
||||
assert_eq!(list_insert_err1, NixErr::Ok);
|
||||
assert_eq!(list_insert_err1, nix_err_NIX_OK);
|
||||
|
||||
// Create second element
|
||||
let attrs2 = nix_alloc_value(ctx, state);
|
||||
|
|
@ -377,23 +374,23 @@ fn complex_value_memory_management() {
|
|||
let _ = nix_init_string(ctx, val3, data_str.as_ptr());
|
||||
|
||||
let insert_err3 = nix_bindings_builder_insert(ctx, bindings_builder2, key3.as_ptr(), val3);
|
||||
assert_eq!(insert_err3, NixErr::Ok);
|
||||
assert_eq!(insert_err3, nix_err_NIX_OK);
|
||||
|
||||
let make_attrs_err2 = nix_make_attrs(ctx, attrs2, bindings_builder2);
|
||||
assert_eq!(make_attrs_err2, NixErr::Ok);
|
||||
assert_eq!(make_attrs_err2, nix_err_NIX_OK);
|
||||
|
||||
let list_insert_err2 = nix_list_builder_insert(ctx, list_builder, 1, attrs2);
|
||||
assert_eq!(list_insert_err2, NixErr::Ok);
|
||||
assert_eq!(list_insert_err2, nix_err_NIX_OK);
|
||||
|
||||
// Create final list
|
||||
let final_list = nix_alloc_value(ctx, state);
|
||||
assert!(!final_list.is_null());
|
||||
|
||||
let make_list_err = nix_make_list(ctx, list_builder, final_list);
|
||||
assert_eq!(make_list_err, NixErr::Ok);
|
||||
assert_eq!(make_list_err, nix_err_NIX_OK);
|
||||
|
||||
// Test the complex structure
|
||||
assert_eq!(nix_get_type(ctx, final_list), ValueType::List);
|
||||
assert_eq!(nix_get_type(ctx, final_list), ValueType_NIX_TYPE_LIST);
|
||||
assert_eq!(nix_get_list_size(ctx, final_list), 2);
|
||||
|
||||
// Access nested elements
|
||||
|
|
@ -401,19 +398,19 @@ fn complex_value_memory_management() {
|
|||
let elem1 = nix_get_list_byidx(ctx, final_list, state, 1);
|
||||
assert!(!elem0.is_null() && !elem1.is_null());
|
||||
|
||||
assert_eq!(nix_get_type(ctx, elem0), ValueType::Attrs);
|
||||
assert_eq!(nix_get_type(ctx, elem1), ValueType::Attrs);
|
||||
assert_eq!(nix_get_type(ctx, elem0), ValueType_NIX_TYPE_ATTRS);
|
||||
assert_eq!(nix_get_type(ctx, elem1), ValueType_NIX_TYPE_ATTRS);
|
||||
|
||||
// Test memory management with deep copying
|
||||
let copied_list = nix_alloc_value(ctx, state);
|
||||
assert!(!copied_list.is_null());
|
||||
|
||||
let copy_err = nix_copy_value(ctx, copied_list, final_list);
|
||||
assert_eq!(copy_err, NixErr::Ok);
|
||||
assert_eq!(copy_err, nix_err_NIX_OK);
|
||||
|
||||
// Force deep evaluation on copy
|
||||
let deep_force_err = nix_value_force_deep(ctx, state, copied_list);
|
||||
assert_eq!(deep_force_err, NixErr::Ok);
|
||||
assert_eq!(deep_force_err, nix_err_NIX_OK);
|
||||
|
||||
// Both should still be accessible
|
||||
assert_eq!(nix_get_list_size(ctx, final_list), 2);
|
||||
|
|
@ -446,28 +443,34 @@ fn memory_management_error_conditions() {
|
|||
|
||||
// XXX: May succeed or fail depending on implementation. We can't really
|
||||
// know, so assert both.
|
||||
assert!(null_incref_err == NixErr::Ok || null_incref_err == NixErr::Unknown);
|
||||
assert!(null_incref_err == nix_err_NIX_OK || null_incref_err == nix_err_NIX_ERR_UNKNOWN);
|
||||
|
||||
let null_decref_err = nix_gc_decref(ctx, std::ptr::null() as *const ::std::os::raw::c_void);
|
||||
assert!(null_decref_err == NixErr::Ok || null_decref_err == NixErr::Unknown);
|
||||
assert!(null_decref_err == nix_err_NIX_OK || null_decref_err == nix_err_NIX_ERR_UNKNOWN);
|
||||
|
||||
let null_value_incref_err = nix_value_incref(ctx, std::ptr::null_mut());
|
||||
// Some Nix APIs gracefully handle null pointers and return OK
|
||||
assert!(null_value_incref_err == NixErr::Ok || null_value_incref_err == NixErr::Unknown);
|
||||
assert!(
|
||||
null_value_incref_err == nix_err_NIX_OK
|
||||
|| null_value_incref_err == nix_err_NIX_ERR_UNKNOWN
|
||||
);
|
||||
|
||||
let null_value_decref_err = nix_value_decref(ctx, std::ptr::null_mut());
|
||||
// Some Nix APIs gracefully handle null pointers and return OK
|
||||
assert!(null_value_decref_err == NixErr::Ok || null_value_decref_err == NixErr::Unknown);
|
||||
assert!(
|
||||
null_value_decref_err == nix_err_NIX_OK
|
||||
|| null_value_decref_err == nix_err_NIX_ERR_UNKNOWN
|
||||
);
|
||||
|
||||
// Test copy with NULL values
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -476,7 +479,7 @@ fn memory_management_error_conditions() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -486,10 +489,10 @@ fn memory_management_error_conditions() {
|
|||
|
||||
// Test copying to/from NULL
|
||||
let copy_from_null_err = nix_copy_value(ctx, valid_value, std::ptr::null_mut());
|
||||
assert_ne!(copy_from_null_err, NixErr::Ok);
|
||||
assert_ne!(copy_from_null_err, nix_err_NIX_OK);
|
||||
|
||||
let copy_to_null_err = nix_copy_value(ctx, std::ptr::null_mut(), valid_value);
|
||||
assert_ne!(copy_to_null_err, NixErr::Ok);
|
||||
assert_ne!(copy_to_null_err, nix_err_NIX_OK);
|
||||
|
||||
// Clean up
|
||||
nix_value_decref(ctx, valid_value);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#![cfg(feature = "nix-expr-c")]
|
||||
#![cfg(test)]
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
|
||||
use serial_test::serial;
|
||||
use std::{
|
||||
ffi::CString,
|
||||
sync::atomic::{AtomicU32, Ordering},
|
||||
};
|
||||
|
||||
use nixide_sys::*;
|
||||
use serial_test::serial;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TestPrimOpData {
|
||||
|
|
@ -17,10 +18,10 @@ struct TestPrimOpData {
|
|||
// Simple PrimOp that adds 1 to an integer argument
|
||||
unsafe extern "C" fn add_one_primop(
|
||||
user_data: *mut ::std::os::raw::c_void,
|
||||
context: *mut NixCContext,
|
||||
context: *mut nix_c_context,
|
||||
state: *mut EvalState,
|
||||
args: *mut *mut NixValue,
|
||||
ret: *mut NixValue,
|
||||
args: *mut *mut nix_value,
|
||||
ret: *mut nix_value,
|
||||
) {
|
||||
if user_data.is_null()
|
||||
|| context.is_null()
|
||||
|
|
@ -31,7 +32,7 @@ unsafe extern "C" fn add_one_primop(
|
|||
let _ = unsafe {
|
||||
nix_set_err_msg(
|
||||
context,
|
||||
NixErr::Unknown,
|
||||
nix_err_NIX_ERR_UNKNOWN,
|
||||
b"Null pointer in add_one_primop\0".as_ptr() as *const _,
|
||||
)
|
||||
};
|
||||
|
|
@ -47,7 +48,7 @@ unsafe extern "C" fn add_one_primop(
|
|||
let _ = unsafe {
|
||||
nix_set_err_msg(
|
||||
context,
|
||||
NixErr::Unknown,
|
||||
nix_err_NIX_ERR_UNKNOWN,
|
||||
b"Missing argument in add_one_primop\0".as_ptr() as *const _,
|
||||
)
|
||||
};
|
||||
|
|
@ -55,16 +56,16 @@ unsafe extern "C" fn add_one_primop(
|
|||
}
|
||||
|
||||
// Force evaluation of argument
|
||||
if unsafe { nix_value_force(context, state, arg) } != NixErr::Ok {
|
||||
if unsafe { nix_value_force(context, state, arg) } != nix_err_NIX_OK {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if argument is integer
|
||||
if unsafe { nix_get_type(context, arg) } != ValueType::Int {
|
||||
if unsafe { nix_get_type(context, arg) } != ValueType_NIX_TYPE_INT {
|
||||
let _ = unsafe {
|
||||
nix_set_err_msg(
|
||||
context,
|
||||
NixErr::Unknown,
|
||||
nix_err_NIX_ERR_UNKNOWN,
|
||||
b"Expected integer argument in add_one_primop\0".as_ptr() as *const _,
|
||||
)
|
||||
};
|
||||
|
|
@ -82,10 +83,10 @@ unsafe extern "C" fn add_one_primop(
|
|||
// PrimOp that returns a constant string
|
||||
unsafe extern "C" fn hello_world_primop(
|
||||
_user_data: *mut ::std::os::raw::c_void,
|
||||
context: *mut NixCContext,
|
||||
context: *mut nix_c_context,
|
||||
_state: *mut EvalState,
|
||||
_args: *mut *mut NixValue,
|
||||
ret: *mut NixValue,
|
||||
_args: *mut *mut nix_value,
|
||||
ret: *mut nix_value,
|
||||
) {
|
||||
let hello = CString::new("Hello from Rust PrimOp!").unwrap();
|
||||
let _ = unsafe { nix_init_string(context, ret, hello.as_ptr()) };
|
||||
|
|
@ -94,10 +95,10 @@ unsafe extern "C" fn hello_world_primop(
|
|||
// PrimOp that takes multiple arguments and concatenates them
|
||||
unsafe extern "C" fn concat_strings_primop(
|
||||
_user_data: *mut ::std::os::raw::c_void,
|
||||
context: *mut NixCContext,
|
||||
context: *mut nix_c_context,
|
||||
state: *mut EvalState,
|
||||
args: *mut *mut NixValue,
|
||||
ret: *mut NixValue,
|
||||
args: *mut *mut nix_value,
|
||||
ret: *mut nix_value,
|
||||
) {
|
||||
if context.is_null() || state.is_null() || args.is_null() || ret.is_null() {
|
||||
return;
|
||||
|
|
@ -112,7 +113,7 @@ unsafe extern "C" fn concat_strings_primop(
|
|||
let _ = unsafe {
|
||||
nix_set_err_msg(
|
||||
context,
|
||||
NixErr::Unknown,
|
||||
nix_err_NIX_ERR_UNKNOWN,
|
||||
b"Missing argument in concat_strings_primop\0".as_ptr() as *const _,
|
||||
)
|
||||
};
|
||||
|
|
@ -120,15 +121,15 @@ unsafe extern "C" fn concat_strings_primop(
|
|||
}
|
||||
|
||||
// Force evaluation
|
||||
if unsafe { nix_value_force(context, state, arg) } != NixErr::Ok {
|
||||
if unsafe { nix_value_force(context, state, arg) } != nix_err_NIX_OK {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it's a string
|
||||
if unsafe { nix_get_type(context, arg) } != ValueType::String {
|
||||
if unsafe { nix_get_type(context, arg) } != ValueType_NIX_TYPE_STRING {
|
||||
let _ = unsafe {
|
||||
static ITEMS: &[u8] = b"Expected string argument in concat_strings_primop\0";
|
||||
nix_set_err_msg(context, NixErr::Unknown, ITEMS.as_ptr() as *const _)
|
||||
nix_set_err_msg(context, nix_err_NIX_ERR_UNKNOWN, ITEMS.as_ptr() as *const _)
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
|
@ -167,13 +168,13 @@ fn primop_allocation_and_registration() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -182,7 +183,7 @@ fn primop_allocation_and_registration() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -219,7 +220,7 @@ fn primop_allocation_and_registration() {
|
|||
let register_err = nix_register_primop(ctx, primop);
|
||||
// Registration may fail in some environments, but allocation should work
|
||||
assert!(
|
||||
register_err == NixErr::Ok || register_err == NixErr::Unknown,
|
||||
register_err == nix_err_NIX_OK || register_err == nix_err_NIX_ERR_UNKNOWN,
|
||||
"Unexpected error code: {register_err}"
|
||||
);
|
||||
|
||||
|
|
@ -228,7 +229,7 @@ fn primop_allocation_and_registration() {
|
|||
assert!(!primop_value.is_null());
|
||||
|
||||
let init_err = nix_init_primop(ctx, primop_value, primop);
|
||||
assert_eq!(init_err, NixErr::Ok);
|
||||
assert_eq!(init_err, nix_err_NIX_OK);
|
||||
|
||||
// Clean up value
|
||||
nix_value_decref(ctx, primop_value);
|
||||
|
|
@ -251,13 +252,13 @@ fn primop_function_call() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -266,7 +267,7 @@ fn primop_function_call() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -299,21 +300,21 @@ fn primop_function_call() {
|
|||
assert!(!primop_value.is_null());
|
||||
|
||||
let init_err = nix_init_primop(ctx, primop_value, hello_primop);
|
||||
assert_eq!(init_err, NixErr::Ok);
|
||||
assert_eq!(init_err, nix_err_NIX_OK);
|
||||
|
||||
// Call the PrimOp (no arguments)
|
||||
let result = nix_alloc_value(ctx, state);
|
||||
assert!(!result.is_null());
|
||||
|
||||
let call_err = nix_value_call(ctx, state, primop_value, std::ptr::null_mut(), result);
|
||||
if call_err == NixErr::Ok {
|
||||
if call_err == nix_err_NIX_OK {
|
||||
// Force the result
|
||||
let force_err = nix_value_force(ctx, state, result);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
// Check if result is a string
|
||||
let result_type = nix_get_type(ctx, result);
|
||||
if result_type == ValueType::String {
|
||||
if result_type == ValueType_NIX_TYPE_STRING {
|
||||
// Get string value
|
||||
unsafe extern "C" fn string_callback(
|
||||
start: *const ::std::os::raw::c_char,
|
||||
|
|
@ -336,12 +337,10 @@ fn primop_function_call() {
|
|||
);
|
||||
|
||||
// Verify we got the expected string
|
||||
assert!(
|
||||
string_result
|
||||
assert!(string_result
|
||||
.as_deref()
|
||||
.unwrap_or("")
|
||||
.contains("Hello from Rust")
|
||||
);
|
||||
.contains("Hello from Rust"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -366,13 +365,13 @@ fn primop_with_arguments() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -381,7 +380,7 @@ fn primop_with_arguments() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -418,28 +417,28 @@ fn primop_with_arguments() {
|
|||
assert!(!primop_value.is_null());
|
||||
|
||||
let init_err = nix_init_primop(ctx, primop_value, add_primop);
|
||||
assert_eq!(init_err, NixErr::Ok);
|
||||
assert_eq!(init_err, nix_err_NIX_OK);
|
||||
|
||||
// Create an integer argument
|
||||
let arg_value = nix_alloc_value(ctx, state);
|
||||
assert!(!arg_value.is_null());
|
||||
|
||||
let init_arg_err = nix_init_int(ctx, arg_value, 42);
|
||||
assert_eq!(init_arg_err, NixErr::Ok);
|
||||
assert_eq!(init_arg_err, nix_err_NIX_OK);
|
||||
|
||||
// Call the PrimOp with the argument
|
||||
let result = nix_alloc_value(ctx, state);
|
||||
assert!(!result.is_null());
|
||||
|
||||
let call_err = nix_value_call(ctx, state, primop_value, arg_value, result);
|
||||
if call_err == NixErr::Ok {
|
||||
if call_err == nix_err_NIX_OK {
|
||||
// Force the result
|
||||
let force_err = nix_value_force(ctx, state, result);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
// Check if result is an integer
|
||||
let result_type = nix_get_type(ctx, result);
|
||||
if result_type == ValueType::Int {
|
||||
if result_type == ValueType_NIX_TYPE_INT {
|
||||
let result_value = nix_get_int(ctx, result);
|
||||
assert_eq!(result_value, 43); // 42 + 1
|
||||
|
||||
|
|
@ -472,13 +471,13 @@ fn primop_multi_argument() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -487,7 +486,7 @@ fn primop_multi_argument() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
@ -517,7 +516,7 @@ fn primop_multi_argument() {
|
|||
assert!(!primop_value.is_null());
|
||||
|
||||
let init_err = nix_init_primop(ctx, primop_value, concat_primop);
|
||||
assert_eq!(init_err, NixErr::Ok);
|
||||
assert_eq!(init_err, nix_err_NIX_OK);
|
||||
|
||||
// Create string arguments
|
||||
let arg1 = nix_alloc_value(ctx, state);
|
||||
|
|
@ -529,8 +528,8 @@ fn primop_multi_argument() {
|
|||
|
||||
let init_arg1_err = nix_init_string(ctx, arg1, hello_cstr.as_ptr());
|
||||
let init_arg2_err = nix_init_string(ctx, arg2, world_cstr.as_ptr());
|
||||
assert_eq!(init_arg1_err, NixErr::Ok);
|
||||
assert_eq!(init_arg2_err, NixErr::Ok);
|
||||
assert_eq!(init_arg1_err, nix_err_NIX_OK);
|
||||
assert_eq!(init_arg2_err, nix_err_NIX_OK);
|
||||
|
||||
// Test multi-argument call using nix_value_call_multi
|
||||
let mut args = [arg1, arg2];
|
||||
|
|
@ -539,14 +538,14 @@ fn primop_multi_argument() {
|
|||
|
||||
let call_err =
|
||||
nix_value_call_multi(ctx, state, primop_value, 2, args.as_mut_ptr(), result);
|
||||
if call_err == NixErr::Ok {
|
||||
if call_err == nix_err_NIX_OK {
|
||||
// Force the result
|
||||
let force_err = nix_value_force(ctx, state, result);
|
||||
assert_eq!(force_err, NixErr::Ok);
|
||||
assert_eq!(force_err, nix_err_NIX_OK);
|
||||
|
||||
// Check if result is a string
|
||||
let result_type = nix_get_type(ctx, result);
|
||||
if result_type == ValueType::String {
|
||||
if result_type == ValueType_NIX_TYPE_STRING {
|
||||
unsafe extern "C" fn string_callback(
|
||||
start: *const ::std::os::raw::c_char,
|
||||
n: ::std::os::raw::c_uint,
|
||||
|
|
@ -593,13 +592,13 @@ fn primop_error_handling() {
|
|||
assert!(!ctx.is_null());
|
||||
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let err = nix_libexpr_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -608,7 +607,7 @@ fn primop_error_handling() {
|
|||
assert!(!builder.is_null());
|
||||
|
||||
let load_err = nix_eval_state_builder_load(ctx, builder);
|
||||
assert_eq!(load_err, NixErr::Ok);
|
||||
assert_eq!(load_err, nix_err_NIX_OK);
|
||||
|
||||
let state = nix_eval_state_build(ctx, builder);
|
||||
assert!(!state.is_null());
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
#![cfg(feature = "nix-store-c")]
|
||||
#![cfg(test)]
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
|
||||
use serial_test::serial;
|
||||
use std::{ffi::CString, ptr};
|
||||
|
||||
use nixide_sys::*;
|
||||
use serial_test::serial;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
|
|
@ -15,7 +13,7 @@ fn libstore_init_and_open_free() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
// Open the default store (NULL URI, NULL params)
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
|
|
@ -34,7 +32,7 @@ fn parse_and_clone_free_store_path() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -76,14 +74,14 @@ fn store_get_uri_and_storedir() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, ptr::null(), ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
||||
let mut uri: Option<String> = None;
|
||||
let res = nix_store_get_uri(ctx, store, Some(string_callback), (&raw mut uri).cast());
|
||||
assert_eq!(res, NixErr::Ok);
|
||||
assert_eq!(res, nix_err_NIX_OK);
|
||||
assert!(uri.is_some());
|
||||
|
||||
let mut storedir: Option<String> = None;
|
||||
|
|
@ -93,7 +91,7 @@ fn store_get_uri_and_storedir() {
|
|||
Some(string_callback),
|
||||
(&raw mut storedir).cast(),
|
||||
);
|
||||
assert_eq!(res, NixErr::Ok);
|
||||
assert_eq!(res, nix_err_NIX_OK);
|
||||
assert!(storedir.is_some());
|
||||
|
||||
nix_store_free(store);
|
||||
|
|
@ -108,7 +106,7 @@ fn libstore_init_no_load_config() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init_no_load_config(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
nix_c_context_free(ctx);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +129,7 @@ fn store_is_valid_path_and_real_path() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -152,7 +150,7 @@ fn store_is_valid_path_and_real_path() {
|
|||
(&raw mut real_path).cast(),
|
||||
);
|
||||
// May fail, but should not crash
|
||||
assert!(res == NixErr::Ok || res == NixErr::Unknown);
|
||||
assert!(res == nix_err_NIX_OK || res == nix_err_NIX_ERR_UNKNOWN);
|
||||
nix_store_path_free(store_path);
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +177,7 @@ fn store_path_name() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -217,7 +215,7 @@ fn store_get_version() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
@ -225,7 +223,7 @@ fn store_get_version() {
|
|||
let mut version: Option<String> = None;
|
||||
let res =
|
||||
nix_store_get_version(ctx, store, Some(string_callback), (&raw mut version).cast());
|
||||
assert_eq!(res, NixErr::Ok);
|
||||
assert_eq!(res, nix_err_NIX_OK);
|
||||
// Version may be empty for dummy stores, but should not crash
|
||||
assert!(version.is_some());
|
||||
|
||||
|
|
@ -251,7 +249,7 @@ fn store_realise_and_copy_closure() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libstore_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
let store = nix_store_open(ctx, std::ptr::null(), std::ptr::null_mut());
|
||||
assert!(!store.is_null());
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
#![cfg(feature = "nix-util-c")]
|
||||
#![cfg(test)]
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
use nixide_sys::*;
|
||||
use serial_test::serial;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
|
|
@ -24,7 +22,7 @@ fn libutil_init() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
nix_c_context_free(ctx);
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +60,7 @@ fn setting_set_and_get() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
// Set a setting (use a dummy/extra setting to avoid breaking global config)
|
||||
let key = CString::new("extra-test-setting").unwrap();
|
||||
|
|
@ -70,7 +68,7 @@ fn setting_set_and_get() {
|
|||
let set_err = nix_setting_set(ctx, key.as_ptr(), value.as_ptr());
|
||||
// Setting may not exist, but should not crash
|
||||
assert!(
|
||||
set_err == NixErr::Ok || set_err == NixErr::Key,
|
||||
set_err == nix_err_NIX_OK || set_err == nix_err_NIX_ERR_KEY,
|
||||
"Unexpected error code: {set_err}"
|
||||
);
|
||||
|
||||
|
|
@ -83,11 +81,11 @@ fn setting_set_and_get() {
|
|||
(&raw mut got).cast(),
|
||||
);
|
||||
assert!(
|
||||
get_err == NixErr::Ok || get_err == NixErr::Key,
|
||||
get_err == nix_err_NIX_OK || get_err == nix_err_NIX_ERR_KEY,
|
||||
"Unexpected error code: {get_err}"
|
||||
);
|
||||
// If OK, we should have gotten a value
|
||||
if get_err == NixErr::Ok {
|
||||
if get_err == nix_err_NIX_OK {
|
||||
assert_eq!(got.as_deref(), Some("test-value"));
|
||||
}
|
||||
|
||||
|
|
@ -113,16 +111,16 @@ fn error_handling_apis() {
|
|||
let ctx = nix_c_context_create();
|
||||
assert!(!ctx.is_null());
|
||||
let err = nix_libutil_init(ctx);
|
||||
assert_eq!(err, NixErr::Ok);
|
||||
assert_eq!(err, nix_err_NIX_OK);
|
||||
|
||||
// Set an error message
|
||||
let msg = CString::new("custom error message").unwrap();
|
||||
let set_err = nix_set_err_msg(ctx, NixErr::Unknown, msg.as_ptr());
|
||||
assert_eq!(set_err, NixErr::Unknown);
|
||||
let set_err = nix_set_err_msg(ctx, nix_err_NIX_ERR_UNKNOWN, msg.as_ptr());
|
||||
assert_eq!(set_err, nix_err_NIX_ERR_UNKNOWN);
|
||||
|
||||
// Get error code
|
||||
let code = nix_err_code(ctx);
|
||||
assert_eq!(code, NixErr::Unknown);
|
||||
assert_eq!(code, nix_err_NIX_ERR_UNKNOWN);
|
||||
|
||||
// Get error message
|
||||
let mut len: std::os::raw::c_uint = 0;
|
||||
|
|
@ -147,7 +145,7 @@ fn error_handling_apis() {
|
|||
// Clear error
|
||||
nix_clear_err(ctx);
|
||||
let code_after_clear = nix_err_code(ctx);
|
||||
assert_eq!(code_after_clear, NixErr::Ok);
|
||||
assert_eq!(code_after_clear, nix_err_NIX_OK);
|
||||
|
||||
nix_c_context_free(ctx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,29 +57,42 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
/// };
|
||||
/// ```
|
||||
///
|
||||
/// The [NixCContext] struct is laid out so that it can also be
|
||||
/// cast to a [sys::NixErr] to inspect directly:
|
||||
/// The [sys::nix_c_context] struct is laid out so that it can also be
|
||||
/// cast to a [sys::nix_err] to inspect directly:
|
||||
/// ```c
|
||||
/// assert(*(nix_err*)ctx == NIX_OK);
|
||||
/// ```
|
||||
///
|
||||
pub(crate) struct ErrorContext {
|
||||
inner: NonNull<sys::NixCContext>,
|
||||
inner: NonNull<sys::nix_c_context>,
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixCContext> for ErrorContext {
|
||||
// impl Clone for ErrorContext {
|
||||
// fn clone(&self) -> Self {
|
||||
// let inner = self.inner.clone();
|
||||
//
|
||||
// wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
// sys::nix_gc_incref(ctx.as_ptr(), self.as_ptr() as *mut c_void);
|
||||
// })
|
||||
// .unwrap();
|
||||
//
|
||||
// Self { inner }
|
||||
// }
|
||||
// }
|
||||
|
||||
impl AsInnerPtr<sys::nix_c_context> for ErrorContext {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixCContext {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_c_context {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixCContext {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_c_context {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixCContext {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_c_context {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -87,11 +100,11 @@ impl AsInnerPtr<sys::NixCContext> for ErrorContext {
|
|||
impl Into<NixideResult<()>> for &ErrorContext {
|
||||
/// # Panics
|
||||
///
|
||||
/// This function will panic in the event that `context.get_err() == Some(err) && err == sys::NixErr::NIX_OK`
|
||||
/// since `nixide::ErrorContext::get_err` is expected to return `None` to indicate `sys::NixErr::NIX_OK`.
|
||||
/// This function will panic in the event that `context.get_err() == Some(err) && err == sys::nix_err_NIX_OK`
|
||||
/// since `nixide::ErrorContext::get_err` is expected to return `None` to indicate `sys::nix_err_NIX_OK`.
|
||||
///
|
||||
/// This function will panic in the event that `value != sys::NixErr::NIX_OK`
|
||||
/// but that `context.get_code() == sys::NixErr::NIX_OK`
|
||||
/// This function will panic in the event that `value != sys::nix_err_NIX_OK`
|
||||
/// but that `context.get_code() == sys::nix_err_NIX_OK`
|
||||
///
|
||||
fn into(self) -> NixideResult<()> {
|
||||
let inner = match self.get_err() {
|
||||
|
|
@ -104,11 +117,11 @@ impl Into<NixideResult<()>> for &ErrorContext {
|
|||
};
|
||||
|
||||
let err = match inner {
|
||||
sys::NixErr::Ok => unreachable!(),
|
||||
sys::nix_err_NIX_OK => unreachable!(),
|
||||
|
||||
sys::NixErr::Overflow => NixError::Overflow,
|
||||
sys::NixErr::Key => NixError::KeyNotFound(None),
|
||||
sys::NixErr::NixError => NixError::ExprEval {
|
||||
sys::nix_err_NIX_ERR_OVERFLOW => NixError::Overflow,
|
||||
sys::nix_err_NIX_ERR_KEY => NixError::KeyNotFound(None),
|
||||
sys::nix_err_NIX_ERR_NIX_ERROR => NixError::ExprEval {
|
||||
name: self
|
||||
.get_nix_err_name()
|
||||
.unwrap_or_else(|| panic_issue_call_failed!()),
|
||||
|
|
@ -118,7 +131,7 @@ impl Into<NixideResult<()>> for &ErrorContext {
|
|||
.unwrap_or_else(|| panic_issue_call_failed!()),
|
||||
},
|
||||
|
||||
sys::NixErr::Unknown => NixError::Unknown,
|
||||
sys::nix_err_NIX_ERR_UNKNOWN => NixError::Unknown,
|
||||
err => NixError::Undocumented(err),
|
||||
};
|
||||
|
||||
|
|
@ -132,13 +145,13 @@ impl ErrorContext {
|
|||
/// # Errors
|
||||
///
|
||||
/// Returns an error if no memory can be allocated for
|
||||
/// the underlying [NixCContext] struct.
|
||||
/// the underlying [sys::nix_c_context] struct.
|
||||
///
|
||||
pub fn new() -> Self {
|
||||
match NonNull::new(unsafe { sys::nix_c_context_create() }) {
|
||||
Some(inner) => ErrorContext { inner },
|
||||
None => panic!(
|
||||
"[nixide] CRITICAL FAILURE: Out-Of-Memory condition reached - `NixCContext_create` allocation failed!"
|
||||
"[nixide] CRITICAL FAILURE: Out-Of-Memory condition reached - `sys::nix_c_context_create` allocation failed!"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
@ -203,12 +216,12 @@ impl ErrorContext {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns [None] if [self.code] is [sys::NixErr::NIX_OK], and [Some] otherwise.
|
||||
/// Returns [None] if [self.code] is [sys::nix_err_NIX_OK], and [Some] otherwise.
|
||||
///
|
||||
/// # Nix C++ API Internals
|
||||
///
|
||||
/// ```cpp
|
||||
/// nix_err nix_err::code(const nix_c_context * read_context)
|
||||
/// nix_err nix_err_code(const nix_c_context * read_context)
|
||||
/// {
|
||||
/// return read_context->last_err_code;
|
||||
/// }
|
||||
|
|
@ -216,19 +229,19 @@ impl ErrorContext {
|
|||
///
|
||||
/// This function **never fails**.
|
||||
///
|
||||
fn get_err(&self) -> Option<sys::NixErr> {
|
||||
fn get_err(&self) -> Option<sys::nix_err> {
|
||||
match unsafe { sys::nix_err_code(self.as_ptr()) } {
|
||||
sys::NixErr::Ok => None,
|
||||
sys::nix_err_NIX_OK => None,
|
||||
err => Some(err),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns [None] if [self.code] is [sys::NixErr::NIX_OK], and [Some] otherwise.
|
||||
/// Returns [None] if [self.code] is [sys::nix_err_NIX_OK], and [Some] otherwise.
|
||||
///
|
||||
/// # Nix C++ API Internals
|
||||
///
|
||||
/// ```cpp
|
||||
/// const char * nix_err::msg(nix_c_context * context, const nix_c_context * read_context, unsigned int * n)
|
||||
/// const char * nix_err_msg(nix_c_context * context, const nix_c_context * read_context, unsigned int * n)
|
||||
/// {
|
||||
/// if (context)
|
||||
/// context->last_err_code = NIX_OK;
|
||||
|
|
@ -237,21 +250,21 @@ impl ErrorContext {
|
|||
/// *n = read_context->last_err->size();
|
||||
/// return read_context->last_err->c_str();
|
||||
/// }
|
||||
/// nix_set_err_msg(context, NIX_ERR::UNKNOWN, "No error message");
|
||||
/// nix_set_err_msg(context, NIX_ERR_UNKNOWN, "No error message");
|
||||
/// return nullptr;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// On failure [sys::NixErr::name] does the following if the error
|
||||
/// has the error code [sys::NixErr::NIX_OK]:
|
||||
/// On failure [sys::nix_err_name] does the following if the error
|
||||
/// has the error code [sys::nix_err_NIX_OK]:
|
||||
/// ```cpp
|
||||
/// nix_set_err_msg(context, NIX_ERR::UNKNOWN, "No error message");
|
||||
/// nix_set_err_msg(context, NIX_ERR_UNKNOWN, "No error message");
|
||||
/// return nullptr;
|
||||
/// ```
|
||||
/// Hence we can just test whether the returned pointer is a `NULL` pointer,
|
||||
/// and avoid passing in a [NixCContext] struct.
|
||||
/// and avoid passing in a [sys::nix_c_context] struct.
|
||||
///
|
||||
fn get_msg(&self) -> Option<String> {
|
||||
// NOTE: an Err here only occurs when `self.get_code() == Ok(())`
|
||||
|
|
@ -268,13 +281,13 @@ impl ErrorContext {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns [None] if [self.code] is [sys::NixErr::NIX_OK], and [Some] otherwise.
|
||||
/// Returns [None] if [self.code] is [sys::nix_err_NIX_OK], and [Some] otherwise.
|
||||
///
|
||||
/// # Nix C++ API Internals
|
||||
///
|
||||
/// ```cpp
|
||||
/// // NOTE(nixide): the implementation of `nix_err::info_msg` is identical to `nix_err::name`
|
||||
/// nix_err nix_err::info_msg(
|
||||
/// // NOTE(nixide): the implementation of `nix_err_info_msg` is identical to `nix_err_name`
|
||||
/// nix_err nix_err_info_msg(
|
||||
/// nix_c_context * context,
|
||||
/// const nix_c_context * read_context,
|
||||
/// nix_get_string_callback callback,
|
||||
|
|
@ -282,16 +295,16 @@ impl ErrorContext {
|
|||
/// {
|
||||
/// if (context)
|
||||
/// context->last_err_code = NIX_OK;
|
||||
/// if (read_context->last_err_code != NIX_ERR::NIX_ERROR) {
|
||||
/// if (read_context->last_err_code != NIX_ERR_NIX_ERROR) {
|
||||
/// // NOTE(nixide): `nix_set_err_msg` throws a `nix::Error` exception if `context == nullptr`
|
||||
/// return nix_set_err_msg(context, NIX_ERR::UNKNOWN, "Last error was not a nix error");
|
||||
/// return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Last error was not a nix error");
|
||||
/// }
|
||||
/// // NOTE(nixide): `call_nix_get_string_callback` always returns `NIX_OK`
|
||||
/// return call_nix_get_string_callback(read_context->info->msg.str(), callback, user_data);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// `nix_err::info_msg` accepts two `nix_c_context*`:
|
||||
/// `nix_err_info_msg` accepts two `nix_c_context*`:
|
||||
/// * `nix_c_context* context` - errors from the function call are logged here
|
||||
/// * `const nix_c_context* read_context` - the context to read `info_msg` from
|
||||
///
|
||||
|
|
@ -320,13 +333,13 @@ impl ErrorContext {
|
|||
.ok()
|
||||
}
|
||||
|
||||
/// Returns [None] if [self.code] is [sys::NixErr::NIX_OK], and [Some] otherwise.
|
||||
/// Returns [None] if [self.code] is [sys::nix_err_NIX_OK], and [Some] otherwise.
|
||||
///
|
||||
/// # Nix C++ API Internals
|
||||
///
|
||||
/// ```cpp
|
||||
/// // NOTE(nixide): the implementation of `nix_err::info_msg` is identical to `nix_err::name`
|
||||
/// nix_err nix_err::info_msg(
|
||||
/// // NOTE(nixide): the implementation of `nix_err_info_msg` is identical to `nix_err_name`
|
||||
/// nix_err nix_err_info_msg(
|
||||
/// nix_c_context * context,
|
||||
/// const nix_c_context * read_context,
|
||||
/// nix_get_string_callback callback,
|
||||
|
|
@ -334,16 +347,16 @@ impl ErrorContext {
|
|||
/// {
|
||||
/// if (context)
|
||||
/// context->last_err_code = NIX_OK;
|
||||
/// if (read_context->last_err_code != NIX_ERR::NIX_ERROR) {
|
||||
/// if (read_context->last_err_code != NIX_ERR_NIX_ERROR) {
|
||||
/// // NOTE(nixide): `nix_set_err_msg` throws a `nix::Error` exception if `context == nullptr`
|
||||
/// return nix_set_err_msg(context, NIX_ERR::UNKNOWN, "Last error was not a nix error");
|
||||
/// return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Last error was not a nix error");
|
||||
/// }
|
||||
/// // NOTE(nixide): `call_nix_get_string_callback` always returns `NIX_OK`
|
||||
/// return call_nix_get_string_callback(read_context->info->msg.str(), callback, user_data);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// `nix_err::info_msg` accepts two `nix_c_context*`:
|
||||
/// `nix_err_info_msg` accepts two `nix_c_context*`:
|
||||
/// * `nix_c_context* context` - errors from the function call are logged here
|
||||
/// * `const nix_c_context* read_context` - the context to read `info_msg` from
|
||||
///
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub enum NixideError {
|
|||
/// that is instead mapped to [NixError::ExprEval]
|
||||
NixError {
|
||||
trace: String,
|
||||
inner: sys::NixErr,
|
||||
inner: sys::nix_err,
|
||||
err: NixError,
|
||||
msg: String,
|
||||
},
|
||||
|
|
@ -84,7 +84,9 @@ pub(crate) use new_nixide_error;
|
|||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! retrace_nixide_error {
|
||||
($x:expr) => {{ crate::errors::new_nixide_error!($x.err) }};
|
||||
($x:expr) => {{
|
||||
crate::errors::new_nixide_error!($x.err)
|
||||
}};
|
||||
}
|
||||
pub(crate) use retrace_nixide_error;
|
||||
|
||||
|
|
@ -100,15 +102,15 @@ impl Display for NixideError {
|
|||
msg,
|
||||
} => {
|
||||
write!(f, "[nixide ~ {trace}]{err} (nix_err={inner}): {msg}")
|
||||
},
|
||||
}
|
||||
|
||||
NixideError::StringNulByte { trace } => {
|
||||
write!(f, "[nixide ~ {trace}] Got premature `\\0` (NUL) byte")
|
||||
},
|
||||
}
|
||||
|
||||
NixideError::StringNotUtf8 { trace } => {
|
||||
write!(f, "[nixide ~ {trace}] Expected UTF-8 encoded string")
|
||||
},
|
||||
}
|
||||
|
||||
NixideError::NullPtr { trace } => write!(f, "[nixide ~ {trace}] Got null pointer"),
|
||||
|
||||
|
|
@ -121,7 +123,7 @@ impl Display for NixideError {
|
|||
f,
|
||||
"[nixide ~ {trace}] Invalid argument `{name}`: reason \"{reason}\""
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
NixideError::InvalidType {
|
||||
trace,
|
||||
|
|
|
|||
|
|
@ -93,18 +93,15 @@ pub enum NixError {
|
|||
///
|
||||
/// [NixError::Undocumented] has no equivalent in the `libnix` api.
|
||||
/// This is solely a language difference between C++ and Rust, since
|
||||
/// [sys::NixErr] is defined over the *"continuous" (not realy)*
|
||||
/// [sys::nix_err] is defined over the *"continuous" (not realy)*
|
||||
/// type [std::os::raw::c_int].
|
||||
Undocumented(sys::NixErr),
|
||||
Undocumented(sys::nix_err),
|
||||
}
|
||||
|
||||
impl Display for NixError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
match self {
|
||||
NixError::ExprEval { name, info_msg } => write!(
|
||||
f,
|
||||
"[libnix] NixExpr evaluation failed [name=\"{name}\", info_msg=\"{info_msg}\"]"
|
||||
),
|
||||
NixError::ExprEval { name, info_msg } => write!(f, "[libnix] NixExpr evaluation failed [name=\"{name}\", info_msg=\"{info_msg}\"]"),
|
||||
NixError::KeyNotFound(Some(key)) => write!(f, "[libnix] Key not found \"{key}\""),
|
||||
NixError::KeyNotFound(None) => write!(f, "[libnix] Key not found"),
|
||||
NixError::Overflow => write!(f, "[libnix] Overflow error"),
|
||||
|
|
@ -118,15 +115,15 @@ impl Display for NixError {
|
|||
}
|
||||
|
||||
impl NixError {
|
||||
pub fn err_code(&self) -> sys::NixErr {
|
||||
pub fn err_code(&self) -> sys::nix_err {
|
||||
match self {
|
||||
NixError::Overflow => sys::NixErr::Overflow,
|
||||
NixError::KeyNotFound(_) => sys::NixErr::Key,
|
||||
NixError::Overflow => sys::nix_err_NIX_ERR_OVERFLOW,
|
||||
NixError::KeyNotFound(_) => sys::nix_err_NIX_ERR_NIX_ERROR,
|
||||
NixError::ExprEval {
|
||||
name: _,
|
||||
info_msg: _,
|
||||
} => sys::NixErr::NixError,
|
||||
NixError::Unknown => sys::NixErr::NixError,
|
||||
} => sys::nix_err_NIX_ERR_NIX_ERROR,
|
||||
NixError::Unknown => sys::nix_err_NIX_ERR_UNKNOWN,
|
||||
NixError::Undocumented(err) => err.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,23 +18,23 @@ use crate::util::{panic_issue_call_failed, wrap};
|
|||
/// the evaluation state.
|
||||
///
|
||||
pub struct EvalStateBuilder {
|
||||
inner: Rc<RefCell<NonNull<sys::NixEvalStateBuilder>>>,
|
||||
inner: Rc<RefCell<NonNull<sys::nix_eval_state_builder>>>,
|
||||
store: Rc<RefCell<Store>>,
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixEvalStateBuilder> for EvalStateBuilder {
|
||||
impl AsInnerPtr<sys::nix_eval_state_builder> for EvalStateBuilder {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixEvalStateBuilder {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_eval_state_builder {
|
||||
self.inner.borrow().as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixEvalStateBuilder {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_eval_state_builder {
|
||||
unsafe { self.inner.borrow().as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixEvalStateBuilder {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_eval_state_builder {
|
||||
unsafe { self.inner.borrow_mut().as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,24 +12,24 @@ use crate::{EvalState, NixideResult, StorePath};
|
|||
use crate::{Store, sys};
|
||||
|
||||
pub struct RealisedString<'a> {
|
||||
inner: RefCell<NonNull<sys::NixRealisedString>>,
|
||||
inner: RefCell<NonNull<sys::nix_realised_string>>,
|
||||
pub path: StorePath,
|
||||
pub children: LazyArray<StorePath, Box<dyn Fn(usize) -> StorePath + 'a>>,
|
||||
}
|
||||
|
||||
impl<'a> AsInnerPtr<sys::NixRealisedString> for RealisedString<'a> {
|
||||
impl<'a> AsInnerPtr<sys::nix_realised_string> for RealisedString<'a> {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixRealisedString {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_realised_string {
|
||||
self.inner.borrow().as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixRealisedString {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_realised_string {
|
||||
unsafe { self.inner.borrow().as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixRealisedString {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_realised_string {
|
||||
unsafe { self.inner.borrow_mut().as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ impl<'a> RealisedString<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_path(realised_string: *mut sys::NixRealisedString, store: &Store) -> StorePath {
|
||||
fn parse_path(realised_string: *mut sys::nix_realised_string, store: &Store) -> StorePath {
|
||||
let buffer_ptr = unsafe { sys::nix_realised_string_get_buffer_start(realised_string) };
|
||||
let buffer_size = unsafe { sys::nix_realised_string_get_buffer_size(realised_string) };
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
|
||||
pub struct NixAttrs {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
len: u32,
|
||||
}
|
||||
|
|
@ -55,19 +55,19 @@ impl Debug for NixAttrs {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixAttrs {
|
||||
impl AsInnerPtr<sys::nix_value> for NixAttrs {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -75,10 +75,10 @@ impl AsInnerPtr<sys::NixValue> for NixAttrs {
|
|||
impl NixValue for NixAttrs {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Attrs
|
||||
sys::ValueType_NIX_TYPE_ATTRS
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
let len = wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
sys::nix_get_attrs_size(ctx.as_ptr(), inner.as_ptr())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use crate::util::wrap;
|
|||
use crate::util::wrappers::AsInnerPtr;
|
||||
|
||||
pub struct NixBool {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
value: bool,
|
||||
}
|
||||
|
|
@ -54,19 +54,19 @@ impl Debug for NixBool {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixBool {
|
||||
impl AsInnerPtr<sys::nix_value> for NixBool {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -74,10 +74,10 @@ impl AsInnerPtr<sys::NixValue> for NixBool {
|
|||
impl NixValue for NixBool {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Bool
|
||||
sys::ValueType_NIX_TYPE_BOOL
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
let value = wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
sys::nix_get_bool(ctx.as_ptr(), inner.as_ptr())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
|
||||
pub struct NixFloat {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
value: f64,
|
||||
}
|
||||
|
|
@ -53,19 +53,19 @@ impl Debug for NixFloat {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixFloat {
|
||||
impl AsInnerPtr<sys::nix_value> for NixFloat {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -73,10 +73,10 @@ impl AsInnerPtr<sys::NixValue> for NixFloat {
|
|||
impl NixValue for NixFloat {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Float
|
||||
sys::ValueType_NIX_TYPE_FLOAT
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
let value = wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
sys::nix_get_float(ctx.as_ptr(), inner.as_ptr())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
|
||||
pub struct NixFunction {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
}
|
||||
|
||||
|
|
@ -52,19 +52,19 @@ impl Debug for NixFunction {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixFunction {
|
||||
impl AsInnerPtr<sys::nix_value> for NixFunction {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -72,10 +72,10 @@ impl AsInnerPtr<sys::NixValue> for NixFunction {
|
|||
impl NixValue for NixFunction {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Function
|
||||
sys::ValueType_NIX_TYPE_FUNCTION
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
Self { inner, state }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
|
||||
pub struct NixInt {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
value: i64,
|
||||
}
|
||||
|
|
@ -53,19 +53,19 @@ impl Debug for NixInt {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixInt {
|
||||
impl AsInnerPtr<sys::nix_value> for NixInt {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -73,10 +73,10 @@ impl AsInnerPtr<sys::NixValue> for NixInt {
|
|||
impl NixValue for NixInt {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Int
|
||||
sys::ValueType_NIX_TYPE_INT
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
let value = wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
sys::nix_get_int(ctx.as_ptr(), inner.as_ptr())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
|
||||
pub struct NixList {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
}
|
||||
|
||||
|
|
@ -51,19 +51,19 @@ impl Debug for NixList {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixList {
|
||||
impl AsInnerPtr<sys::nix_value> for NixList {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -71,10 +71,10 @@ impl AsInnerPtr<sys::NixValue> for NixList {
|
|||
impl NixValue for NixList {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::List
|
||||
sys::ValueType_NIX_TYPE_LIST
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
Self { inner, state }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,16 +30,21 @@ use std::rc::Rc;
|
|||
|
||||
use crate::errors::ErrorContext;
|
||||
use crate::sys;
|
||||
use crate::sys::ValueType;
|
||||
use crate::sys::{
|
||||
ValueType_NIX_TYPE_ATTRS, ValueType_NIX_TYPE_BOOL, ValueType_NIX_TYPE_EXTERNAL,
|
||||
ValueType_NIX_TYPE_FLOAT, ValueType_NIX_TYPE_FUNCTION, ValueType_NIX_TYPE_INT,
|
||||
ValueType_NIX_TYPE_LIST, ValueType_NIX_TYPE_NULL, ValueType_NIX_TYPE_PATH,
|
||||
ValueType_NIX_TYPE_STRING, ValueType_NIX_TYPE_THUNK,
|
||||
};
|
||||
use crate::util::wrappers::AsInnerPtr;
|
||||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
|
||||
pub trait NixValue: Clone + Drop + Display + Debug + AsInnerPtr<sys::NixValue> {
|
||||
pub trait NixValue: Clone + Drop + Display + Debug + AsInnerPtr<sys::nix_value> {
|
||||
/// TODO
|
||||
fn type_id(&self) -> sys::ValueType;
|
||||
|
||||
/// TODO
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self;
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self;
|
||||
}
|
||||
|
||||
/// A Nix value
|
||||
|
|
@ -105,8 +110,18 @@ pub enum Value {
|
|||
// Failed(NixFailed),
|
||||
}
|
||||
|
||||
impl From<(NonNull<sys::NixValue>, Rc<RefCell<NonNull<sys::EvalState>>>)> for Value {
|
||||
fn from(value: (NonNull<sys::NixValue>, Rc<RefCell<NonNull<sys::EvalState>>>)) -> Self {
|
||||
impl
|
||||
From<(
|
||||
NonNull<sys::nix_value>,
|
||||
Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
)> for Value
|
||||
{
|
||||
fn from(
|
||||
value: (
|
||||
NonNull<sys::nix_value>,
|
||||
Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
),
|
||||
) -> Self {
|
||||
let (inner, state) = value;
|
||||
|
||||
wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
|
|
@ -121,20 +136,22 @@ impl From<(NonNull<sys::NixValue>, Rc<RefCell<NonNull<sys::EvalState>>>)> for Va
|
|||
|
||||
#[allow(non_upper_case_globals)]
|
||||
match type_id {
|
||||
ValueType::Thunk => Value::Thunk(<NixThunk as NixValue>::from(inner, state)),
|
||||
ValueType::Int => Value::Int(<NixInt as NixValue>::from(inner, state)),
|
||||
ValueType::Float => Value::Float(<NixFloat as NixValue>::from(inner, state)),
|
||||
ValueType::Bool => Value::Bool(<NixBool as NixValue>::from(inner, state)),
|
||||
ValueType::String => Value::String(<NixString as NixValue>::from(inner, state)),
|
||||
ValueType::Path => Value::Path(<NixPath as NixValue>::from(inner, state)),
|
||||
ValueType::Null => Value::Null(<NixNull as NixValue>::from(inner, state)),
|
||||
ValueType::Attrs => Value::Attrs(<NixAttrs as NixValue>::from(inner, state)),
|
||||
ValueType::List => Value::List(<NixList as NixValue>::from(inner, state)),
|
||||
ValueType::Function => Value::Function(<NixFunction as NixValue>::from(inner, state)),
|
||||
// ValueType::External => {
|
||||
ValueType_NIX_TYPE_THUNK => Value::Thunk(<NixThunk as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_INT => Value::Int(<NixInt as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_FLOAT => Value::Float(<NixFloat as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_BOOL => Value::Bool(<NixBool as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_STRING => Value::String(<NixString as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_PATH => Value::Path(<NixPath as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_NULL => Value::Null(<NixNull as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_ATTRS => Value::Attrs(<NixAttrs as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_LIST => Value::List(<NixList as NixValue>::from(inner, state)),
|
||||
ValueType_NIX_TYPE_FUNCTION => {
|
||||
Value::Function(<NixFunction as NixValue>::from(inner, state))
|
||||
},
|
||||
// ValueType_NIX_TYPE_EXTERNAL => {
|
||||
// Value::External(<NixExternal as NixValue>::from(inner, state))
|
||||
// },
|
||||
// ValueType::Failed => {
|
||||
// ValueType_NIX_TYPE_FAILED => {
|
||||
// Value::Failed(<NixFailed as NixValue>::from(inner, state))
|
||||
// },
|
||||
_ => unreachable!(),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::util::wrap;
|
|||
use crate::util::wrappers::AsInnerPtr;
|
||||
|
||||
pub struct NixNull {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
}
|
||||
|
||||
|
|
@ -51,19 +51,19 @@ impl Debug for NixNull {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixNull {
|
||||
impl AsInnerPtr<sys::nix_value> for NixNull {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -71,10 +71,10 @@ impl AsInnerPtr<sys::NixValue> for NixNull {
|
|||
impl NixValue for NixNull {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Null
|
||||
sys::ValueType_NIX_TYPE_NULL
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
Self { inner, state }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::util::wrap;
|
|||
use crate::util::wrappers::AsInnerPtr;
|
||||
|
||||
pub struct NixPath {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
value: PathBuf,
|
||||
}
|
||||
|
|
@ -56,19 +56,19 @@ impl Debug for NixPath {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixPath {
|
||||
impl AsInnerPtr<sys::nix_value> for NixPath {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -76,10 +76,10 @@ impl AsInnerPtr<sys::NixValue> for NixPath {
|
|||
impl NixValue for NixPath {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Path
|
||||
sys::ValueType_NIX_TYPE_PATH
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
let value = wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
|
||||
sys::nix_get_path_string(ctx.as_ptr(), inner.as_ptr())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::util::wrap;
|
|||
use crate::util::wrappers::AsInnerPtr;
|
||||
|
||||
pub struct NixString {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
value: String,
|
||||
}
|
||||
|
|
@ -55,19 +55,19 @@ impl Debug for NixString {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixString {
|
||||
impl AsInnerPtr<sys::nix_value> for NixString {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -75,10 +75,10 @@ impl AsInnerPtr<sys::NixValue> for NixString {
|
|||
impl NixValue for NixString {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::String
|
||||
sys::ValueType_NIX_TYPE_STRING
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
let value = wrap::nix_string_callback!(
|
||||
|callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe {
|
||||
sys::nix_get_string(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
|
||||
pub struct NixThunk {
|
||||
inner: NonNull<sys::NixValue>,
|
||||
inner: NonNull<sys::nix_value>,
|
||||
state: Rc<RefCell<NonNull<sys::EvalState>>>,
|
||||
}
|
||||
|
||||
|
|
@ -51,19 +51,19 @@ impl Debug for NixThunk {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixValue> for NixThunk {
|
||||
impl AsInnerPtr<sys::nix_value> for NixThunk {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixValue {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_value {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixValue {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_value {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixValue {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_value {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -71,10 +71,10 @@ impl AsInnerPtr<sys::NixValue> for NixThunk {
|
|||
impl NixValue for NixThunk {
|
||||
#[inline]
|
||||
fn type_id(&self) -> sys::ValueType {
|
||||
sys::ValueType::Thunk
|
||||
sys::ValueType_NIX_TYPE_THUNK
|
||||
}
|
||||
|
||||
fn from(inner: NonNull<sys::NixValue>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
fn from(inner: NonNull<sys::nix_value>, state: Rc<RefCell<NonNull<sys::EvalState>>>) -> Self {
|
||||
Self { inner, state }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::util::wrap;
|
|||
use crate::util::wrappers::AsInnerPtr;
|
||||
|
||||
pub struct FetchersSettings {
|
||||
inner: NonNull<sys::NixFetchersSettings>,
|
||||
inner: NonNull<sys::nix_fetchers_settings>,
|
||||
}
|
||||
|
||||
impl FetchersSettings {
|
||||
|
|
@ -41,19 +41,19 @@ impl Drop for FetchersSettings {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixFetchersSettings> for FetchersSettings {
|
||||
impl AsInnerPtr<sys::nix_fetchers_settings> for FetchersSettings {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixFetchersSettings {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_fetchers_settings {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixFetchersSettings {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_fetchers_settings {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixFetchersSettings {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_fetchers_settings {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::ffi::c_void;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use super::{FlakeReference, FlakeSettings};
|
||||
|
|
@ -25,7 +26,7 @@ pub enum FlakeLockMode {
|
|||
|
||||
/// Parameters that affect the locking of a flake.
|
||||
pub struct FlakeLockFlags {
|
||||
pub(crate) inner: NonNull<sys::NixFlakeLockFlags>,
|
||||
pub(crate) inner: NonNull<sys::nix_flake_lock_flags>,
|
||||
}
|
||||
|
||||
// impl Clone for FlakeLockFlags {
|
||||
|
|
@ -49,19 +50,19 @@ impl Drop for FlakeLockFlags {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixFlakeLockFlags> for FlakeLockFlags {
|
||||
impl AsInnerPtr<sys::nix_flake_lock_flags> for FlakeLockFlags {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixFlakeLockFlags {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_flake_lock_flags {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixFlakeLockFlags {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_flake_lock_flags {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixFlakeLockFlags {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_flake_lock_flags {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
|
||||
// XXX: TODO: rename FlakeReference -> FlakeRef
|
||||
pub struct FlakeReference {
|
||||
inner: NonNull<sys::NixFlakeReference>,
|
||||
inner: NonNull<sys::nix_flake_reference>,
|
||||
fragment: String,
|
||||
}
|
||||
|
||||
|
|
@ -37,19 +37,19 @@ impl Drop for FlakeReference {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixFlakeReference> for FlakeReference {
|
||||
impl AsInnerPtr<sys::nix_flake_reference> for FlakeReference {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixFlakeReference {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_flake_reference {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixFlakeReference {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_flake_reference {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixFlakeReference {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_flake_reference {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ impl FlakeReference {
|
|||
flags: &FlakeReferenceParseFlags,
|
||||
reference: &str,
|
||||
) -> Result<FlakeReference, NixideError> {
|
||||
let mut ptr: *mut sys::NixFlakeReference = null_mut();
|
||||
let mut ptr: *mut sys::nix_flake_reference = null_mut();
|
||||
let fragment = wrap::nix_string_callback!(
|
||||
|callback, userdata: *mut __UserData, ctx: &ErrorContext| unsafe {
|
||||
sys::nix_flake_reference_and_fragment_from_string(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::ffi::c_void;
|
||||
use std::os::raw::c_char;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
/// Parameters for parsing a flake reference.
|
||||
#[derive(Debug)]
|
||||
pub struct FlakeReferenceParseFlags {
|
||||
inner: NonNull<sys::NixFlakeReferenceParseFlags>,
|
||||
inner: NonNull<sys::nix_flake_reference_parse_flags>,
|
||||
}
|
||||
|
||||
// impl Clone for FlakeReferenceParseFlags {
|
||||
|
|
@ -35,19 +36,19 @@ impl Drop for FlakeReferenceParseFlags {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixFlakeReferenceParseFlags> for FlakeReferenceParseFlags {
|
||||
impl AsInnerPtr<sys::nix_flake_reference_parse_flags> for FlakeReferenceParseFlags {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixFlakeReferenceParseFlags {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_flake_reference_parse_flags {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixFlakeReferenceParseFlags {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_flake_reference_parse_flags {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixFlakeReferenceParseFlags {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_flake_reference_parse_flags {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
|
||||
/// Store settings for the flakes feature.
|
||||
pub struct FlakeSettings {
|
||||
inner: NonNull<sys::NixFlakeSettings>,
|
||||
inner: NonNull<sys::nix_flake_settings>,
|
||||
}
|
||||
|
||||
impl Drop for FlakeSettings {
|
||||
|
|
@ -19,19 +19,19 @@ impl Drop for FlakeSettings {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixFlakeSettings> for FlakeSettings {
|
||||
impl AsInnerPtr<sys::nix_flake_settings> for FlakeSettings {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixFlakeSettings {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_flake_settings {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixFlakeSettings {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_flake_settings {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixFlakeSettings {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_flake_settings {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::util::wrappers::AsInnerPtr;
|
|||
use crate::{EvalState, NixideResult, Value};
|
||||
|
||||
pub struct LockedFlake {
|
||||
inner: NonNull<sys::NixLockedFlake>,
|
||||
inner: NonNull<sys::nix_locked_flake>,
|
||||
|
||||
flakeref: FlakeReference,
|
||||
state: EvalState,
|
||||
|
|
@ -45,19 +45,19 @@ impl Drop for LockedFlake {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsInnerPtr<sys::NixLockedFlake> for LockedFlake {
|
||||
impl AsInnerPtr<sys::nix_locked_flake> for LockedFlake {
|
||||
#[inline]
|
||||
unsafe fn as_ptr(&self) -> *mut sys::NixLockedFlake {
|
||||
unsafe fn as_ptr(&self) -> *mut sys::nix_locked_flake {
|
||||
self.inner.as_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_ref(&self) -> &sys::NixLockedFlake {
|
||||
unsafe fn as_ref(&self) -> &sys::nix_locked_flake {
|
||||
unsafe { self.inner.as_ref() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::NixLockedFlake {
|
||||
unsafe fn as_mut(&mut self) -> &mut sys::nix_locked_flake {
|
||||
unsafe { self.inner.as_mut() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
use crate::errors::ErrorContext;
|
||||
use crate::sys;
|
||||
use crate::util::wrappers::AsInnerPtr as _;
|
||||
use crate::util::{panic_issue_call_failed, wrap};
|
||||
use crate::util::{panic_issue, panic_issue_call_failed, wrap};
|
||||
|
||||
/// Verbosity level
|
||||
///
|
||||
/// # NOTE
|
||||
///
|
||||
/// This should be kept in sync with the C++ implementation (nix::Verbosity)
|
||||
///
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum NixVerbosity {
|
||||
Error,
|
||||
|
|
@ -21,24 +20,28 @@ pub enum NixVerbosity {
|
|||
Vomit,
|
||||
}
|
||||
|
||||
impl From<sys::NixVerbosity> for NixVerbosity {
|
||||
fn from(level: sys::NixVerbosity) -> NixVerbosity {
|
||||
impl From<sys::nix_verbosity> for NixVerbosity {
|
||||
fn from(level: sys::nix_verbosity) -> NixVerbosity {
|
||||
match level {
|
||||
sys::NixVerbosity::Error => NixVerbosity::Error,
|
||||
sys::NixVerbosity::Warn => NixVerbosity::Warn,
|
||||
sys::NixVerbosity::Notice => NixVerbosity::Notice,
|
||||
sys::NixVerbosity::Info => NixVerbosity::Info,
|
||||
sys::NixVerbosity::Talkative => NixVerbosity::Talkative,
|
||||
sys::NixVerbosity::Chatty => NixVerbosity::Chatty,
|
||||
sys::NixVerbosity::Debug => NixVerbosity::Debug,
|
||||
sys::NixVerbosity::Vomit => NixVerbosity::Vomit,
|
||||
sys::nix_verbosity_NIX_LVL_ERROR => NixVerbosity::Error,
|
||||
sys::nix_verbosity_NIX_LVL_WARN => NixVerbosity::Warn,
|
||||
sys::nix_verbosity_NIX_LVL_NOTICE => NixVerbosity::Notice,
|
||||
sys::nix_verbosity_NIX_LVL_INFO => NixVerbosity::Info,
|
||||
sys::nix_verbosity_NIX_LVL_TALKATIVE => NixVerbosity::Talkative,
|
||||
sys::nix_verbosity_NIX_LVL_CHATTY => NixVerbosity::Chatty,
|
||||
sys::nix_verbosity_NIX_LVL_DEBUG => NixVerbosity::Debug,
|
||||
sys::nix_verbosity_NIX_LVL_VOMIT => NixVerbosity::Vomit,
|
||||
value => panic_issue!(
|
||||
"nixide encountered unknown `nix_verbosity` value ({})",
|
||||
value
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<sys::NixVerbosity> for NixVerbosity {
|
||||
fn into(self) -> sys::NixVerbosity {
|
||||
self as sys::NixVerbosity
|
||||
impl Into<sys::nix_verbosity> for NixVerbosity {
|
||||
fn into(self) -> sys::nix_verbosity {
|
||||
self as sys::nix_verbosity
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue