├── docs ├── api │ ├── .lock │ ├── crates.js │ ├── rust_info │ │ ├── types │ │ │ ├── sidebar-items.js │ │ │ └── index.html │ │ ├── sidebar-items.js │ │ ├── all.html │ │ ├── fn.get.html │ │ ├── fn.get_with_options.html │ │ └── index.html │ ├── src-files.js │ ├── static.files │ │ ├── favicon-32x32-00000000d9d8501d.png │ │ ├── FiraSans-Medium-0000000066e2bc86.woff2 │ │ ├── FiraSans-Regular-0000000084b1ad12.woff2 │ │ ├── SourceSerif4-It-000000007236df52.ttf.woff2 │ │ ├── NanumBarunGothic-00000000f861df9d.ttf.woff2 │ │ ├── SourceCodePro-It-00000000668aca82.ttf.woff2 │ │ ├── SourceSerif4-Bold-00000000ad926a49.ttf.woff2 │ │ ├── SourceSerif4-Regular-0000000007da4a04.ttf.woff2 │ │ ├── SourceCodePro-Regular-0000000004ddb02d.ttf.woff2 │ │ ├── SourceCodePro-Semibold-00000000f27a569e.ttf.woff2 │ │ ├── LICENSE-MIT-00000000cc9db09c.txt │ │ ├── normalize-0000000091fda82d.css │ │ ├── COPYRIGHT-000000008a1f0d17.txt │ │ ├── scrape-examples-00000000aae39024.js │ │ ├── rust-logo-00000000a653c8a4.svg │ │ ├── src-script-00000000e6115c00.js │ │ ├── favicon-00000000a292be17.svg │ │ ├── FiraSans-LICENSE-000000004f3fb3ba.txt │ │ ├── SourceCodePro-LICENSE-00000000fb612b27.txt │ │ ├── SourceSerif4-LICENSE-00000000b79e562a.md │ │ ├── NanumBarunGothic-LICENSE-000000008feec719.txt │ │ ├── storage-0000000036c0a5b4.js │ │ ├── settings-000000000a4e6193.js │ │ ├── noscript-00000000626a34ad.css │ │ └── LICENSE-APACHE-00000000be5b60d4.txt │ ├── trait.impl │ │ └── core │ │ │ ├── marker │ │ │ ├── trait.Copy.js │ │ │ ├── trait.StructuralPartialEq.js │ │ │ ├── trait.Send.js │ │ │ ├── trait.Sync.js │ │ │ ├── trait.Unpin.js │ │ │ └── trait.Freeze.js │ │ │ ├── cmp │ │ │ └── trait.PartialEq.js │ │ │ ├── default │ │ │ └── trait.Default.js │ │ │ ├── fmt │ │ │ └── trait.Debug.js │ │ │ ├── clone │ │ │ └── trait.Clone.js │ │ │ └── panic │ │ │ └── unwind_safe │ │ │ ├── trait.UnwindSafe.js │ │ │ └── trait.RefUnwindSafe.js │ ├── search.desc │ │ └── rust_info │ │ │ └── rust_info-desc-0-.js │ ├── search-index.js │ ├── settings.html │ ├── help.html │ └── src │ │ └── rust_info │ │ ├── types.rs.html │ │ ├── triple.rs.html │ │ ├── lib.rs.html │ │ └── rustinfo.rs.html └── index.html ├── .gitattributes ├── .rusty-hook.toml ├── .gitignore ├── .github ├── dependabot.yml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── workflows │ └── ci.yml └── CONTRIBUTING.md ├── src ├── lib_test.rs ├── types_test.rs ├── rustinfo_test.rs ├── types.rs ├── triple.rs ├── rustinfo.rs ├── lib.rs └── triple_test.rs ├── .editorconfig ├── Makefile.toml ├── benches └── bench_get.rs ├── tests ├── get_test.rs └── get_option_test.rs ├── CHANGELOG.md ├── Cargo.toml ├── examples └── example.rs ├── README.md └── LICENSE /docs/api/.lock: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/api/crates.js: -------------------------------------------------------------------------------- 1 | window.ALL_CRATES = ["rust_info"]; -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.ico binary 3 | *.woff binary 4 | -------------------------------------------------------------------------------- /.rusty-hook.toml: -------------------------------------------------------------------------------- 1 | [hooks] 2 | pre-push = "cargo make ci-flow" 3 | -------------------------------------------------------------------------------- /docs/api/rust_info/types/sidebar-items.js: -------------------------------------------------------------------------------- 1 | window.SIDEBAR_ITEMS = {"enum":["RustChannel"],"struct":["RustInfo"]}; -------------------------------------------------------------------------------- /docs/api/rust_info/sidebar-items.js: -------------------------------------------------------------------------------- 1 | window.SIDEBAR_ITEMS = {"fn":["get","get_with_options"],"mod":["types"],"struct":["Options"]}; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .c9 3 | /target 4 | temp/ 5 | **/*.rs.bk 6 | Cargo.lock 7 | **/*.log 8 | dump.rdb 9 | /rs*.sh 10 | /docs/_site 11 | /core 12 | -------------------------------------------------------------------------------- /docs/api/src-files.js: -------------------------------------------------------------------------------- 1 | var srcIndex = new Map(JSON.parse('[\ 2 | ["rust_info",["",[],["lib.rs","rustinfo.rs","triple.rs","types.rs"]]]\ 3 | ]')); 4 | createSrcSidebar(); 5 | -------------------------------------------------------------------------------- /docs/api/static.files/favicon-32x32-00000000d9d8501d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/favicon-32x32-00000000d9d8501d.png -------------------------------------------------------------------------------- /docs/api/static.files/FiraSans-Medium-0000000066e2bc86.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/FiraSans-Medium-0000000066e2bc86.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/FiraSans-Regular-0000000084b1ad12.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/FiraSans-Regular-0000000084b1ad12.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-It-000000007236df52.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/SourceSerif4-It-000000007236df52.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/NanumBarunGothic-00000000f861df9d.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/NanumBarunGothic-00000000f861df9d.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceCodePro-It-00000000668aca82.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/SourceCodePro-It-00000000668aca82.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-Bold-00000000ad926a49.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/SourceSerif4-Bold-00000000ad926a49.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-Regular-0000000007da4a04.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/SourceSerif4-Regular-0000000007da4a04.ttf.woff2 -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: '03:00' 8 | open-pull-requests-limit: 99 9 | -------------------------------------------------------------------------------- /docs/api/static.files/SourceCodePro-Regular-0000000004ddb02d.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/SourceCodePro-Regular-0000000004ddb02d.ttf.woff2 -------------------------------------------------------------------------------- /docs/api/static.files/SourceCodePro-Semibold-00000000f27a569e.ttf.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/rust_info/master/docs/api/static.files/SourceCodePro-Semibold-00000000f27a569e.ttf.woff2 -------------------------------------------------------------------------------- /src/lib_test.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use doc_comment as _; 3 | 4 | #[test] 5 | fn get_test() { 6 | let rust_info = get(); 7 | 8 | assert!(rust_info.version.is_some()); 9 | assert!(rust_info.channel.is_some()); 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | indent_style = space 10 | indent_size = 4 11 | 12 | [*.json] 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Makefile.toml: -------------------------------------------------------------------------------- 1 | 2 | [config] 3 | additional_profiles = [ 4 | "all-default-tasks", 5 | "docs-all-modification-tasks", 6 | "ci-coverage-tasks", 7 | "ci-all-build-tasks", 8 | "ci-static-code-analysis-tasks", 9 | "publish-pre-cleanup", 10 | ] 11 | 12 | [env] 13 | CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS = true 14 | 15 | -------------------------------------------------------------------------------- /benches/bench_get.rs: -------------------------------------------------------------------------------- 1 | #![feature(test)] 2 | extern crate test; 3 | 4 | use rust_info; 5 | use test::Bencher; 6 | 7 | #[bench] 8 | fn get(bencher: &mut Bencher) { 9 | bencher.iter(|| { 10 | let rust_info = rust_info::get(); 11 | 12 | assert!(rust_info.version.is_some()); 13 | assert!(rust_info.channel.is_some()); 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /tests/get_test.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn get() { 3 | let rust_info = rust_info::get(); 4 | 5 | assert!(rust_info.version.is_some()); 6 | assert!(rust_info.channel.is_some()); 7 | assert!(rust_info.target_arch.is_some()); 8 | assert!(rust_info.target_env.is_some()); 9 | assert!(rust_info.target_os.is_some()); 10 | assert!(rust_info.target_pointer_width.is_some()); 11 | assert!(rust_info.target_triple.is_some()); 12 | } 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: sagiegurari 7 | 8 | --- 9 | 10 | ### Feature Description 11 | 12 | 13 | ### Describe The Solution You'd Like 14 | 15 | 16 | ### Code Sample 17 | 18 | ```rust 19 | /// paste code here 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.Copy.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Copy for RustChannel"]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: sagiegurari 7 | 8 | --- 9 | 10 | ### Describe The Bug 11 | 12 | 13 | ### To Reproduce 14 | 15 | 16 | ### Error Stack 17 | 18 | ```console 19 | The error stack trace 20 | ``` 21 | 22 | ### Code Sample 23 | 24 | ```rust 25 | /// paste code here 26 | ``` 27 | -------------------------------------------------------------------------------- /src/types_test.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | 3 | #[test] 4 | fn rust_info_new() { 5 | let rust_info = RustInfo::new(); 6 | 7 | assert!(rust_info.version.is_none()); 8 | assert!(rust_info.channel.is_none()); 9 | assert!(rust_info.target_arch.is_none()); 10 | assert!(rust_info.target_env.is_none()); 11 | assert!(rust_info.target_os.is_none()); 12 | assert!(rust_info.target_pointer_width.is_none()); 13 | assert!(rust_info.target_vendor.is_none()); 14 | assert!(rust_info.target_triple.is_none()); 15 | } 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## CHANGELOG 2 | 3 | ### v0.3.3 (2024-08-30) 4 | 5 | * Enhancement: Serde support (as optional feature) #7 (thanks @SamuelMarks) 6 | 7 | ### v0.3.2 (2021-07-30) 8 | 9 | * Enhancement: enable to fetch info from custom directory location #5 (thanks @EliseZeroTwo) 10 | 11 | ### v0.3.1 (2020-05-01) 12 | 13 | * Fix target_triple for multiple platforms #3 14 | 15 | ### v0.3.0 (2019-01-06) 16 | 17 | * Adding target_triple information. 18 | 19 | ### v0.1.1 (2017-10-10) 20 | 21 | * Update exposed types. 22 | 23 | ### v0.1.0 (2017-10-10) 24 | 25 | * Initial release 26 | -------------------------------------------------------------------------------- /tests/get_option_test.rs: -------------------------------------------------------------------------------- 1 | use std::path::Path; 2 | 3 | use rust_info::Options; 4 | 5 | #[test] 6 | fn get() { 7 | let opts = Options::new().path(Some(Path::new("./").into())); 8 | let rust_info = rust_info::get_with_options(&opts); 9 | 10 | assert!(rust_info.version.is_some()); 11 | assert!(rust_info.channel.is_some()); 12 | assert!(rust_info.target_arch.is_some()); 13 | assert!(rust_info.target_env.is_some()); 14 | assert!(rust_info.target_os.is_some()); 15 | assert!(rust_info.target_pointer_width.is_some()); 16 | assert!(rust_info.target_triple.is_some()); 17 | } 18 | -------------------------------------------------------------------------------- /src/rustinfo_test.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use std::io::ErrorKind; 3 | 4 | #[test] 5 | fn get_exit_code_error() { 6 | let code = get_exit_code(Err(Error::new(ErrorKind::Other, "test"))); 7 | assert_eq!(code, -1); 8 | } 9 | 10 | #[test] 11 | fn load_with_values() { 12 | let rust_info = crate::get(); 13 | 14 | assert!(rust_info.version.is_some()); 15 | assert!(rust_info.channel.is_some()); 16 | assert!(rust_info.target_arch.is_some()); 17 | assert!(rust_info.target_env.is_some()); 18 | assert!(rust_info.target_os.is_some()); 19 | assert!(rust_info.target_pointer_width.is_some()); 20 | assert!(rust_info.target_triple.is_some()); 21 | } 22 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | env: 4 | CLICOLOR_FORCE: 1 5 | jobs: 6 | ci: 7 | name: CI 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | rust: [stable, beta, nightly] 13 | os: [ubuntu-latest, windows-latest, macOS-latest] 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | - name: Install rust 18 | uses: dtolnay/rust-toolchain@master 19 | with: 20 | toolchain: ${{ matrix.rust }} 21 | - name: Install cargo-make 22 | run: cargo install --debug cargo-make 23 | - name: Run CI 24 | env: 25 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 26 | run: cargo make ci-flow 27 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/cmp/trait.PartialEq.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl PartialEq for RustChannel"],["impl PartialEq for RustInfo"]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/trait.impl/core/default/trait.Default.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Default for RustInfo"],["impl<'path> Default for Options<'path>"]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.StructuralPartialEq.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl StructuralPartialEq for RustChannel"],["impl StructuralPartialEq for RustInfo"]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/search.desc/rust_info/rust_info-desc-0-.js: -------------------------------------------------------------------------------- 1 | searchState.loadedDescShard("rust_info", 0, "rust_info\nOptions used for querying rust info\nReturns the argument unchanged.\nLoads and returns the current rust compiler version and …\nLoads and returns the current rust compiler version and …\nCalls U::from(self).\nHelper for calling default\nSets the path option\nOptionally override working directory used for querying …\ntypes\nRust beta channel\nRust nightly channel\nRust channel type\nHolds the current rust installation and setup information\nRust stable channel\nchannel\nReturns the argument unchanged.\nReturns the argument unchanged.\nCalls U::from(self).\nCalls U::from(self).\nReturns new instance\ntarget arch cfg value\ntarget env cfg value\ntarget OS cfg value\ntarget pointer width cfg value\ntarget triple constructed from target arc, vendor, os and …\ntarget vendor cfg value\nversion") -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust_info" 3 | version = "0.3.3" 4 | authors = ["Sagie Gur-Ari "] 5 | description = "Extracts the current rust compiler information." 6 | license = "Apache-2.0" 7 | edition = "2021" 8 | documentation = "https://sagiegurari.github.io/rust_info/api/rust_info/index.html" 9 | homepage = "http://github.com/sagiegurari/rust_info" 10 | repository = "https://github.com/sagiegurari/rust_info.git" 11 | readme = "README.md" 12 | keywords = ["rust", "compiler", "os"] 13 | categories = ["rust-patterns"] 14 | include = [ 15 | "/benches/*", 16 | "/docs/*", 17 | "/examples/*", 18 | "/src/*", 19 | "/tests/*", 20 | "/Cargo.toml", 21 | "/LICENSE", 22 | "/README.md", 23 | "/Makefile.toml", 24 | ] 25 | 26 | [dev-dependencies] 27 | doc-comment = "^0.3" 28 | 29 | [dependencies] 30 | serde = { version = "^1", optional = true, features = ["serde_derive"] } 31 | 32 | [features] 33 | serde = ["dep:serde"] 34 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | 4 | ## Issues 5 | 6 | Found a bug? Got a question? Want some enhancement?
7 | First place to go is the repository issues section, and I'll try to help as much as possible. 8 | 9 | ## Pull Requests 10 | 11 | Fixed a bug or just want to provided additional functionality?
12 | Simply fork this repository, implement your changes and create a pull request.
13 | Few guidelines regarding pull requests: 14 | 15 | * This repository is integrated with github actions for continuous integration.
16 | 17 | Your pull request build must pass (the build will run automatically).
18 | You can run the following command locally to ensure the build will pass: 19 | 20 | ````sh 21 | cargo make ci-flow 22 | ```` 23 | 24 | * There are many automatic unit tests as part of the library which provide full coverage of the functionality.
Any fix/enhancement must come with a set of tests to ensure it's working well. 25 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/fmt/trait.Debug.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Debug for RustChannel"],["impl Debug for RustInfo"],["impl<'path> Debug for Options<'path>"]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/trait.impl/core/clone/trait.Clone.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Clone for RustChannel"],["impl Clone for RustInfo"],["impl<'path> Clone for Options<'path>"]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /examples/example.rs: -------------------------------------------------------------------------------- 1 | use rust_info; 2 | 3 | fn main() { 4 | let rust_info = rust_info::get(); 5 | 6 | println!("Version: {}", rust_info.version.unwrap()); 7 | println!("Channel: {:#?}", rust_info.channel.unwrap()); 8 | println!( 9 | "Target Arch: {}", 10 | rust_info.target_arch.unwrap_or("unknown".to_string()) 11 | ); 12 | println!( 13 | "Target Env: {}", 14 | rust_info.target_env.unwrap_or("unknown".to_string()) 15 | ); 16 | println!( 17 | "Target OS: {}", 18 | rust_info.target_os.unwrap_or("unknown".to_string()) 19 | ); 20 | println!( 21 | "Target Pointer Width: {}", 22 | rust_info 23 | .target_pointer_width 24 | .unwrap_or("unknown".to_string()) 25 | ); 26 | println!( 27 | "Target Vendor: {}", 28 | rust_info.target_vendor.unwrap_or("unknown".to_string()) 29 | ); 30 | println!( 31 | "Target Triple: {}", 32 | rust_info.target_triple.unwrap_or("unknown".to_string()) 33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.Send.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Send for RustChannel",1,["rust_info::types::RustChannel"]],["impl Send for RustInfo",1,["rust_info::types::RustInfo"]],["impl<'path> Send for Options<'path>",1,["rust_info::Options"]]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.Sync.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Sync for RustChannel",1,["rust_info::types::RustChannel"]],["impl Sync for RustInfo",1,["rust_info::types::RustInfo"]],["impl<'path> Sync for Options<'path>",1,["rust_info::Options"]]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.Unpin.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Unpin for RustChannel",1,["rust_info::types::RustChannel"]],["impl Unpin for RustInfo",1,["rust_info::types::RustInfo"]],["impl<'path> Unpin for Options<'path>",1,["rust_info::Options"]]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/trait.impl/core/marker/trait.Freeze.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl Freeze for RustChannel",1,["rust_info::types::RustChannel"]],["impl Freeze for RustInfo",1,["rust_info::types::RustInfo"]],["impl<'path> Freeze for Options<'path>",1,["rust_info::Options"]]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/static.files/LICENSE-MIT-00000000cc9db09c.txt: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /docs/api/trait.impl/core/panic/unwind_safe/trait.UnwindSafe.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl UnwindSafe for RustChannel",1,["rust_info::types::RustChannel"]],["impl UnwindSafe for RustInfo",1,["rust_info::types::RustInfo"]],["impl<'path> UnwindSafe for Options<'path>",1,["rust_info::Options"]]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/api/trait.impl/core/panic/unwind_safe/trait.RefUnwindSafe.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = { 2 | "rust_info":[["impl RefUnwindSafe for RustChannel",1,["rust_info::types::RustChannel"]],["impl RefUnwindSafe for RustInfo",1,["rust_info::types::RustInfo"]],["impl<'path> RefUnwindSafe for Options<'path>",1,["rust_info::Options"]]] 3 | };if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /src/types.rs: -------------------------------------------------------------------------------- 1 | //! # types 2 | //! 3 | //! Defines the various types and aliases. 4 | //! 5 | 6 | #[cfg(test)] 7 | #[path = "./types_test.rs"] 8 | mod types_test; 9 | 10 | #[derive(Debug, Clone, PartialEq, Copy)] 11 | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] 12 | /// Rust channel type 13 | pub enum RustChannel { 14 | /// Rust stable channel 15 | Stable, 16 | /// Rust beta channel 17 | Beta, 18 | /// Rust nightly channel 19 | Nightly, 20 | } 21 | 22 | #[derive(Debug, Clone, PartialEq, Default)] 23 | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] 24 | /// Holds the current rust installation and setup information 25 | pub struct RustInfo { 26 | /// version 27 | pub version: Option, 28 | /// channel 29 | pub channel: Option, 30 | /// target arch cfg value 31 | pub target_arch: Option, 32 | /// target env cfg value 33 | pub target_env: Option, 34 | /// target OS cfg value 35 | pub target_os: Option, 36 | /// target pointer width cfg value 37 | pub target_pointer_width: Option, 38 | /// target vendor cfg value 39 | pub target_vendor: Option, 40 | /// target triple constructed from target arc, vendor, os and env 41 | pub target_triple: Option, 42 | } 43 | 44 | impl RustInfo { 45 | /// Returns new instance 46 | pub fn new() -> RustInfo { 47 | Default::default() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /docs/api/search-index.js: -------------------------------------------------------------------------------- 1 | var searchIndex = new Map(JSON.parse('[\ 2 | ["rust_info",{"t":"FNNNNNNNHHNNNONNNNCPPGFPNNNNONNNNNNNNNNNNNNOOOOOONNNNNNNNO","n":["Options","borrow","borrow_mut","clone","clone_into","default","fmt","from","get","get_with_options","into","new","path","path","to_owned","try_from","try_into","type_id","types","Beta","Nightly","RustChannel","RustInfo","Stable","borrow","borrow","borrow_mut","borrow_mut","channel","clone","clone","clone_into","clone_into","default","eq","eq","fmt","fmt","from","from","into","into","new","target_arch","target_env","target_os","target_pointer_width","target_triple","target_vendor","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","version"],"q":[[0,"rust_info"],[19,"rust_info::types"],[58,"core::fmt"],[59,"std::path"],[60,"alloc::borrow"],[61,"core::option"],[62,"core::result"],[63,"core::any"]],"i":[0,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,0,13,13,0,0,13,13,7,13,7,7,13,7,13,7,7,13,7,13,7,13,7,13,7,7,7,7,7,7,7,7,13,7,13,7,13,7,13,7,7],"f":"`{{{b{c}}}{{b{e}}}{}{}}{{{b{dc}}}{{b{de}}}{}{}}{{{b{f}}}f}{{{b{c}}{b{de}}}h{}{}}{{}f}{{{b{f}}{b{dj}}}l}{cc{}}{{}n}{{{b{f}}}n}{ce{}{}}5{{f{Ad{{Ab{A`}}}}}f}`{{{b{c}}}e{}{}}{c{{Af{e}}}{}{}}0{{{b{c}}}Ah{}}``````==<<`{{{b{Aj}}}Aj}{{{b{n}}}n}<<8{{{b{Aj}}{b{Aj}}}Al}{{{b{n}}{b{n}}}Al}{{{b{Aj}}{b{dj}}}l}{{{b{n}}{b{dj}}}l}==::<``````88777766`","D":"Ch","p":[[1,"reference"],[0,"mut"],[5,"Options",0],[1,"unit"],[5,"Formatter",58],[8,"Result",58],[5,"RustInfo",19],[5,"Path",59],[6,"Cow",60],[6,"Option",61],[6,"Result",62],[5,"TypeId",63],[6,"RustChannel",19],[1,"bool"]],"r":[],"b":[],"c":"OjAAAAAAAAA=","e":"OzAAAAEAAB4ABQACAAUADwADABkAAwAeAAgAMgAHAA=="}]\ 3 | ]')); 4 | if (typeof exports !== 'undefined') exports.searchIndex = searchIndex; 5 | else if (window.initSearch) window.initSearch(searchIndex); 6 | -------------------------------------------------------------------------------- /docs/api/static.files/normalize-0000000091fda82d.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ 2 | html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type="button"],[type="reset"],[type="submit"],button{-webkit-appearance:button}[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none} -------------------------------------------------------------------------------- /docs/api/static.files/COPYRIGHT-000000008a1f0d17.txt: -------------------------------------------------------------------------------- 1 | # REUSE-IgnoreStart 2 | 3 | These documentation pages include resources by third parties. This copyright 4 | file applies only to those resources. The following third party resources are 5 | included, and carry their own copyright notices and license terms: 6 | 7 | * Fira Sans (FiraSans-Regular.woff2, FiraSans-Medium.woff2): 8 | 9 | Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ 10 | with Reserved Font Name Fira Sans. 11 | 12 | Copyright (c) 2014, Telefonica S.A. 13 | 14 | Licensed under the SIL Open Font License, Version 1.1. 15 | See FiraSans-LICENSE.txt. 16 | 17 | * rustdoc.css, main.js, and playpen.js: 18 | 19 | Copyright 2015 The Rust Developers. 20 | Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE.txt) or 21 | the MIT license (LICENSE-MIT.txt) at your option. 22 | 23 | * normalize.css: 24 | 25 | Copyright (c) Nicolas Gallagher and Jonathan Neal. 26 | Licensed under the MIT license (see LICENSE-MIT.txt). 27 | 28 | * Source Code Pro (SourceCodePro-Regular.ttf.woff2, 29 | SourceCodePro-Semibold.ttf.woff2, SourceCodePro-It.ttf.woff2): 30 | 31 | Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), 32 | with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark 33 | of Adobe Systems Incorporated in the United States and/or other countries. 34 | 35 | Licensed under the SIL Open Font License, Version 1.1. 36 | See SourceCodePro-LICENSE.txt. 37 | 38 | * Source Serif 4 (SourceSerif4-Regular.ttf.woff2, SourceSerif4-Bold.ttf.woff2, 39 | SourceSerif4-It.ttf.woff2): 40 | 41 | Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 42 | 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United 43 | States and/or other countries. 44 | 45 | Licensed under the SIL Open Font License, Version 1.1. 46 | See SourceSerif4-LICENSE.md. 47 | 48 | This copyright file is intended to be distributed with rustdoc output. 49 | 50 | # REUSE-IgnoreEnd 51 | -------------------------------------------------------------------------------- /src/triple.rs: -------------------------------------------------------------------------------- 1 | //! # triple 2 | //! 3 | //! Manages the rust triple values and logic. 4 | //! 5 | 6 | #[cfg(test)] 7 | #[path = "./triple_test.rs"] 8 | mod triple_test; 9 | 10 | use crate::types::RustInfo; 11 | 12 | pub(crate) fn load(rust_info: &mut RustInfo) { 13 | if let (Some(arch), Some(os)) = (&rust_info.target_arch, &rust_info.target_os) { 14 | let mut triple = String::new(); 15 | let mapped_arch = map_arch(arch); 16 | triple.push_str(&mapped_arch); 17 | 18 | if let Some(vendor) = &rust_info.target_vendor { 19 | let mapped_vendor = map_vendor(vendor, os); 20 | 21 | triple.push_str("-"); 22 | triple.push_str(&mapped_vendor); 23 | } 24 | 25 | let mapped_os = map_os(os, arch); 26 | triple.push_str("-"); 27 | triple.push_str(&mapped_os); 28 | 29 | if let Some(env) = &rust_info.target_env { 30 | if !env.is_empty() { 31 | let mapped_env = map_env(env, arch); 32 | triple.push_str("-"); 33 | triple.push_str(&mapped_env); 34 | } 35 | } 36 | 37 | rust_info.target_triple = Some(triple); 38 | } 39 | } 40 | 41 | fn map_arch(arch: &str) -> String { 42 | match arch { 43 | "x86" => "i686".to_string(), 44 | _ => arch.to_string(), 45 | } 46 | } 47 | 48 | fn map_vendor(vendor: &str, os: &str) -> String { 49 | match os { 50 | "android" => "linux".to_string(), 51 | _ => vendor.to_string(), 52 | } 53 | } 54 | 55 | fn map_os(os: &str, arch: &str) -> String { 56 | match os { 57 | "macos" => "darwin".to_string(), 58 | "android" => match arch { 59 | "arm" => "androideabi".to_string(), 60 | _ => os.to_string(), 61 | }, 62 | _ => os.to_string(), 63 | } 64 | } 65 | 66 | fn map_env(env: &str, arch: &str) -> String { 67 | match env { 68 | "gnu" => match arch { 69 | "arm" => "gnueabihf".to_string(), 70 | _ => env.to_string(), 71 | }, 72 | _ => env.to_string(), 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /docs/api/static.files/scrape-examples-00000000aae39024.js: -------------------------------------------------------------------------------- 1 | "use strict";(function(){const DEFAULT_MAX_LINES=5;const HIDDEN_MAX_LINES=10;function scrollToLoc(elt,loc,isHidden){const lines=elt.querySelector(".src-line-numbers");let scrollOffset;const maxLines=isHidden?HIDDEN_MAX_LINES:DEFAULT_MAX_LINES;if(loc[1]-loc[0]>maxLines){const line=Math.max(0,loc[0]-1);scrollOffset=lines.children[line].offsetTop}else{const wrapper=elt.querySelector(".code-wrapper");const halfHeight=wrapper.offsetHeight/2;const offsetTop=lines.children[loc[0]].offsetTop;const lastLine=lines.children[loc[1]];const offsetBot=lastLine.offsetTop+lastLine.offsetHeight;const offsetMid=(offsetTop+offsetBot)/2;scrollOffset=offsetMid-halfHeight}lines.scrollTo(0,scrollOffset);elt.querySelector(".rust").scrollTo(0,scrollOffset)}function updateScrapedExample(example,isHidden){const locs=JSON.parse(example.attributes.getNamedItem("data-locs").textContent);let locIndex=0;const highlights=Array.prototype.slice.call(example.querySelectorAll(".highlight"));const link=example.querySelector(".scraped-example-title a");if(locs.length>1){const onChangeLoc=changeIndex=>{removeClass(highlights[locIndex],"focus");changeIndex();scrollToLoc(example,locs[locIndex][0],isHidden);addClass(highlights[locIndex],"focus");const url=locs[locIndex][1];const title=locs[locIndex][2];link.href=url;link.innerHTML=title};example.querySelector(".prev").addEventListener("click",()=>{onChangeLoc(()=>{locIndex=(locIndex-1+locs.length)%locs.length})});example.querySelector(".next").addEventListener("click",()=>{onChangeLoc(()=>{locIndex=(locIndex+1)%locs.length})})}const expandButton=example.querySelector(".expand");if(expandButton){expandButton.addEventListener("click",()=>{if(hasClass(example,"expanded")){removeClass(example,"expanded");scrollToLoc(example,locs[0][0],isHidden)}else{addClass(example,"expanded")}})}scrollToLoc(example,locs[0][0],isHidden)}const firstExamples=document.querySelectorAll(".scraped-example-list > .scraped-example");onEachLazy(firstExamples,el=>updateScrapedExample(el,false));onEachLazy(document.querySelectorAll(".more-examples-toggle"),toggle=>{onEachLazy(toggle.querySelectorAll(".toggle-line, .hide-more"),button=>{button.addEventListener("click",()=>{toggle.open=false})});const moreExamples=toggle.querySelectorAll(".scraped-example");toggle.querySelector("summary").addEventListener("click",()=>{setTimeout(()=>{onEachLazy(moreExamples,el=>updateScrapedExample(el,true))})},{once:true})})})() -------------------------------------------------------------------------------- /docs/api/settings.html: -------------------------------------------------------------------------------- 1 | Settings

Rustdoc settings

Back
-------------------------------------------------------------------------------- /docs/api/rust_info/all.html: -------------------------------------------------------------------------------- 1 | List of all items in this crate
-------------------------------------------------------------------------------- /docs/api/help.html: -------------------------------------------------------------------------------- 1 | Help

Rustdoc help

Back
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rust_info 2 | 3 | [![crates.io](https://img.shields.io/crates/v/rust_info.svg)](https://crates.io/crates/rust_info) [![CI](https://github.com/sagiegurari/rust_info/workflows/CI/badge.svg?branch=master)](https://github.com/sagiegurari/rust_info/actions) [![codecov](https://codecov.io/gh/sagiegurari/rust_info/branch/master/graph/badge.svg)](https://codecov.io/gh/sagiegurari/rust_info)
4 | [![license](https://img.shields.io/crates/l/rust_info.svg)](https://github.com/sagiegurari/rust_info/blob/master/LICENSE) [![Libraries.io for GitHub](https://img.shields.io/librariesio/github/sagiegurari/rust_info.svg)](https://libraries.io/cargo/rust_info) [![Documentation](https://docs.rs/rust_info/badge.svg)](https://docs.rs/crate/rust_info/) [![downloads](https://img.shields.io/crates/d/rust_info.svg)](https://crates.io/crates/rust_info)
5 | [![Built with cargo-make](https://sagiegurari.github.io/cargo-make/assets/badges/cargo-make.svg)](https://sagiegurari.github.io/cargo-make) 6 | 7 | > Extracts the current [rust](https://www.rust-lang.org/) compiler information. 8 | 9 | * [Overview](#overview) 10 | * [Usage](#usage) 11 | * [Installation](#installation) 12 | * [API Documentation](https://sagiegurari.github.io/rust_info/) 13 | * [Contributing](.github/CONTRIBUTING.md) 14 | * [Release History](CHANGELOG.md) 15 | * [License](#license) 16 | 17 | 18 | ## Overview 19 | This library main goal is to provide development/build tools such as [cargo-make](https://sagiegurari.github.io/cargo-make/) the needed information on the current rust installation and setup. 20 | 21 | 22 | ## Usage 23 | Simply include the library and invoke the get function to pull all info as follows: 24 | 25 | 26 | ```rust 27 | fn main() { 28 | let rust_info = rust_info::get(); 29 | 30 | println!("Version: {}", rust_info.version.unwrap()); 31 | println!("Channel: {:#?}", rust_info.channel.unwrap()); 32 | println!( 33 | "Target Arch: {}", 34 | rust_info.target_arch.unwrap_or("unknown".to_string()) 35 | ); 36 | println!( 37 | "Target Env: {}", 38 | rust_info.target_env.unwrap_or("unknown".to_string()) 39 | ); 40 | println!( 41 | "Target OS: {}", 42 | rust_info.target_os.unwrap_or("unknown".to_string()) 43 | ); 44 | println!( 45 | "Target Pointer Width: {}", 46 | rust_info 47 | .target_pointer_width 48 | .unwrap_or("unknown".to_string()) 49 | ); 50 | println!( 51 | "Target Vendor: {}", 52 | rust_info.target_vendor.unwrap_or("unknown".to_string()) 53 | ); 54 | println!( 55 | "Target Triple: {}", 56 | rust_info.target_triple.unwrap_or("unknown".to_string()) 57 | ); 58 | } 59 | ``` 60 | 61 | 62 | 63 | ## Installation 64 | In order to use this library, just add it as a dependency: 65 | 66 | ```ini 67 | [dependencies] 68 | rust_info = "^0.3.3" 69 | ``` 70 | 71 | ## API Documentation 72 | See full docs at: [API Docs](https://sagiegurari.github.io/rust_info/) 73 | 74 | ## Contributing 75 | See [contributing guide](.github/CONTRIBUTING.md) 76 | 77 | 78 | ## Release History 79 | 80 | See [Changelog](CHANGELOG.md) 81 | 82 | 83 | ## License 84 | Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license. 85 | -------------------------------------------------------------------------------- /docs/api/static.files/rust-logo-00000000a653c8a4.svg: -------------------------------------------------------------------------------- 1 | 2 | 61 | 62 | -------------------------------------------------------------------------------- /docs/api/static.files/src-script-00000000e6115c00.js: -------------------------------------------------------------------------------- 1 | "use strict";(function(){const rootPath=getVar("root-path");const NAME_OFFSET=0;const DIRS_OFFSET=1;const FILES_OFFSET=2;const RUSTDOC_MOBILE_BREAKPOINT=700;function closeSidebarIfMobile(){if(window.innerWidth{removeClass(document.documentElement,"src-sidebar-expanded");updateLocalStorage("source-sidebar-show","false")};window.rustdocShowSourceSidebar=()=>{addClass(document.documentElement,"src-sidebar-expanded");updateLocalStorage("source-sidebar-show","true")};window.rustdocToggleSrcSidebar=()=>{if(document.documentElement.classList.contains("src-sidebar-expanded")){window.rustdocCloseSourceSidebar()}else{window.rustdocShowSourceSidebar()}};function createSrcSidebar(){const container=document.querySelector("nav.sidebar");const sidebar=document.createElement("div");sidebar.id="src-sidebar";let hasFoundFile=false;for(const[key,source]of srcIndex){source[NAME_OFFSET]=key;hasFoundFile=createDirEntry(source,sidebar,"",hasFoundFile)}container.appendChild(sidebar);const selected_elem=sidebar.getElementsByClassName("selected")[0];if(typeof selected_elem!=="undefined"){selected_elem.focus()}}function highlightSrcLines(){const match=window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);if(!match){return}let from=parseInt(match[1],10);let to=from;if(typeof match[2]!=="undefined"){to=parseInt(match[2],10)}if(to{onEachLazy(e.getElementsByTagName("a"),i_e=>{removeClass(i_e,"line-highlighted")})});for(let i=from;i<=to;++i){elem=document.getElementById(i);if(!elem){break}addClass(elem,"line-highlighted")}}const handleSrcHighlight=(function(){let prev_line_id=0;const set_fragment=name=>{const x=window.scrollX,y=window.scrollY;if(browserSupportsHistoryApi()){history.replaceState(null,null,"#"+name);highlightSrcLines()}else{location.replace("#"+name)}window.scrollTo(x,y)};return ev=>{let cur_line_id=parseInt(ev.target.id,10);if(isNaN(cur_line_id)||ev.ctrlKey||ev.altKey||ev.metaKey){return}ev.preventDefault();if(ev.shiftKey&&prev_line_id){if(prev_line_id>cur_line_id){const tmp=prev_line_id;prev_line_id=cur_line_id;cur_line_id=tmp}set_fragment(prev_line_id+"-"+cur_line_id)}else{prev_line_id=cur_line_id;set_fragment(cur_line_id)}}}());window.addEventListener("hashchange",highlightSrcLines);onEachLazy(document.getElementsByClassName("src-line-numbers"),el=>{el.addEventListener("click",handleSrcHighlight)});highlightSrcLines();window.createSrcSidebar=createSrcSidebar})() -------------------------------------------------------------------------------- /docs/api/rust_info/types/index.html: -------------------------------------------------------------------------------- 1 | rust_info::types - Rust

Module rust_info::types

source ·
Expand description

§types

2 |

Defines the various types and aliases.

3 |

Structs§

  • Holds the current rust installation and setup information

Enums§

-------------------------------------------------------------------------------- /docs/api/static.files/favicon-00000000a292be17.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/api/rust_info/fn.get.html: -------------------------------------------------------------------------------- 1 | get in rust_info - Rust

Function rust_info::get

source ·
pub fn get() -> RustInfo
Expand description

Loads and returns the current rust compiler version and setup.
2 | In case partial data is not available, those values will be set to Option::None.

3 |

§Example

4 |
fn main() {
 5 |     let rust_info = rust_info::get();
 6 | 
 7 |     println!("Version: {}", rust_info.version.unwrap());
 8 |     println!("Channel: {:#?}", rust_info.channel.unwrap());
 9 |     println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string()));
10 |     println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string()));
11 |     println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string()));
12 |     println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string()));
13 |     println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string()));
14 |     println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string()));
15 | }
16 |
-------------------------------------------------------------------------------- /docs/api/static.files/FiraSans-LICENSE-000000004f3fb3ba.txt: -------------------------------------------------------------------------------- 1 | // REUSE-IgnoreStart 2 | 3 | Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. 4 | with Reserved Font Name < Fira >, 5 | 6 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 7 | This license is copied below, and is also available with a FAQ at: 8 | http://scripts.sil.org/OFL 9 | 10 | 11 | ----------------------------------------------------------- 12 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 13 | ----------------------------------------------------------- 14 | 15 | PREAMBLE 16 | The goals of the Open Font License (OFL) are to stimulate worldwide 17 | development of collaborative font projects, to support the font creation 18 | efforts of academic and linguistic communities, and to provide a free and 19 | open framework in which fonts may be shared and improved in partnership 20 | with others. 21 | 22 | The OFL allows the licensed fonts to be used, studied, modified and 23 | redistributed freely as long as they are not sold by themselves. The 24 | fonts, including any derivative works, can be bundled, embedded, 25 | redistributed and/or sold with any software provided that any reserved 26 | names are not used by derivative works. The fonts and derivatives, 27 | however, cannot be released under any other type of license. The 28 | requirement for fonts to remain under this license does not apply 29 | to any document created using the fonts or their derivatives. 30 | 31 | DEFINITIONS 32 | "Font Software" refers to the set of files released by the Copyright 33 | Holder(s) under this license and clearly marked as such. This may 34 | include source files, build scripts and documentation. 35 | 36 | "Reserved Font Name" refers to any names specified as such after the 37 | copyright statement(s). 38 | 39 | "Original Version" refers to the collection of Font Software components as 40 | distributed by the Copyright Holder(s). 41 | 42 | "Modified Version" refers to any derivative made by adding to, deleting, 43 | or substituting -- in part or in whole -- any of the components of the 44 | Original Version, by changing formats or by porting the Font Software to a 45 | new environment. 46 | 47 | "Author" refers to any designer, engineer, programmer, technical 48 | writer or other person who contributed to the Font Software. 49 | 50 | PERMISSION & CONDITIONS 51 | Permission is hereby granted, free of charge, to any person obtaining 52 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 53 | redistribute, and sell modified and unmodified copies of the Font 54 | Software, subject to the following conditions: 55 | 56 | 1) Neither the Font Software nor any of its individual components, 57 | in Original or Modified Versions, may be sold by itself. 58 | 59 | 2) Original or Modified Versions of the Font Software may be bundled, 60 | redistributed and/or sold with any software, provided that each copy 61 | contains the above copyright notice and this license. These can be 62 | included either as stand-alone text files, human-readable headers or 63 | in the appropriate machine-readable metadata fields within text or 64 | binary files as long as those fields can be easily viewed by the user. 65 | 66 | 3) No Modified Version of the Font Software may use the Reserved Font 67 | Name(s) unless explicit written permission is granted by the corresponding 68 | Copyright Holder. This restriction only applies to the primary font name as 69 | presented to the users. 70 | 71 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 72 | Software shall not be used to promote, endorse or advertise any 73 | Modified Version, except to acknowledge the contribution(s) of the 74 | Copyright Holder(s) and the Author(s) or with their explicit written 75 | permission. 76 | 77 | 5) The Font Software, modified or unmodified, in part or in whole, 78 | must be distributed entirely under this license, and must not be 79 | distributed under any other license. The requirement for fonts to 80 | remain under this license does not apply to any document created 81 | using the Font Software. 82 | 83 | TERMINATION 84 | This license becomes null and void if any of the above conditions are 85 | not met. 86 | 87 | DISCLAIMER 88 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 89 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 90 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 91 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 92 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 93 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 94 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 95 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 96 | OTHER DEALINGS IN THE FONT SOFTWARE. 97 | 98 | // REUSE-IgnoreEnd 99 | -------------------------------------------------------------------------------- /docs/api/static.files/SourceCodePro-LICENSE-00000000fb612b27.txt: -------------------------------------------------------------------------------- 1 | // REUSE-IgnoreStart 2 | 3 | Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. 4 | 5 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 6 | 7 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 8 | 9 | 10 | ----------------------------------------------------------- 11 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 12 | ----------------------------------------------------------- 13 | 14 | PREAMBLE 15 | The goals of the Open Font License (OFL) are to stimulate worldwide 16 | development of collaborative font projects, to support the font creation 17 | efforts of academic and linguistic communities, and to provide a free and 18 | open framework in which fonts may be shared and improved in partnership 19 | with others. 20 | 21 | The OFL allows the licensed fonts to be used, studied, modified and 22 | redistributed freely as long as they are not sold by themselves. The 23 | fonts, including any derivative works, can be bundled, embedded, 24 | redistributed and/or sold with any software provided that any reserved 25 | names are not used by derivative works. The fonts and derivatives, 26 | however, cannot be released under any other type of license. The 27 | requirement for fonts to remain under this license does not apply 28 | to any document created using the fonts or their derivatives. 29 | 30 | DEFINITIONS 31 | "Font Software" refers to the set of files released by the Copyright 32 | Holder(s) under this license and clearly marked as such. This may 33 | include source files, build scripts and documentation. 34 | 35 | "Reserved Font Name" refers to any names specified as such after the 36 | copyright statement(s). 37 | 38 | "Original Version" refers to the collection of Font Software components as 39 | distributed by the Copyright Holder(s). 40 | 41 | "Modified Version" refers to any derivative made by adding to, deleting, 42 | or substituting -- in part or in whole -- any of the components of the 43 | Original Version, by changing formats or by porting the Font Software to a 44 | new environment. 45 | 46 | "Author" refers to any designer, engineer, programmer, technical 47 | writer or other person who contributed to the Font Software. 48 | 49 | PERMISSION & CONDITIONS 50 | Permission is hereby granted, free of charge, to any person obtaining 51 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 52 | redistribute, and sell modified and unmodified copies of the Font 53 | Software, subject to the following conditions: 54 | 55 | 1) Neither the Font Software nor any of its individual components, 56 | in Original or Modified Versions, may be sold by itself. 57 | 58 | 2) Original or Modified Versions of the Font Software may be bundled, 59 | redistributed and/or sold with any software, provided that each copy 60 | contains the above copyright notice and this license. These can be 61 | included either as stand-alone text files, human-readable headers or 62 | in the appropriate machine-readable metadata fields within text or 63 | binary files as long as those fields can be easily viewed by the user. 64 | 65 | 3) No Modified Version of the Font Software may use the Reserved Font 66 | Name(s) unless explicit written permission is granted by the corresponding 67 | Copyright Holder. This restriction only applies to the primary font name as 68 | presented to the users. 69 | 70 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 71 | Software shall not be used to promote, endorse or advertise any 72 | Modified Version, except to acknowledge the contribution(s) of the 73 | Copyright Holder(s) and the Author(s) or with their explicit written 74 | permission. 75 | 76 | 5) The Font Software, modified or unmodified, in part or in whole, 77 | must be distributed entirely under this license, and must not be 78 | distributed under any other license. The requirement for fonts to 79 | remain under this license does not apply to any document created 80 | using the Font Software. 81 | 82 | TERMINATION 83 | This license becomes null and void if any of the above conditions are 84 | not met. 85 | 86 | DISCLAIMER 87 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 88 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 89 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 90 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 91 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 92 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 93 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 94 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 95 | OTHER DEALINGS IN THE FONT SOFTWARE. 96 | 97 | // REUSE-IgnoreEnd 98 | -------------------------------------------------------------------------------- /docs/api/static.files/SourceSerif4-LICENSE-00000000b79e562a.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. 4 | Copyright 2014 - 2023 Adobe (http://www.adobe.com/), with Reserved Font Name ‘Source’. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. 5 | 6 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 7 | 8 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 9 | 10 | 11 | ----------------------------------------------------------- 12 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 13 | ----------------------------------------------------------- 14 | 15 | PREAMBLE 16 | The goals of the Open Font License (OFL) are to stimulate worldwide 17 | development of collaborative font projects, to support the font creation 18 | efforts of academic and linguistic communities, and to provide a free and 19 | open framework in which fonts may be shared and improved in partnership 20 | with others. 21 | 22 | The OFL allows the licensed fonts to be used, studied, modified and 23 | redistributed freely as long as they are not sold by themselves. The 24 | fonts, including any derivative works, can be bundled, embedded, 25 | redistributed and/or sold with any software provided that any reserved 26 | names are not used by derivative works. The fonts and derivatives, 27 | however, cannot be released under any other type of license. The 28 | requirement for fonts to remain under this license does not apply 29 | to any document created using the fonts or their derivatives. 30 | 31 | DEFINITIONS 32 | "Font Software" refers to the set of files released by the Copyright 33 | Holder(s) under this license and clearly marked as such. This may 34 | include source files, build scripts and documentation. 35 | 36 | "Reserved Font Name" refers to any names specified as such after the 37 | copyright statement(s). 38 | 39 | "Original Version" refers to the collection of Font Software components as 40 | distributed by the Copyright Holder(s). 41 | 42 | "Modified Version" refers to any derivative made by adding to, deleting, 43 | or substituting -- in part or in whole -- any of the components of the 44 | Original Version, by changing formats or by porting the Font Software to a 45 | new environment. 46 | 47 | "Author" refers to any designer, engineer, programmer, technical 48 | writer or other person who contributed to the Font Software. 49 | 50 | PERMISSION & CONDITIONS 51 | Permission is hereby granted, free of charge, to any person obtaining 52 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 53 | redistribute, and sell modified and unmodified copies of the Font 54 | Software, subject to the following conditions: 55 | 56 | 1) Neither the Font Software nor any of its individual components, 57 | in Original or Modified Versions, may be sold by itself. 58 | 59 | 2) Original or Modified Versions of the Font Software may be bundled, 60 | redistributed and/or sold with any software, provided that each copy 61 | contains the above copyright notice and this license. These can be 62 | included either as stand-alone text files, human-readable headers or 63 | in the appropriate machine-readable metadata fields within text or 64 | binary files as long as those fields can be easily viewed by the user. 65 | 66 | 3) No Modified Version of the Font Software may use the Reserved Font 67 | Name(s) unless explicit written permission is granted by the corresponding 68 | Copyright Holder. This restriction only applies to the primary font name as 69 | presented to the users. 70 | 71 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 72 | Software shall not be used to promote, endorse or advertise any 73 | Modified Version, except to acknowledge the contribution(s) of the 74 | Copyright Holder(s) and the Author(s) or with their explicit written 75 | permission. 76 | 77 | 5) The Font Software, modified or unmodified, in part or in whole, 78 | must be distributed entirely under this license, and must not be 79 | distributed under any other license. The requirement for fonts to 80 | remain under this license does not apply to any document created 81 | using the Font Software. 82 | 83 | TERMINATION 84 | This license becomes null and void if any of the above conditions are 85 | not met. 86 | 87 | DISCLAIMER 88 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 89 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 90 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 91 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 92 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 93 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 94 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 95 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 96 | OTHER DEALINGS IN THE FONT SOFTWARE. 97 | 98 | 99 | -------------------------------------------------------------------------------- /docs/api/rust_info/fn.get_with_options.html: -------------------------------------------------------------------------------- 1 | get_with_options in rust_info - Rust

Function rust_info::get_with_options

source ·
pub fn get_with_options(options: &Options<'_>) -> RustInfo
Expand description

Loads and returns the current rust compiler version and setup for a specified path.
2 | In case partial data is not available, those values will be set to Option::None.

3 |

§Example

4 |
fn main() {
 5 |     let opts = rust_info::Options::new().path(Some(std::path::Path::new("./").into()));
 6 |     let rust_info = rust_info::get_with_options(&opts);
 7 | 
 8 |     println!("Version: {}", rust_info.version.unwrap());
 9 |     println!("Channel: {:#?}", rust_info.channel.unwrap());
10 |     println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string()));
11 |     println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string()));
12 |     println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string()));
13 |     println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string()));
14 |     println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string()));
15 |     println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string()));
16 | }
17 |
-------------------------------------------------------------------------------- /src/rustinfo.rs: -------------------------------------------------------------------------------- 1 | //! # rustinfo 2 | //! 3 | //! Loads rust compiler information. 4 | //! 5 | 6 | #[cfg(test)] 7 | #[path = "./rustinfo_test.rs"] 8 | mod rustinfo_test; 9 | 10 | use crate::types::{RustChannel, RustInfo}; 11 | use crate::{triple, Options}; 12 | use std::collections::HashMap; 13 | use std::io::Error; 14 | use std::process::{Command, ExitStatus}; 15 | 16 | /// Returns the exit code (-1 if no exit code found) 17 | fn get_exit_code(exit_status: Result) -> i32 { 18 | match exit_status { 19 | Ok(code) => { 20 | if !code.success() { 21 | match code.code() { 22 | Some(value) => value, 23 | None => -1, 24 | } 25 | } else { 26 | 0 27 | } 28 | } 29 | _ => -1, 30 | } 31 | } 32 | 33 | fn load_version(rust_info: &mut RustInfo, options: &Options) { 34 | let mut command = Command::new("rustc"); 35 | 36 | command.arg("--version"); 37 | 38 | if let Some(directory) = &options.path { 39 | command.current_dir(directory); 40 | } 41 | 42 | let result = command.output(); 43 | 44 | match result { 45 | Ok(output) => { 46 | let exit_code = get_exit_code(Ok(output.status)); 47 | 48 | if exit_code == 0 { 49 | let stdout = String::from_utf8_lossy(&output.stdout); 50 | let parts: Vec<&str> = stdout.split(' ').collect(); 51 | 52 | if (parts.len() >= 3) && (parts[0] == "rustc") { 53 | let version_part = parts[1]; 54 | 55 | let version_parts: Vec<&str> = version_part.split('-').collect(); 56 | 57 | if version_parts.len() > 0 { 58 | rust_info.version = Some(version_parts[0].to_string()); 59 | 60 | if version_parts.len() == 1 { 61 | rust_info.channel = Some(RustChannel::Stable); 62 | } else if version_parts[1].contains("beta") { 63 | rust_info.channel = Some(RustChannel::Beta); 64 | } else if version_parts[1].contains("nightly") { 65 | rust_info.channel = Some(RustChannel::Nightly); 66 | } 67 | } 68 | } 69 | } 70 | } 71 | _ => (), 72 | }; 73 | } 74 | 75 | fn load_setup(rust_info: &mut RustInfo, options: &Options) { 76 | let mut command = Command::new("rustc"); 77 | 78 | command.arg("--print").arg("cfg"); 79 | 80 | if let Some(directory) = &options.path { 81 | command.current_dir(directory); 82 | } 83 | 84 | let result = command.output(); 85 | 86 | match result { 87 | Ok(output) => { 88 | let exit_code = get_exit_code(Ok(output.status)); 89 | 90 | if exit_code == 0 { 91 | let mut values = HashMap::::new(); 92 | 93 | let stdout = String::from_utf8_lossy(&output.stdout); 94 | let lines: Vec<&str> = stdout.split('\n').collect(); 95 | for mut line in lines { 96 | line = line.trim(); 97 | 98 | if line.contains("=") { 99 | let parts: Vec<&str> = line.split('=').collect(); 100 | let value = str::replace(parts[1], "\"", ""); 101 | values.insert(parts[0].to_string(), value.to_string()); 102 | } 103 | } 104 | 105 | let mut value = values.remove("target_arch"); 106 | if value.is_some() { 107 | rust_info.target_arch = Some(value.unwrap()); 108 | } 109 | 110 | value = values.remove("target_env"); 111 | if value.is_some() { 112 | rust_info.target_env = Some(value.unwrap()); 113 | } 114 | 115 | value = values.remove("target_os"); 116 | if value.is_some() { 117 | rust_info.target_os = Some(value.unwrap()); 118 | } 119 | 120 | value = values.remove("target_pointer_width"); 121 | if value.is_some() { 122 | rust_info.target_pointer_width = Some(value.unwrap()); 123 | } 124 | 125 | value = values.remove("target_vendor"); 126 | if value.is_some() { 127 | rust_info.target_vendor = Some(value.unwrap()); 128 | } 129 | } 130 | } 131 | _ => (), 132 | }; 133 | } 134 | 135 | /// Loads and returns the current rust compiler version and setup.
136 | /// In case partial data is not available, those values will be set to Option::None. 137 | pub(crate) fn get(options: &Options) -> RustInfo { 138 | let mut rust_info = RustInfo::new(); 139 | 140 | load_version(&mut rust_info, options); 141 | 142 | load_setup(&mut rust_info, options); 143 | 144 | triple::load(&mut rust_info); 145 | 146 | rust_info 147 | } 148 | -------------------------------------------------------------------------------- /docs/api/static.files/NanumBarunGothic-LICENSE-000000008feec719.txt: -------------------------------------------------------------------------------- 1 | // REUSE-IgnoreStart 2 | 3 | Copyright (c) 2010, NAVER Corporation (https://www.navercorp.com/), 4 | 5 | with Reserved Font Name Nanum, Naver Nanum, NanumGothic, Naver NanumGothic, 6 | NanumMyeongjo, Naver NanumMyeongjo, NanumBrush, Naver NanumBrush, NanumPen, 7 | Naver NanumPen, Naver NanumGothicEco, NanumGothicEco, Naver NanumMyeongjoEco, 8 | NanumMyeongjoEco, Naver NanumGothicLight, NanumGothicLight, NanumBarunGothic, 9 | Naver NanumBarunGothic, NanumSquareRound, NanumBarunPen, MaruBuri 10 | 11 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 12 | This license is copied below, and is also available with a FAQ at: 13 | http://scripts.sil.org/OFL 14 | 15 | 16 | ----------------------------------------------------------- 17 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 18 | ----------------------------------------------------------- 19 | 20 | PREAMBLE 21 | The goals of the Open Font License (OFL) are to stimulate worldwide 22 | development of collaborative font projects, to support the font creation 23 | efforts of academic and linguistic communities, and to provide a free and 24 | open framework in which fonts may be shared and improved in partnership 25 | with others. 26 | 27 | The OFL allows the licensed fonts to be used, studied, modified and 28 | redistributed freely as long as they are not sold by themselves. The 29 | fonts, including any derivative works, can be bundled, embedded, 30 | redistributed and/or sold with any software provided that any reserved 31 | names are not used by derivative works. The fonts and derivatives, 32 | however, cannot be released under any other type of license. The 33 | requirement for fonts to remain under this license does not apply 34 | to any document created using the fonts or their derivatives. 35 | 36 | DEFINITIONS 37 | "Font Software" refers to the set of files released by the Copyright 38 | Holder(s) under this license and clearly marked as such. This may 39 | include source files, build scripts and documentation. 40 | 41 | "Reserved Font Name" refers to any names specified as such after the 42 | copyright statement(s). 43 | 44 | "Original Version" refers to the collection of Font Software components as 45 | distributed by the Copyright Holder(s). 46 | 47 | "Modified Version" refers to any derivative made by adding to, deleting, 48 | or substituting -- in part or in whole -- any of the components of the 49 | Original Version, by changing formats or by porting the Font Software to a 50 | new environment. 51 | 52 | "Author" refers to any designer, engineer, programmer, technical 53 | writer or other person who contributed to the Font Software. 54 | 55 | PERMISSION & CONDITIONS 56 | Permission is hereby granted, free of charge, to any person obtaining 57 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 58 | redistribute, and sell modified and unmodified copies of the Font 59 | Software, subject to the following conditions: 60 | 61 | 1) Neither the Font Software nor any of its individual components, 62 | in Original or Modified Versions, may be sold by itself. 63 | 64 | 2) Original or Modified Versions of the Font Software may be bundled, 65 | redistributed and/or sold with any software, provided that each copy 66 | contains the above copyright notice and this license. These can be 67 | included either as stand-alone text files, human-readable headers or 68 | in the appropriate machine-readable metadata fields within text or 69 | binary files as long as those fields can be easily viewed by the user. 70 | 71 | 3) No Modified Version of the Font Software may use the Reserved Font 72 | Name(s) unless explicit written permission is granted by the corresponding 73 | Copyright Holder. This restriction only applies to the primary font name as 74 | presented to the users. 75 | 76 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 77 | Software shall not be used to promote, endorse or advertise any 78 | Modified Version, except to acknowledge the contribution(s) of the 79 | Copyright Holder(s) and the Author(s) or with their explicit written 80 | permission. 81 | 82 | 5) The Font Software, modified or unmodified, in part or in whole, 83 | must be distributed entirely under this license, and must not be 84 | distributed under any other license. The requirement for fonts to 85 | remain under this license does not apply to any document created 86 | using the Font Software. 87 | 88 | TERMINATION 89 | This license becomes null and void if any of the above conditions are 90 | not met. 91 | 92 | DISCLAIMER 93 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 94 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 95 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 96 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 97 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 98 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 99 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 100 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 101 | OTHER DEALINGS IN THE FONT SOFTWARE. 102 | 103 | // REUSE-IgnoreEnd 104 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![deny( 2 | future_incompatible, 3 | keyword_idents, 4 | let_underscore, 5 | nonstandard_style, 6 | unused 7 | )] 8 | #![warn(unknown_lints)] 9 | 10 | //! # rust_info 11 | //! 12 | //! Extracts and provides the current rust compiler information. 13 | //! 14 | //! This library main goal is to provide development/build tools such as 15 | //! [cargo-make](https://sagiegurari.github.io/cargo-make/)the needed information on the current rust installation and 16 | //! setup. 17 | //! 18 | //! # Examples 19 | //! 20 | //! ``` 21 | //! fn main() { 22 | //! let rust_info = rust_info::get(); 23 | //! 24 | //! println!("Version: {}", rust_info.version.unwrap()); 25 | //! println!("Channel: {:#?}", rust_info.channel.unwrap()); 26 | //! println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string())); 27 | //! println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string())); 28 | //! println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string())); 29 | //! println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string())); 30 | //! println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string())); 31 | //! println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string())); 32 | //! } 33 | //! ``` 34 | //! 35 | //! # Installation 36 | //! In order to use this library, just add it as a dependency: 37 | //! 38 | //! ```ini 39 | //! [dependencies] 40 | //! rust_info = "*" 41 | //! ``` 42 | //! 43 | //! # Contributing 44 | //! See [contributing guide](https://github.com/sagiegurari/rust_info/blob/master/.github/CONTRIBUTING.md) 45 | //! 46 | //! # License 47 | //! Developed by Sagie Gur-Ari and licensed under the 48 | //! [Apache 2](https://github.com/sagiegurari/rust_info/blob/master/LICENSE) open source license. 49 | //! 50 | 51 | #[cfg(test)] 52 | #[path = "./lib_test.rs"] 53 | mod lib_test; 54 | 55 | #[cfg(doctest)] 56 | doc_comment::doctest!("../README.md"); 57 | 58 | mod rustinfo; 59 | mod triple; 60 | pub mod types; 61 | 62 | use std::{borrow::Cow, path::Path}; 63 | 64 | use crate::types::RustInfo; 65 | 66 | /// Options used for querying rust info 67 | #[derive(Debug, Clone)] 68 | pub struct Options<'path> { 69 | /// Optionally override working directory used for querying `rustc` 70 | pub path: Option>, 71 | } 72 | 73 | impl<'path> Default for Options<'path> { 74 | fn default() -> Self { 75 | Self { path: None } 76 | } 77 | } 78 | 79 | impl<'path> Options<'path> { 80 | /// Helper for calling `default` 81 | pub fn new() -> Self { 82 | Self::default() 83 | } 84 | 85 | /// Sets the `path` option 86 | pub fn path(mut self, path: Option>) -> Self { 87 | self.path = path; 88 | self 89 | } 90 | } 91 | 92 | /// Loads and returns the current rust compiler version and setup.
93 | /// In case partial data is not available, those values will be set to Option::None. 94 | /// 95 | /// # Example 96 | /// 97 | /// ``` 98 | /// fn main() { 99 | /// let rust_info = rust_info::get(); 100 | /// 101 | /// println!("Version: {}", rust_info.version.unwrap()); 102 | /// println!("Channel: {:#?}", rust_info.channel.unwrap()); 103 | /// println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string())); 104 | /// println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string())); 105 | /// println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string())); 106 | /// println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string())); 107 | /// println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string())); 108 | /// println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string())); 109 | /// } 110 | /// ``` 111 | pub fn get() -> RustInfo { 112 | get_with_options(&Options::default()) 113 | } 114 | 115 | /// Loads and returns the current rust compiler version and setup for a specified path.
116 | /// In case partial data is not available, those values will be set to Option::None. 117 | /// 118 | /// # Example 119 | /// 120 | /// ``` 121 | /// fn main() { 122 | /// let opts = rust_info::Options::new().path(Some(std::path::Path::new("./").into())); 123 | /// let rust_info = rust_info::get_with_options(&opts); 124 | /// 125 | /// println!("Version: {}", rust_info.version.unwrap()); 126 | /// println!("Channel: {:#?}", rust_info.channel.unwrap()); 127 | /// println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string())); 128 | /// println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string())); 129 | /// println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string())); 130 | /// println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string())); 131 | /// println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string())); 132 | /// println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string())); 133 | /// } 134 | /// ``` 135 | pub fn get_with_options(options: &Options) -> RustInfo { 136 | rustinfo::get(options) 137 | } 138 | -------------------------------------------------------------------------------- /docs/api/static.files/storage-0000000036c0a5b4.js: -------------------------------------------------------------------------------- 1 | "use strict";const builtinThemes=["light","dark","ayu"];const darkThemes=["dark","ayu"];window.currentTheme=document.getElementById("themeStyle");const settingsDataset=(function(){const settingsElement=document.getElementById("default-settings");return settingsElement&&settingsElement.dataset?settingsElement.dataset:null})();function getSettingValue(settingName){const current=getCurrentValue(settingName);if(current===null&&settingsDataset!==null){const def=settingsDataset[settingName.replace(/-/g,"_")];if(def!==undefined){return def}}return current}const localStoredTheme=getSettingValue("theme");function hasClass(elem,className){return elem&&elem.classList&&elem.classList.contains(className)}function addClass(elem,className){if(elem&&elem.classList){elem.classList.add(className)}}function removeClass(elem,className){if(elem&&elem.classList){elem.classList.remove(className)}}function onEach(arr,func){for(const elem of arr){if(func(elem)){return true}}return false}function onEachLazy(lazyArray,func){return onEach(Array.prototype.slice.call(lazyArray),func)}function updateLocalStorage(name,value){try{window.localStorage.setItem("rustdoc-"+name,value)}catch(e){}}function getCurrentValue(name){try{return window.localStorage.getItem("rustdoc-"+name)}catch(e){return null}}const getVar=(function getVar(name){const el=document.querySelector("head > meta[name='rustdoc-vars']");return el?el.attributes["data-"+name].value:null});function switchTheme(newThemeName,saveTheme){const themeNames=getVar("themes").split(",").filter(t=>t);themeNames.push(...builtinThemes);if(themeNames.indexOf(newThemeName)===-1){return}if(saveTheme){updateLocalStorage("theme",newThemeName)}document.documentElement.setAttribute("data-theme",newThemeName);if(builtinThemes.indexOf(newThemeName)!==-1){if(window.currentTheme){window.currentTheme.parentNode.removeChild(window.currentTheme);window.currentTheme=null}}else{const newHref=getVar("root-path")+encodeURIComponent(newThemeName)+getVar("resource-suffix")+".css";if(!window.currentTheme){if(document.readyState==="loading"){document.write(``);window.currentTheme=document.getElementById("themeStyle")}else{window.currentTheme=document.createElement("link");window.currentTheme.rel="stylesheet";window.currentTheme.id="themeStyle";window.currentTheme.href=newHref;document.documentElement.appendChild(window.currentTheme)}}else if(newHref!==window.currentTheme.href){window.currentTheme.href=newHref}}}const updateTheme=(function(){const mql=window.matchMedia("(prefers-color-scheme: dark)");function updateTheme(){if(getSettingValue("use-system-theme")!=="false"){const lightTheme=getSettingValue("preferred-light-theme")||"light";const darkTheme=getSettingValue("preferred-dark-theme")||"dark";updateLocalStorage("use-system-theme","true");switchTheme(mql.matches?darkTheme:lightTheme,true)}else{switchTheme(getSettingValue("theme"),false)}}mql.addEventListener("change",updateTheme);return updateTheme})();if(getSettingValue("use-system-theme")!=="false"&&window.matchMedia){if(getSettingValue("use-system-theme")===null&&getSettingValue("preferred-dark-theme")===null&&darkThemes.indexOf(localStoredTheme)>=0){updateLocalStorage("preferred-dark-theme",localStoredTheme)}}updateTheme();if(getSettingValue("source-sidebar-show")==="true"){addClass(document.documentElement,"src-sidebar-expanded")}if(getSettingValue("hide-sidebar")==="true"){addClass(document.documentElement,"hide-sidebar")}function updateSidebarWidth(){const desktopSidebarWidth=getSettingValue("desktop-sidebar-width");if(desktopSidebarWidth&&desktopSidebarWidth!=="null"){document.documentElement.style.setProperty("--desktop-sidebar-width",desktopSidebarWidth+"px",)}const srcSidebarWidth=getSettingValue("src-sidebar-width");if(srcSidebarWidth&&srcSidebarWidth!=="null"){document.documentElement.style.setProperty("--src-sidebar-width",srcSidebarWidth+"px",)}}updateSidebarWidth();window.addEventListener("pageshow",ev=>{if(ev.persisted){setTimeout(updateTheme,0);setTimeout(updateSidebarWidth,0)}});class RustdocSearchElement extends HTMLElement{constructor(){super()}connectedCallback(){const rootPath=getVar("root-path");const currentCrate=getVar("current-crate");this.innerHTML=``}}window.customElements.define("rustdoc-search",RustdocSearchElement) -------------------------------------------------------------------------------- /docs/api/static.files/settings-000000000a4e6193.js: -------------------------------------------------------------------------------- 1 | "use strict";(function(){const isSettingsPage=window.location.pathname.endsWith("/settings.html");function changeSetting(settingName,value){if(settingName==="theme"){const useSystem=value==="system preference"?"true":"false";updateLocalStorage("use-system-theme",useSystem)}updateLocalStorage(settingName,value);switch(settingName){case"theme":case"preferred-dark-theme":case"preferred-light-theme":updateTheme();updateLightAndDark();break;case"line-numbers":if(value===true){window.rustdoc_add_line_numbers_to_examples()}else{window.rustdoc_remove_line_numbers_from_examples()}break;case"hide-sidebar":if(value===true){addClass(document.documentElement,"hide-sidebar")}else{removeClass(document.documentElement,"hide-sidebar")}break}}function showLightAndDark(){removeClass(document.getElementById("preferred-light-theme"),"hidden");removeClass(document.getElementById("preferred-dark-theme"),"hidden")}function hideLightAndDark(){addClass(document.getElementById("preferred-light-theme"),"hidden");addClass(document.getElementById("preferred-dark-theme"),"hidden")}function updateLightAndDark(){const useSystem=getSettingValue("use-system-theme");if(useSystem==="true"||(useSystem===null&&getSettingValue("theme")===null)){showLightAndDark()}else{hideLightAndDark()}}function setEvents(settingsElement){updateLightAndDark();onEachLazy(settingsElement.querySelectorAll("input[type=\"checkbox\"]"),toggle=>{const settingId=toggle.id;const settingValue=getSettingValue(settingId);if(settingValue!==null){toggle.checked=settingValue==="true"}toggle.onchange=()=>{changeSetting(toggle.id,toggle.checked)}});onEachLazy(settingsElement.querySelectorAll("input[type=\"radio\"]"),elem=>{const settingId=elem.name;let settingValue=getSettingValue(settingId);if(settingId==="theme"){const useSystem=getSettingValue("use-system-theme");if(useSystem==="true"||settingValue===null){settingValue=useSystem==="false"?"light":"system preference"}}if(settingValue!==null&&settingValue!=="null"){elem.checked=settingValue===elem.value}elem.addEventListener("change",ev=>{changeSetting(ev.target.name,ev.target.value)})})}function buildSettingsPageSections(settings){let output="";for(const setting of settings){const js_data_name=setting["js_name"];const setting_name=setting["name"];if(setting["options"]!==undefined){output+=`\ 2 |
3 |
${setting_name}
4 |
`;onEach(setting["options"],option=>{const checked=option===setting["default"]?" checked":"";const full=`${js_data_name}-${option.replace(/ /g,"-")}`;output+=`\ 5 | `});output+=`\ 10 |
11 |
`}else{const checked=setting["default"]===true?" checked":"";output+=`\ 12 |
\ 13 | \ 17 |
`}}return output}function buildSettingsPage(){const theme_names=getVar("themes").split(",").filter(t=>t);theme_names.push("light","dark","ayu");const settings=[{"name":"Theme","js_name":"theme","default":"system preference","options":theme_names.concat("system preference"),},{"name":"Preferred light theme","js_name":"preferred-light-theme","default":"light","options":theme_names,},{"name":"Preferred dark theme","js_name":"preferred-dark-theme","default":"dark","options":theme_names,},{"name":"Auto-hide item contents for large items","js_name":"auto-hide-large-items","default":true,},{"name":"Auto-hide item methods' documentation","js_name":"auto-hide-method-docs","default":false,},{"name":"Auto-hide trait implementation documentation","js_name":"auto-hide-trait-implementations","default":false,},{"name":"Directly go to item in search if there is only one result","js_name":"go-to-only-result","default":false,},{"name":"Show line numbers on code examples","js_name":"line-numbers","default":false,},{"name":"Hide persistent navigation bar","js_name":"hide-sidebar","default":false,},{"name":"Disable keyboard shortcuts","js_name":"disable-shortcuts","default":false,},];const elementKind=isSettingsPage?"section":"div";const innerHTML=`
${buildSettingsPageSections(settings)}
`;const el=document.createElement(elementKind);el.id="settings";if(!isSettingsPage){el.className="popover"}el.innerHTML=innerHTML;if(isSettingsPage){document.getElementById(MAIN_ID).appendChild(el)}else{el.setAttribute("tabindex","-1");getSettingsButton().appendChild(el)}return el}const settingsMenu=buildSettingsPage();function displaySettings(){settingsMenu.style.display="";onEachLazy(settingsMenu.querySelectorAll("input[type='checkbox']"),el=>{const val=getSettingValue(el.id);const checked=val==="true";if(checked!==el.checked&&val!==null){el.checked=checked}})}function settingsBlurHandler(event){blurHandler(event,getSettingsButton(),window.hidePopoverMenus)}if(isSettingsPage){getSettingsButton().onclick=event=>{event.preventDefault()}}else{const settingsButton=getSettingsButton();const settingsMenu=document.getElementById("settings");settingsButton.onclick=event=>{if(settingsMenu.contains(event.target)){return}event.preventDefault();const shouldDisplaySettings=settingsMenu.style.display==="none";window.hideAllModals();if(shouldDisplaySettings){displaySettings()}};settingsButton.onblur=settingsBlurHandler;settingsButton.querySelector("a").onblur=settingsBlurHandler;onEachLazy(settingsMenu.querySelectorAll("input"),el=>{el.onblur=settingsBlurHandler});settingsMenu.onblur=settingsBlurHandler}setTimeout(()=>{setEvents(settingsMenu);if(!isSettingsPage){displaySettings()}removeClass(getSettingsButton(),"rotate")},0)})() -------------------------------------------------------------------------------- /docs/api/src/rust_info/types.rs.html: -------------------------------------------------------------------------------- 1 | types.rs - source
1
 2 | 2
 3 | 3
 4 | 4
 5 | 5
 6 | 6
 7 | 7
 8 | 8
 9 | 9
10 | 10
11 | 11
12 | 12
13 | 13
14 | 14
15 | 15
16 | 16
17 | 17
18 | 18
19 | 19
20 | 20
21 | 21
22 | 22
23 | 23
24 | 24
25 | 25
26 | 26
27 | 27
28 | 28
29 | 29
30 | 30
31 | 31
32 | 32
33 | 33
34 | 34
35 | 35
36 | 36
37 | 37
38 | 38
39 | 39
40 | 40
41 | 41
42 | 42
43 | 43
44 | 44
45 | 45
46 | 46
47 | 47
48 | 48
49 | 49
50 | 
//! # types
51 | //!
52 | //! Defines the various types and aliases.
53 | //!
54 | 
55 | #[cfg(test)]
56 | #[path = "./types_test.rs"]
57 | mod types_test;
58 | 
59 | #[derive(Debug, Clone, PartialEq, Copy)]
60 | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
61 | /// Rust channel type
62 | pub enum RustChannel {
63 |     /// Rust stable channel
64 |     Stable,
65 |     /// Rust beta channel
66 |     Beta,
67 |     /// Rust nightly channel
68 |     Nightly,
69 | }
70 | 
71 | #[derive(Debug, Clone, PartialEq, Default)]
72 | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
73 | /// Holds the current rust installation and setup information
74 | pub struct RustInfo {
75 |     /// version
76 |     pub version: Option<String>,
77 |     /// channel
78 |     pub channel: Option<RustChannel>,
79 |     /// target arch cfg value
80 |     pub target_arch: Option<String>,
81 |     /// target env cfg value
82 |     pub target_env: Option<String>,
83 |     /// target OS cfg value
84 |     pub target_os: Option<String>,
85 |     /// target pointer width cfg value
86 |     pub target_pointer_width: Option<String>,
87 |     /// target vendor cfg value
88 |     pub target_vendor: Option<String>,
89 |     /// target triple constructed from target arc, vendor, os and env
90 |     pub target_triple: Option<String>,
91 | }
92 | 
93 | impl RustInfo {
94 |     /// Returns new instance
95 |     pub fn new() -> RustInfo {
96 |         Default::default()
97 |     }
98 | }
99 | 
-------------------------------------------------------------------------------- /docs/api/rust_info/index.html: -------------------------------------------------------------------------------- 1 | rust_info - Rust

Crate rust_info

source ·
Expand description

§rust_info

2 |

Extracts and provides the current rust compiler information.

3 |

This library main goal is to provide development/build tools such as 4 | cargo-makethe needed information on the current rust installation and 5 | setup.

6 |

§Examples

7 |
fn main() {
 8 |     let rust_info = rust_info::get();
 9 | 
10 |     println!("Version: {}", rust_info.version.unwrap());
11 |     println!("Channel: {:#?}", rust_info.channel.unwrap());
12 |     println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string()));
13 |     println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string()));
14 |     println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string()));
15 |     println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string()));
16 |     println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string()));
17 |     println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string()));
18 | }
19 |

§Installation

20 |

In order to use this library, just add it as a dependency:

21 |
[dependencies]
22 | rust_info = "*"
23 | 

§Contributing

24 |

See contributing guide

25 |

§License

26 |

Developed by Sagie Gur-Ari and licensed under the 27 | Apache 2 open source license.

28 |

Modules§

Structs§

  • Options used for querying rust info

Functions§

  • Loads and returns the current rust compiler version and setup.
    29 | In case partial data is not available, those values will be set to Option::None.
  • Loads and returns the current rust compiler version and setup for a specified path.
    30 | In case partial data is not available, those values will be set to Option::None.
-------------------------------------------------------------------------------- /docs/api/static.files/noscript-00000000626a34ad.css: -------------------------------------------------------------------------------- 1 | #main-content .attributes{margin-left:0 !important;}#copy-path,#sidebar-button,.sidebar-resizer{display:none !important;}nav.sub{display:none;}.src .sidebar{display:none;}.notable-traits{display:none;}:root,:root:not([data-theme]){--main-background-color:white;--main-color:black;--settings-input-color:#2196f3;--settings-input-border-color:#717171;--settings-button-color:#000;--settings-button-border-focus:#717171;--sidebar-background-color:#f5f5f5;--sidebar-background-color-hover:#e0e0e0;--code-block-background-color:#f5f5f5;--scrollbar-track-background-color:#dcdcdc;--scrollbar-thumb-background-color:rgba(36,37,39,0.6);--scrollbar-color:rgba(36,37,39,0.6) #d9d9d9;--headings-border-bottom-color:#ddd;--border-color:#e0e0e0;--button-background-color:#fff;--right-side-color:grey;--code-attribute-color:#999;--toggles-color:#999;--toggle-filter:none;--mobile-sidebar-menu-filter:none;--search-input-focused-border-color:#66afe9;--copy-path-button-color:#999;--copy-path-img-filter:invert(50%);--copy-path-img-hover-filter:invert(35%);--codeblock-error-hover-color:rgb(255,0,0);--codeblock-error-color:rgba(255,0,0,.5);--codeblock-ignore-hover-color:rgb(255,142,0);--codeblock-ignore-color:rgba(255,142,0,.6);--warning-border-color:#ff8e00;--type-link-color:#ad378a;--trait-link-color:#6e4fc9;--assoc-item-link-color:#3873ad;--function-link-color:#ad7c37;--macro-link-color:#068000;--keyword-link-color:#3873ad;--mod-link-color:#3873ad;--link-color:#3873ad;--sidebar-link-color:#356da4;--sidebar-current-link-background-color:#fff;--search-result-link-focus-background-color:#ccc;--search-result-border-color:#aaa3;--search-color:#000;--search-error-code-background-color:#d0cccc;--search-results-alias-color:#000;--search-results-grey-color:#999;--search-tab-title-count-color:#888;--search-tab-button-not-selected-border-top-color:#e6e6e6;--search-tab-button-not-selected-background:#e6e6e6;--search-tab-button-selected-border-top-color:#0089ff;--search-tab-button-selected-background:#fff;--settings-menu-filter:none;--stab-background-color:#fff5d6;--stab-code-color:#000;--code-highlight-kw-color:#8959a8;--code-highlight-kw-2-color:#4271ae;--code-highlight-lifetime-color:#b76514;--code-highlight-prelude-color:#4271ae;--code-highlight-prelude-val-color:#c82829;--code-highlight-number-color:#718c00;--code-highlight-string-color:#718c00;--code-highlight-literal-color:#c82829;--code-highlight-attribute-color:#c82829;--code-highlight-self-color:#c82829;--code-highlight-macro-color:#3e999f;--code-highlight-question-mark-color:#ff9011;--code-highlight-comment-color:#8e908c;--code-highlight-doc-comment-color:#4d4d4c;--src-line-numbers-span-color:#c67e2d;--src-line-number-highlighted-background-color:#fdffd3;--test-arrow-color:#f5f5f5;--test-arrow-background-color:rgba(78,139,202,0.2);--test-arrow-hover-color:#f5f5f5;--test-arrow-hover-background-color:rgb(78,139,202);--target-background-color:#fdffd3;--target-border-color:#ad7c37;--kbd-color:#000;--kbd-background:#fafbfc;--kbd-box-shadow-color:#c6cbd1;--rust-logo-filter:initial;--crate-search-div-filter:invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg) brightness(114%) contrast(76%);--crate-search-div-hover-filter:invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg) brightness(96%) contrast(93%);--crate-search-hover-border:#717171;--src-sidebar-background-selected:#fff;--src-sidebar-background-hover:#e0e0e0;--table-alt-row-background-color:#f5f5f5;--codeblock-link-background:#eee;--scrape-example-toggle-line-background:#ccc;--scrape-example-toggle-line-hover-background:#999;--scrape-example-code-line-highlight:#fcffd6;--scrape-example-code-line-highlight-focus:#f6fdb0;--scrape-example-help-border-color:#555;--scrape-example-help-color:#333;--scrape-example-help-hover-border-color:#000;--scrape-example-help-hover-color:#000;--scrape-example-code-wrapper-background-start:rgba(255,255,255,1);--scrape-example-code-wrapper-background-end:rgba(255,255,255,0);--sidebar-resizer-hover:hsl(207,90%,66%);--sidebar-resizer-active:hsl(207,90%,54%);}@media (prefers-color-scheme:dark){:root,:root:not([data-theme]){--main-background-color:#353535;--main-color:#ddd;--settings-input-color:#2196f3;--settings-input-border-color:#999;--settings-button-color:#000;--settings-button-border-focus:#ffb900;--sidebar-background-color:#505050;--sidebar-background-color-hover:#676767;--code-block-background-color:#2A2A2A;--scrollbar-track-background-color:#717171;--scrollbar-thumb-background-color:rgba(32,34,37,.6);--scrollbar-color:rgba(32,34,37,.6) #5a5a5a;--headings-border-bottom-color:#d2d2d2;--border-color:#e0e0e0;--button-background-color:#f0f0f0;--right-side-color:grey;--code-attribute-color:#999;--toggles-color:#999;--toggle-filter:invert(100%);--mobile-sidebar-menu-filter:invert(100%);--search-input-focused-border-color:#008dfd;--copy-path-button-color:#999;--copy-path-img-filter:invert(50%);--copy-path-img-hover-filter:invert(65%);--codeblock-error-hover-color:rgb(255,0,0);--codeblock-error-color:rgba(255,0,0,.5);--codeblock-ignore-hover-color:rgb(255,142,0);--codeblock-ignore-color:rgba(255,142,0,.6);--warning-border-color:#ff8e00;--type-link-color:#2dbfb8;--trait-link-color:#b78cf2;--assoc-item-link-color:#d2991d;--function-link-color:#2bab63;--macro-link-color:#09bd00;--keyword-link-color:#d2991d;--mod-link-color:#d2991d;--link-color:#d2991d;--sidebar-link-color:#fdbf35;--sidebar-current-link-background-color:#444;--search-result-link-focus-background-color:#616161;--search-result-border-color:#aaa3;--search-color:#111;--search-error-code-background-color:#484848;--search-results-alias-color:#fff;--search-results-grey-color:#ccc;--search-tab-title-count-color:#888;--search-tab-button-not-selected-border-top-color:#252525;--search-tab-button-not-selected-background:#252525;--search-tab-button-selected-border-top-color:#0089ff;--search-tab-button-selected-background:#353535;--stab-background-color:#314559;--stab-code-color:#e6e1cf;--code-highlight-kw-color:#ab8ac1;--code-highlight-kw-2-color:#769acb;--code-highlight-lifetime-color:#d97f26;--code-highlight-prelude-color:#769acb;--code-highlight-prelude-val-color:#ee6868;--code-highlight-number-color:#83a300;--code-highlight-string-color:#83a300;--code-highlight-literal-color:#ee6868;--code-highlight-attribute-color:#ee6868;--code-highlight-self-color:#ee6868;--code-highlight-macro-color:#3e999f;--code-highlight-question-mark-color:#ff9011;--code-highlight-comment-color:#8d8d8b;--code-highlight-doc-comment-color:#8ca375;--src-line-numbers-span-color:#3b91e2;--src-line-number-highlighted-background-color:#0a042f;--test-arrow-color:#dedede;--test-arrow-background-color:rgba(78,139,202,0.2);--test-arrow-hover-color:#dedede;--test-arrow-hover-background-color:#4e8bca;--target-background-color:#494a3d;--target-border-color:#bb7410;--kbd-color:#000;--kbd-background:#fafbfc;--kbd-box-shadow-color:#c6cbd1;--rust-logo-filter:drop-shadow(1px 0 0px #fff) drop-shadow(0 1px 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 -1px 0 #fff);--crate-search-div-filter:invert(94%) sepia(0%) saturate(721%) hue-rotate(255deg) brightness(90%) contrast(90%);--crate-search-div-hover-filter:invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg) brightness(100%) contrast(91%);--crate-search-hover-border:#2196f3;--src-sidebar-background-selected:#333;--src-sidebar-background-hover:#444;--table-alt-row-background-color:#2a2a2a;--codeblock-link-background:#333;--scrape-example-toggle-line-background:#999;--scrape-example-toggle-line-hover-background:#c5c5c5;--scrape-example-code-line-highlight:#5b3b01;--scrape-example-code-line-highlight-focus:#7c4b0f;--scrape-example-help-border-color:#aaa;--scrape-example-help-color:#eee;--scrape-example-help-hover-border-color:#fff;--scrape-example-help-hover-color:#fff;--scrape-example-code-wrapper-background-start:rgba(53,53,53,1);--scrape-example-code-wrapper-background-end:rgba(53,53,53,0);--sidebar-resizer-hover:hsl(207,30%,54%);--sidebar-resizer-active:hsl(207,90%,54%);}} -------------------------------------------------------------------------------- /docs/api/src/rust_info/triple.rs.html: -------------------------------------------------------------------------------- 1 | triple.rs - source
1
  2 | 2
  3 | 3
  4 | 4
  5 | 5
  6 | 6
  7 | 7
  8 | 8
  9 | 9
 10 | 10
 11 | 11
 12 | 12
 13 | 13
 14 | 14
 15 | 15
 16 | 16
 17 | 17
 18 | 18
 19 | 19
 20 | 20
 21 | 21
 22 | 22
 23 | 23
 24 | 24
 25 | 25
 26 | 26
 27 | 27
 28 | 28
 29 | 29
 30 | 30
 31 | 31
 32 | 32
 33 | 33
 34 | 34
 35 | 35
 36 | 36
 37 | 37
 38 | 38
 39 | 39
 40 | 40
 41 | 41
 42 | 42
 43 | 43
 44 | 44
 45 | 45
 46 | 46
 47 | 47
 48 | 48
 49 | 49
 50 | 50
 51 | 51
 52 | 52
 53 | 53
 54 | 54
 55 | 55
 56 | 56
 57 | 57
 58 | 58
 59 | 59
 60 | 60
 61 | 61
 62 | 62
 63 | 63
 64 | 64
 65 | 65
 66 | 66
 67 | 67
 68 | 68
 69 | 69
 70 | 70
 71 | 71
 72 | 72
 73 | 73
 74 | 74
 75 | 
//! # triple
 76 | //!
 77 | //! Manages the rust triple values and logic.
 78 | //!
 79 | 
 80 | #[cfg(test)]
 81 | #[path = "./triple_test.rs"]
 82 | mod triple_test;
 83 | 
 84 | use crate::types::RustInfo;
 85 | 
 86 | pub(crate) fn load(rust_info: &mut RustInfo) {
 87 |     if let (Some(arch), Some(os)) = (&rust_info.target_arch, &rust_info.target_os) {
 88 |         let mut triple = String::new();
 89 |         let mapped_arch = map_arch(arch);
 90 |         triple.push_str(&mapped_arch);
 91 | 
 92 |         if let Some(vendor) = &rust_info.target_vendor {
 93 |             let mapped_vendor = map_vendor(vendor, os);
 94 | 
 95 |             triple.push_str("-");
 96 |             triple.push_str(&mapped_vendor);
 97 |         }
 98 | 
 99 |         let mapped_os = map_os(os, arch);
100 |         triple.push_str("-");
101 |         triple.push_str(&mapped_os);
102 | 
103 |         if let Some(env) = &rust_info.target_env {
104 |             if !env.is_empty() {
105 |                 let mapped_env = map_env(env, arch);
106 |                 triple.push_str("-");
107 |                 triple.push_str(&mapped_env);
108 |             }
109 |         }
110 | 
111 |         rust_info.target_triple = Some(triple);
112 |     }
113 | }
114 | 
115 | fn map_arch(arch: &str) -> String {
116 |     match arch {
117 |         "x86" => "i686".to_string(),
118 |         _ => arch.to_string(),
119 |     }
120 | }
121 | 
122 | fn map_vendor(vendor: &str, os: &str) -> String {
123 |     match os {
124 |         "android" => "linux".to_string(),
125 |         _ => vendor.to_string(),
126 |     }
127 | }
128 | 
129 | fn map_os(os: &str, arch: &str) -> String {
130 |     match os {
131 |         "macos" => "darwin".to_string(),
132 |         "android" => match arch {
133 |             "arm" => "androideabi".to_string(),
134 |             _ => os.to_string(),
135 |         },
136 |         _ => os.to_string(),
137 |     }
138 | }
139 | 
140 | fn map_env(env: &str, arch: &str) -> String {
141 |     match env {
142 |         "gnu" => match arch {
143 |             "arm" => "gnueabihf".to_string(),
144 |             _ => env.to_string(),
145 |         },
146 |         _ => env.to_string(),
147 |     }
148 | }
149 | 
-------------------------------------------------------------------------------- /src/triple_test.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | 3 | #[test] 4 | fn load_with_arch_first() { 5 | let mut rust_info = RustInfo::new(); 6 | 7 | rust_info.target_arch = Some(String::from("unknown")); 8 | load(&mut rust_info); 9 | assert!(rust_info.target_triple.is_none()); 10 | 11 | rust_info.target_vendor = Some(String::from("unknown")); 12 | load(&mut rust_info); 13 | assert!(rust_info.target_triple.is_none()); 14 | 15 | rust_info.target_env = Some(String::from("unknown")); 16 | load(&mut rust_info); 17 | assert!(rust_info.target_triple.is_none()); 18 | 19 | rust_info.target_os = Some(String::from("unknown")); 20 | load(&mut rust_info); 21 | assert_eq!( 22 | Some(String::from("unknown-unknown-unknown-unknown")), 23 | rust_info.target_triple 24 | ); 25 | } 26 | 27 | #[test] 28 | fn load_with_os_first() { 29 | let mut rust_info = RustInfo::new(); 30 | 31 | rust_info.target_os = Some(String::from("os")); 32 | rust_info.target_vendor = Some(String::from("vendor")); 33 | rust_info.target_env = Some(String::from("env")); 34 | load(&mut rust_info); 35 | assert!(rust_info.target_triple.is_none()); 36 | 37 | rust_info.target_arch = Some(String::from("arch")); 38 | load(&mut rust_info); 39 | assert_eq!( 40 | Some(String::from("arch-vendor-os-env")), 41 | rust_info.target_triple 42 | ); 43 | } 44 | 45 | #[test] 46 | fn load_with_minimum() { 47 | let mut rust_info = RustInfo::new(); 48 | 49 | rust_info.target_arch = Some(String::from("arch")); 50 | rust_info.target_os = Some(String::from("os")); 51 | load(&mut rust_info); 52 | assert_eq!(Some(String::from("arch-os")), rust_info.target_triple); 53 | } 54 | 55 | #[test] 56 | fn load_with_empty_env() { 57 | let mut rust_info = RustInfo::new(); 58 | 59 | rust_info.target_arch = Some(String::from("arch")); 60 | rust_info.target_os = Some(String::from("os")); 61 | rust_info.target_env = Some(String::from("")); 62 | load(&mut rust_info); 63 | assert_eq!(Some(String::from("arch-os")), rust_info.target_triple); 64 | } 65 | 66 | #[test] 67 | fn load_mac_32bit() { 68 | let mut rust_info = RustInfo::new(); 69 | 70 | rust_info.target_arch = Some(String::from("x86")); 71 | rust_info.target_os = Some(String::from("macos")); 72 | rust_info.target_vendor = Some(String::from("apple")); 73 | rust_info.target_env = Some(String::from("")); 74 | load(&mut rust_info); 75 | assert_eq!(rust_info.target_triple.unwrap(), "i686-apple-darwin"); 76 | } 77 | 78 | #[test] 79 | fn load_mac_64bit() { 80 | let mut rust_info = RustInfo::new(); 81 | 82 | rust_info.target_arch = Some(String::from("x86_64")); 83 | rust_info.target_os = Some(String::from("macos")); 84 | rust_info.target_vendor = Some(String::from("apple")); 85 | rust_info.target_env = Some(String::from("")); 86 | load(&mut rust_info); 87 | assert_eq!(rust_info.target_triple.unwrap(), "x86_64-apple-darwin"); 88 | } 89 | 90 | #[test] 91 | fn load_windows_32bit_gnu() { 92 | let mut rust_info = RustInfo::new(); 93 | 94 | rust_info.target_arch = Some(String::from("x86")); 95 | rust_info.target_os = Some(String::from("windows")); 96 | rust_info.target_vendor = Some(String::from("pc")); 97 | rust_info.target_env = Some(String::from("gnu")); 98 | load(&mut rust_info); 99 | assert_eq!(rust_info.target_triple.unwrap(), "i686-pc-windows-gnu"); 100 | } 101 | 102 | #[test] 103 | fn load_window_64bit_gnu() { 104 | let mut rust_info = RustInfo::new(); 105 | 106 | rust_info.target_arch = Some(String::from("x86_64")); 107 | rust_info.target_os = Some(String::from("windows")); 108 | rust_info.target_vendor = Some(String::from("pc")); 109 | rust_info.target_env = Some(String::from("gnu")); 110 | load(&mut rust_info); 111 | assert_eq!(rust_info.target_triple.unwrap(), "x86_64-pc-windows-gnu"); 112 | } 113 | 114 | #[test] 115 | fn load_windows_32bit_msvc() { 116 | let mut rust_info = RustInfo::new(); 117 | 118 | rust_info.target_arch = Some(String::from("x86")); 119 | rust_info.target_os = Some(String::from("windows")); 120 | rust_info.target_vendor = Some(String::from("pc")); 121 | rust_info.target_env = Some(String::from("msvc")); 122 | load(&mut rust_info); 123 | assert_eq!(rust_info.target_triple.unwrap(), "i686-pc-windows-msvc"); 124 | } 125 | 126 | #[test] 127 | fn load_window_64bit_msvc() { 128 | let mut rust_info = RustInfo::new(); 129 | 130 | rust_info.target_arch = Some(String::from("x86_64")); 131 | rust_info.target_os = Some(String::from("windows")); 132 | rust_info.target_vendor = Some(String::from("pc")); 133 | rust_info.target_env = Some(String::from("msvc")); 134 | load(&mut rust_info); 135 | assert_eq!(rust_info.target_triple.unwrap(), "x86_64-pc-windows-msvc"); 136 | } 137 | 138 | #[test] 139 | fn load_linux_32bit_gnu() { 140 | let mut rust_info = RustInfo::new(); 141 | 142 | rust_info.target_arch = Some(String::from("x86")); 143 | rust_info.target_os = Some(String::from("linux")); 144 | rust_info.target_vendor = Some(String::from("unknown")); 145 | rust_info.target_env = Some(String::from("gnu")); 146 | load(&mut rust_info); 147 | assert_eq!(rust_info.target_triple.unwrap(), "i686-unknown-linux-gnu"); 148 | } 149 | 150 | #[test] 151 | fn load_linux_64bit_gnu() { 152 | let mut rust_info = RustInfo::new(); 153 | 154 | rust_info.target_arch = Some(String::from("x86_64")); 155 | rust_info.target_os = Some(String::from("linux")); 156 | rust_info.target_vendor = Some(String::from("unknown")); 157 | rust_info.target_env = Some(String::from("gnu")); 158 | load(&mut rust_info); 159 | assert_eq!(rust_info.target_triple.unwrap(), "x86_64-unknown-linux-gnu"); 160 | } 161 | 162 | #[test] 163 | fn load_linux_64bit_musl() { 164 | let mut rust_info = RustInfo::new(); 165 | 166 | rust_info.target_arch = Some(String::from("x86_64")); 167 | rust_info.target_os = Some(String::from("linux")); 168 | rust_info.target_vendor = Some(String::from("unknown")); 169 | rust_info.target_env = Some(String::from("musl")); 170 | load(&mut rust_info); 171 | assert_eq!( 172 | rust_info.target_triple.unwrap(), 173 | "x86_64-unknown-linux-musl" 174 | ); 175 | } 176 | 177 | #[test] 178 | fn load_linux_arm_gnu() { 179 | let mut rust_info = RustInfo::new(); 180 | 181 | rust_info.target_arch = Some(String::from("arm")); 182 | rust_info.target_os = Some(String::from("linux")); 183 | rust_info.target_vendor = Some(String::from("unknown")); 184 | rust_info.target_env = Some(String::from("gnu")); 185 | load(&mut rust_info); 186 | assert_eq!( 187 | rust_info.target_triple.unwrap(), 188 | "arm-unknown-linux-gnueabihf" 189 | ); 190 | } 191 | 192 | #[test] 193 | fn load_android_32bit() { 194 | let mut rust_info = RustInfo::new(); 195 | 196 | rust_info.target_arch = Some(String::from("x86")); 197 | rust_info.target_os = Some(String::from("android")); 198 | rust_info.target_vendor = Some(String::from("unknown")); 199 | rust_info.target_env = Some(String::from("")); 200 | load(&mut rust_info); 201 | assert_eq!(rust_info.target_triple.unwrap(), "i686-linux-android"); 202 | } 203 | 204 | #[test] 205 | fn load_android_64bit() { 206 | let mut rust_info = RustInfo::new(); 207 | 208 | rust_info.target_arch = Some(String::from("x86_64")); 209 | rust_info.target_os = Some(String::from("android")); 210 | rust_info.target_vendor = Some(String::from("unknown")); 211 | rust_info.target_env = Some(String::from("")); 212 | load(&mut rust_info); 213 | assert_eq!(rust_info.target_triple.unwrap(), "x86_64-linux-android"); 214 | } 215 | 216 | #[test] 217 | fn load_android_arm() { 218 | let mut rust_info = RustInfo::new(); 219 | 220 | rust_info.target_arch = Some(String::from("arm")); 221 | rust_info.target_os = Some(String::from("android")); 222 | rust_info.target_vendor = Some(String::from("unknown")); 223 | rust_info.target_env = Some(String::from("")); 224 | load(&mut rust_info); 225 | assert_eq!(rust_info.target_triple.unwrap(), "arm-linux-androideabi"); 226 | } 227 | 228 | #[test] 229 | fn load_freebsd_64bit() { 230 | let mut rust_info = RustInfo::new(); 231 | 232 | rust_info.target_arch = Some(String::from("x86_64")); 233 | rust_info.target_os = Some(String::from("freebsd")); 234 | rust_info.target_vendor = Some(String::from("unknown")); 235 | rust_info.target_env = Some(String::from("")); 236 | load(&mut rust_info); 237 | assert_eq!(rust_info.target_triple.unwrap(), "x86_64-unknown-freebsd"); 238 | } 239 | 240 | #[test] 241 | fn load_netbsd_64bit() { 242 | let mut rust_info = RustInfo::new(); 243 | 244 | rust_info.target_arch = Some(String::from("x86_64")); 245 | rust_info.target_os = Some(String::from("netbsd")); 246 | rust_info.target_vendor = Some(String::from("unknown")); 247 | rust_info.target_env = Some(String::from("")); 248 | load(&mut rust_info); 249 | assert_eq!(rust_info.target_triple.unwrap(), "x86_64-unknown-netbsd"); 250 | } 251 | -------------------------------------------------------------------------------- /docs/api/static.files/LICENSE-APACHE-00000000be5b60d4.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /docs/api/src/rust_info/lib.rs.html: -------------------------------------------------------------------------------- 1 | lib.rs - source
1
  2 | 2
  3 | 3
  4 | 4
  5 | 5
  6 | 6
  7 | 7
  8 | 8
  9 | 9
 10 | 10
 11 | 11
 12 | 12
 13 | 13
 14 | 14
 15 | 15
 16 | 16
 17 | 17
 18 | 18
 19 | 19
 20 | 20
 21 | 21
 22 | 22
 23 | 23
 24 | 24
 25 | 25
 26 | 26
 27 | 27
 28 | 28
 29 | 29
 30 | 30
 31 | 31
 32 | 32
 33 | 33
 34 | 34
 35 | 35
 36 | 36
 37 | 37
 38 | 38
 39 | 39
 40 | 40
 41 | 41
 42 | 42
 43 | 43
 44 | 44
 45 | 45
 46 | 46
 47 | 47
 48 | 48
 49 | 49
 50 | 50
 51 | 51
 52 | 52
 53 | 53
 54 | 54
 55 | 55
 56 | 56
 57 | 57
 58 | 58
 59 | 59
 60 | 60
 61 | 61
 62 | 62
 63 | 63
 64 | 64
 65 | 65
 66 | 66
 67 | 67
 68 | 68
 69 | 69
 70 | 70
 71 | 71
 72 | 72
 73 | 73
 74 | 74
 75 | 75
 76 | 76
 77 | 77
 78 | 78
 79 | 79
 80 | 80
 81 | 81
 82 | 82
 83 | 83
 84 | 84
 85 | 85
 86 | 86
 87 | 87
 88 | 88
 89 | 89
 90 | 90
 91 | 91
 92 | 92
 93 | 93
 94 | 94
 95 | 95
 96 | 96
 97 | 97
 98 | 98
 99 | 99
100 | 100
101 | 101
102 | 102
103 | 103
104 | 104
105 | 105
106 | 106
107 | 107
108 | 108
109 | 109
110 | 110
111 | 111
112 | 112
113 | 113
114 | 114
115 | 115
116 | 116
117 | 117
118 | 118
119 | 119
120 | 120
121 | 121
122 | 122
123 | 123
124 | 124
125 | 125
126 | 126
127 | 127
128 | 128
129 | 129
130 | 130
131 | 131
132 | 132
133 | 133
134 | 134
135 | 135
136 | 136
137 | 137
138 | 
#![deny(
139 |     future_incompatible,
140 |     keyword_idents,
141 |     let_underscore,
142 |     nonstandard_style,
143 |     unused
144 | )]
145 | #![warn(unknown_lints)]
146 | 
147 | //! # rust_info
148 | //!
149 | //! Extracts and provides the current rust compiler information.
150 | //!
151 | //! This library main goal is to provide development/build tools such as
152 | //! [cargo-make](https://sagiegurari.github.io/cargo-make/)the needed information on the current rust installation and
153 | //! setup.
154 | //!
155 | //! # Examples
156 | //!
157 | //! ```
158 | //! fn main() {
159 | //!     let rust_info = rust_info::get();
160 | //!
161 | //!     println!("Version: {}", rust_info.version.unwrap());
162 | //!     println!("Channel: {:#?}", rust_info.channel.unwrap());
163 | //!     println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string()));
164 | //!     println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string()));
165 | //!     println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string()));
166 | //!     println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string()));
167 | //!     println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string()));
168 | //!     println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string()));
169 | //! }
170 | //! ```
171 | //!
172 | //! # Installation
173 | //! In order to use this library, just add it as a dependency:
174 | //!
175 | //! ```ini
176 | //! [dependencies]
177 | //! rust_info = "*"
178 | //! ```
179 | //!
180 | //! # Contributing
181 | //! See [contributing guide](https://github.com/sagiegurari/rust_info/blob/master/.github/CONTRIBUTING.md)
182 | //!
183 | //! # License
184 | //! Developed by Sagie Gur-Ari and licensed under the
185 | //! [Apache 2](https://github.com/sagiegurari/rust_info/blob/master/LICENSE) open source license.
186 | //!
187 | 
188 | #[cfg(test)]
189 | #[path = "./lib_test.rs"]
190 | mod lib_test;
191 | 
192 | #[cfg(doctest)]
193 | doc_comment::doctest!("../README.md");
194 | 
195 | mod rustinfo;
196 | mod triple;
197 | pub mod types;
198 | 
199 | use std::{borrow::Cow, path::Path};
200 | 
201 | use crate::types::RustInfo;
202 | 
203 | /// Options used for querying rust info
204 | #[derive(Debug, Clone)]
205 | pub struct Options<'path> {
206 |     /// Optionally override working directory used for querying `rustc`
207 |     pub path: Option<Cow<'path, Path>>,
208 | }
209 | 
210 | impl<'path> Default for Options<'path> {
211 |     fn default() -> Self {
212 |         Self { path: None }
213 |     }
214 | }
215 | 
216 | impl<'path> Options<'path> {
217 |     /// Helper for calling `default`
218 |     pub fn new() -> Self {
219 |         Self::default()
220 |     }
221 | 
222 |     /// Sets the `path` option
223 |     pub fn path(mut self, path: Option<Cow<'path, Path>>) -> Self {
224 |         self.path = path;
225 |         self
226 |     }
227 | }
228 | 
229 | /// Loads and returns the current rust compiler version and setup.<br>
230 | /// In case partial data is not available, those values will be set to Option::None.
231 | ///
232 | /// # Example
233 | ///
234 | /// ```
235 | /// fn main() {
236 | ///     let rust_info = rust_info::get();
237 | ///
238 | ///     println!("Version: {}", rust_info.version.unwrap());
239 | ///     println!("Channel: {:#?}", rust_info.channel.unwrap());
240 | ///     println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string()));
241 | ///     println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string()));
242 | ///     println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string()));
243 | ///     println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string()));
244 | ///     println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string()));
245 | ///     println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string()));
246 | /// }
247 | /// ```
248 | pub fn get() -> RustInfo {
249 |     get_with_options(&Options::default())
250 | }
251 | 
252 | /// Loads and returns the current rust compiler version and setup for a specified path.<br>
253 | /// In case partial data is not available, those values will be set to Option::None.
254 | ///
255 | /// # Example
256 | ///
257 | /// ```
258 | /// fn main() {
259 | ///     let opts = rust_info::Options::new().path(Some(std::path::Path::new("./").into()));
260 | ///     let rust_info = rust_info::get_with_options(&opts);
261 | ///
262 | ///     println!("Version: {}", rust_info.version.unwrap());
263 | ///     println!("Channel: {:#?}", rust_info.channel.unwrap());
264 | ///     println!("Target Arch: {}", rust_info.target_arch.unwrap_or("unknown".to_string()));
265 | ///     println!("Target Env: {}", rust_info.target_env.unwrap_or("unknown".to_string()));
266 | ///     println!("Target OS: {}", rust_info.target_os.unwrap_or("unknown".to_string()));
267 | ///     println!("Target Pointer Width: {}", rust_info.target_pointer_width.unwrap_or("unknown".to_string()));
268 | ///     println!("Target Vendor: {}", rust_info.target_vendor.unwrap_or("unknown".to_string()));
269 | ///     println!("Target Triple: {}", rust_info.target_triple.unwrap_or("unknown".to_string()));
270 | /// }
271 | /// ```
272 | pub fn get_with_options(options: &Options) -> RustInfo {
273 |     rustinfo::get(options)
274 | }
275 | 
-------------------------------------------------------------------------------- /docs/api/src/rust_info/rustinfo.rs.html: -------------------------------------------------------------------------------- 1 | rustinfo.rs - source
1
  2 | 2
  3 | 3
  4 | 4
  5 | 5
  6 | 6
  7 | 7
  8 | 8
  9 | 9
 10 | 10
 11 | 11
 12 | 12
 13 | 13
 14 | 14
 15 | 15
 16 | 16
 17 | 17
 18 | 18
 19 | 19
 20 | 20
 21 | 21
 22 | 22
 23 | 23
 24 | 24
 25 | 25
 26 | 26
 27 | 27
 28 | 28
 29 | 29
 30 | 30
 31 | 31
 32 | 32
 33 | 33
 34 | 34
 35 | 35
 36 | 36
 37 | 37
 38 | 38
 39 | 39
 40 | 40
 41 | 41
 42 | 42
 43 | 43
 44 | 44
 45 | 45
 46 | 46
 47 | 47
 48 | 48
 49 | 49
 50 | 50
 51 | 51
 52 | 52
 53 | 53
 54 | 54
 55 | 55
 56 | 56
 57 | 57
 58 | 58
 59 | 59
 60 | 60
 61 | 61
 62 | 62
 63 | 63
 64 | 64
 65 | 65
 66 | 66
 67 | 67
 68 | 68
 69 | 69
 70 | 70
 71 | 71
 72 | 72
 73 | 73
 74 | 74
 75 | 75
 76 | 76
 77 | 77
 78 | 78
 79 | 79
 80 | 80
 81 | 81
 82 | 82
 83 | 83
 84 | 84
 85 | 85
 86 | 86
 87 | 87
 88 | 88
 89 | 89
 90 | 90
 91 | 91
 92 | 92
 93 | 93
 94 | 94
 95 | 95
 96 | 96
 97 | 97
 98 | 98
 99 | 99
100 | 100
101 | 101
102 | 102
103 | 103
104 | 104
105 | 105
106 | 106
107 | 107
108 | 108
109 | 109
110 | 110
111 | 111
112 | 112
113 | 113
114 | 114
115 | 115
116 | 116
117 | 117
118 | 118
119 | 119
120 | 120
121 | 121
122 | 122
123 | 123
124 | 124
125 | 125
126 | 126
127 | 127
128 | 128
129 | 129
130 | 130
131 | 131
132 | 132
133 | 133
134 | 134
135 | 135
136 | 136
137 | 137
138 | 138
139 | 139
140 | 140
141 | 141
142 | 142
143 | 143
144 | 144
145 | 145
146 | 146
147 | 147
148 | 
//! # rustinfo
149 | //!
150 | //! Loads rust compiler information.
151 | //!
152 | 
153 | #[cfg(test)]
154 | #[path = "./rustinfo_test.rs"]
155 | mod rustinfo_test;
156 | 
157 | use crate::types::{RustChannel, RustInfo};
158 | use crate::{triple, Options};
159 | use std::collections::HashMap;
160 | use std::io::Error;
161 | use std::process::{Command, ExitStatus};
162 | 
163 | /// Returns the exit code (-1 if no exit code found)
164 | fn get_exit_code(exit_status: Result<ExitStatus, Error>) -> i32 {
165 |     match exit_status {
166 |         Ok(code) => {
167 |             if !code.success() {
168 |                 match code.code() {
169 |                     Some(value) => value,
170 |                     None => -1,
171 |                 }
172 |             } else {
173 |                 0
174 |             }
175 |         }
176 |         _ => -1,
177 |     }
178 | }
179 | 
180 | fn load_version(rust_info: &mut RustInfo, options: &Options) {
181 |     let mut command = Command::new("rustc");
182 | 
183 |     command.arg("--version");
184 | 
185 |     if let Some(directory) = &options.path {
186 |         command.current_dir(directory);
187 |     }
188 | 
189 |     let result = command.output();
190 | 
191 |     match result {
192 |         Ok(output) => {
193 |             let exit_code = get_exit_code(Ok(output.status));
194 | 
195 |             if exit_code == 0 {
196 |                 let stdout = String::from_utf8_lossy(&output.stdout);
197 |                 let parts: Vec<&str> = stdout.split(' ').collect();
198 | 
199 |                 if (parts.len() >= 3) && (parts[0] == "rustc") {
200 |                     let version_part = parts[1];
201 | 
202 |                     let version_parts: Vec<&str> = version_part.split('-').collect();
203 | 
204 |                     if version_parts.len() > 0 {
205 |                         rust_info.version = Some(version_parts[0].to_string());
206 | 
207 |                         if version_parts.len() == 1 {
208 |                             rust_info.channel = Some(RustChannel::Stable);
209 |                         } else if version_parts[1].contains("beta") {
210 |                             rust_info.channel = Some(RustChannel::Beta);
211 |                         } else if version_parts[1].contains("nightly") {
212 |                             rust_info.channel = Some(RustChannel::Nightly);
213 |                         }
214 |                     }
215 |                 }
216 |             }
217 |         }
218 |         _ => (),
219 |     };
220 | }
221 | 
222 | fn load_setup(rust_info: &mut RustInfo, options: &Options) {
223 |     let mut command = Command::new("rustc");
224 | 
225 |     command.arg("--print").arg("cfg");
226 | 
227 |     if let Some(directory) = &options.path {
228 |         command.current_dir(directory);
229 |     }
230 | 
231 |     let result = command.output();
232 | 
233 |     match result {
234 |         Ok(output) => {
235 |             let exit_code = get_exit_code(Ok(output.status));
236 | 
237 |             if exit_code == 0 {
238 |                 let mut values = HashMap::<String, String>::new();
239 | 
240 |                 let stdout = String::from_utf8_lossy(&output.stdout);
241 |                 let lines: Vec<&str> = stdout.split('\n').collect();
242 |                 for mut line in lines {
243 |                     line = line.trim();
244 | 
245 |                     if line.contains("=") {
246 |                         let parts: Vec<&str> = line.split('=').collect();
247 |                         let value = str::replace(parts[1], "\"", "");
248 |                         values.insert(parts[0].to_string(), value.to_string());
249 |                     }
250 |                 }
251 | 
252 |                 let mut value = values.remove("target_arch");
253 |                 if value.is_some() {
254 |                     rust_info.target_arch = Some(value.unwrap());
255 |                 }
256 | 
257 |                 value = values.remove("target_env");
258 |                 if value.is_some() {
259 |                     rust_info.target_env = Some(value.unwrap());
260 |                 }
261 | 
262 |                 value = values.remove("target_os");
263 |                 if value.is_some() {
264 |                     rust_info.target_os = Some(value.unwrap());
265 |                 }
266 | 
267 |                 value = values.remove("target_pointer_width");
268 |                 if value.is_some() {
269 |                     rust_info.target_pointer_width = Some(value.unwrap());
270 |                 }
271 | 
272 |                 value = values.remove("target_vendor");
273 |                 if value.is_some() {
274 |                     rust_info.target_vendor = Some(value.unwrap());
275 |                 }
276 |             }
277 |         }
278 |         _ => (),
279 |     };
280 | }
281 | 
282 | /// Loads and returns the current rust compiler version and setup.<br>
283 | /// In case partial data is not available, those values will be set to Option::None.
284 | pub(crate) fn get(options: &Options) -> RustInfo {
285 |     let mut rust_info = RustInfo::new();
286 | 
287 |     load_version(&mut rust_info, options);
288 | 
289 |     load_setup(&mut rust_info, options);
290 | 
291 |     triple::load(&mut rust_info);
292 | 
293 |     rust_info
294 | }
295 | 
--------------------------------------------------------------------------------