├── .gitignore ├── .github ├── dependabot.yml ├── workflows │ └── ci.yml └── actions │ └── setup │ └── action.yml ├── src ├── attrs.rs ├── lib.rs └── svg.rs ├── Cargo.toml ├── LICENSE-MIT ├── README.md ├── LICENSE-APACHE └── Cargo.lock /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "04:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /src/attrs.rs: -------------------------------------------------------------------------------- 1 | use syn::{Expr, ExprLit, Lit}; 2 | 3 | pub fn get_lit_str<'a>(attr_name: &'static str, value: &'a Expr) -> syn::Result<&'a syn::LitStr> { 4 | if let Expr::Lit(ExprLit { 5 | lit: Lit::Str(lit), .. 6 | }) = &value 7 | { 8 | Ok(lit) 9 | } else { 10 | Err(syn::Error::new_spanned( 11 | value, 12 | format!("expected {attr_name} attribute to be a string: `{attr_name} = \"...\"`"), 13 | )) 14 | } 15 | } 16 | 17 | pub fn get_lit_bool(attr_name: &'static str, value: &Expr) -> syn::Result { 18 | if let Expr::Lit(ExprLit { 19 | lit: Lit::Bool(lit), 20 | .. 21 | }) = &value 22 | { 23 | Ok(lit.value()) 24 | } else { 25 | Err(syn::Error::new_spanned( 26 | value, 27 | format!("expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`"), 28 | ))? 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "iconify" 3 | version = "0.3.1" 4 | edition = "2021" 5 | authors = ["Matthew Taylor "] 6 | categories = ["development-tools::code-generators"] 7 | description = "Proc-macros for generating icons from the Iconify API" 8 | license = "MIT OR Apache-2.0" 9 | repository = "https://github.com/wrapperup/iconify-rs" 10 | readme = "README.md" 11 | keywords = ["iconify", "icons", "proc-macro"] 12 | 13 | [features] 14 | default = ["cache", "tls"] 15 | tls = ["ureq/tls"] 16 | cache = ["directories", "blake3"] 17 | offline = ["blake3"] 18 | 19 | [lib] 20 | proc-macro = true 21 | doctest = false # requires network access, can't really use doctests 22 | 23 | [dependencies] 24 | proc-macro2 = "1.0.86" 25 | quote = "1.0.36" 26 | syn = "2.0.71" 27 | ureq = { version = "2.10.0", default-features = false } 28 | directories = { version = "5.0.1", optional = true } 29 | url = "2.5.2" 30 | blake3 = { version = "1.5.3", optional = true } 31 | hex = "0.4.3" 32 | 33 | [dev-dependencies] 34 | iconify = { path = ".", default-features = false } 35 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: ['main'] 6 | pull_request: 7 | schedule: 8 | - cron: "32 4 * * 5" 9 | 10 | jobs: 11 | test: 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest, macos-latest, windows-latest] 15 | rust: [stable, beta] 16 | exclude: 17 | - os: macos-latest 18 | rust: beta 19 | - os: windows-latest 20 | rust: beta 21 | runs-on: ${{ matrix.os }} 22 | steps: 23 | - uses: actions/checkout@v1 24 | - uses: ./.github/actions/setup 25 | with: 26 | toolchain: ${{ matrix.rust }} 27 | key: test-${{ matrix.os }}-${{ matrix.rust }} 28 | - run: cargo build 29 | - run: cargo test 30 | 31 | lint: 32 | runs-on: ubuntu-latest 33 | steps: 34 | - uses: actions/checkout@v1 35 | - uses: ./.github/actions/setup 36 | with: 37 | key: lint 38 | components: rustfmt, clippy 39 | - run: cargo fmt --all -- --check 40 | - run: cargo clippy --all-targets -- -D warnings 41 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 Matthew Taylor 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /.github/actions/setup/action.yml: -------------------------------------------------------------------------------- 1 | name: Setup Rust Environment 2 | 3 | inputs: 4 | key: 5 | description: Cache key 6 | required: true 7 | toolchain: 8 | description: Pass-through to toolchain on actions-rs 9 | default: stable 10 | required: false 11 | components: 12 | description: Pass-through to components on actions-rs 13 | required: false 14 | 15 | runs: 16 | using: composite 17 | steps: 18 | - uses: actions-rs/toolchain@v1 19 | id: toolchain-install 20 | with: 21 | profile: minimal 22 | override: true 23 | toolchain: ${{ inputs.toolchain }} 24 | components: ${{ inputs.components }} 25 | - uses: actions/cache@v3 26 | with: 27 | path: | 28 | ~/.cargo/registry/index/ 29 | ~/.cargo/registry/cache/ 30 | ~/.cargo/git/db/ 31 | target/ 32 | key: ${{ inputs.key }}-${{ runner.os }}-${{ inputs.toolchain }}-${{ steps.toolchain-install.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} 33 | restore-keys: | 34 | ${{ inputs.key }}-${{ runner.os }}-${{ inputs.toolchain }}-${{ steps.toolchain-install.outputs.rustc_hash }}- 35 | ${{ inputs.key }}-${{ runner.os }}-${{ inputs.toolchain }}- 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | iconify-rs 3 |

4 | 5 |

6 | This crate provides a macro to embed SVGs from 7 | Iconify. 8 | For a list of icons, see 9 | Iconify Icon Sets. 10 |

11 | 12 |
13 | 14 | Crates.io 15 | 16 | 17 | Crates.io 18 | 19 | 20 | docs.rs 21 | 22 |
23 | 24 | 25 | ## 📝 Usage 26 | 27 | ```jsx 28 | let svg = iconify::svg!("mdi:home", color = "red") 29 | ``` 30 | `iconify::svg!` will download and embed an SVG as a string. It will also cache the request, 31 | so it won't download the same SVG twice. 32 | ```rust 33 | let svg = "..." 34 | ``` 35 | 36 | ### Options 37 | 38 | You can pass options to the macro to customize the SVG. 39 | ```rust 40 | let svg = iconify::svg!("mdi:home", 41 | width = "24", 42 | height = "24", 43 | color = "red", 44 | // ... and more. 45 | ) 46 | ``` 47 | 48 | All options from the [Iconify API](https://iconify.design/docs/api/svg.html) are supported. You can 49 | find the documentation for the options for the `svg!` macro [here](https://docs.rs/iconify/latest/iconify/macro.svg.html). 50 | 51 | ### Templating 52 | It can also be used directly in rsx, or any compile-time template engine. 53 | 54 | Maud: 55 | ```rust 56 | html! { 57 | body { 58 | .card { 59 | (PreEscaped(iconify::svg!("mdi:home"))) 60 | p { "Hello!" } 61 | } 62 | } 63 | } 64 | ``` 65 | 66 | Askama 67 | 68 | ```jsx 69 | 70 |
71 | {{ iconify::svg!("mdi:home")|safe }} 72 |

Hello!

73 | 74 | ``` 75 | 76 | ## ✨ Features 77 | 78 | * Directly embed SVGs from Iconify 79 | * Caches requests (default feature) 80 | * Offline mode 81 | * SVG transforms (through API) 82 | * (Soon) CSS fetching 83 | 84 | ## 🔌 Offline Mode 85 | 86 | If you don't want iconify-rs to make requests at compile-time in CI (or other reasons), you can use offline mode with prepared icons. 87 | 88 | 1. Enable the `offline` feature. 89 | 2. Prepare icons by setting `ICONIFY_PREPARE=true` and running `cargo check`. This will generate a directory for you in `CARGO_MANIFEST_DIR` called `icons` with all the icons you invoked. 90 | 3. Now you're ready to go! Just run `cargo build` and it will use the icons you prepared. 91 | 92 | If you want to set a custom directory, you can also set `ICONIFY_OFFLINE_DIR`. 93 | 94 | ## ⚙️ Configuration 95 | - `ICONIFY_URL` - Sets the API url to use. If not set, the default is "https://api.iconify.design" 96 | - `ICONIFY_PREPARE` - If set, icons will be written to the offline icons directory (offline mode only) 97 | - `ICONIFY_OFFLINE_DIR` - Sets the offline icons directory. If not set, the default is "/icons" in your project directory 98 | 99 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //!

2 | //! This crate provides a macro to embed SVGs from 3 | //! Iconify. 4 | //! For a list of icons, see 5 | //! Iconify Icon Sets. 6 | //!

7 | //! 8 | //!
9 | //! 10 | //! Crates.io 11 | //! 12 | //! 13 | //! Crates.io 14 | //! 15 | //! 16 | //! docs.rs 17 | //! 18 | //!
19 | //! 20 | //! 21 | //! ## 📝 Usage 22 | //! 23 | //! ``` 24 | //! let svg = iconify::svg!("mdi:home") 25 | //! ``` 26 | //! `iconify::svg!` will download and embed an SVG as a string. It will also cache the request, 27 | //! so it won't download the same SVG twice. 28 | //! ``` 29 | //! let svg = "..." 30 | //! ``` 31 | //! 32 | //! #### Options 33 | //! 34 | //! You can pass options to the macro to customize the SVG. 35 | //! ``` 36 | //! let svg = iconify::svg!("mdi:home", 37 | //! width = "24", 38 | //! height = "24", 39 | //! color = "red", 40 | //! // ... and more. 41 | //! ) 42 | //! ``` 43 | //! 44 | //! All options from the [Iconify API](https://iconify.design/docs/api/svg.html) are supported. You can 45 | //! find the documentation for the options for the [svg!] macro [here](svg!). 46 | //! 47 | //! #### Templating 48 | //! It can also be used directly in rsx, or any compile-time template engine. 49 | //! 50 | //! Maud: 51 | //! ``` 52 | //! html! { 53 | //! body { 54 | //! .card { 55 | //! (PreEscaped(iconify::svg!("mdi:home"))) 56 | //! p { "Hello!" } 57 | //! } 58 | //! } 59 | //! } 60 | //! ``` 61 | //! 62 | //! Askama (Currently, a bug prevents you from using the full macro path. See [Issue #836](https://github.com/djc/askama/issues/836)) 63 | //! 64 | //! ``` 65 | //! 66 | //!
67 | //! {{ svg!("mdi:home")|safe }} 68 | //!

Hello!

69 | //! 70 | //! ``` 71 | //! 72 | //! ## ✨ Features 73 | //! 74 | //! * Directly embed SVGs from Iconify 75 | //! * Caches requests (default feature) 76 | //! * Offline mode 77 | //! * SVG transforms (through API) 78 | //! * (Soon) CSS fetching 79 | //! 80 | //! ## 🔌 Offline Mode 81 | //! 82 | //! If you don't want iconify-rs to make requests at compile-time in CI (or other reasons), you can use offline mode with prepared icons. 83 | //! 84 | //! 1. Enable the `offline` feature. 85 | //! 2. Prepare icons by setting `ICONIFY_PREPARE=true` and running `cargo check`. This will generate a directory for you in `CARGO_MANIFEST_DIR` called `icons` with all the icons you invoked. 86 | //! 3. Now you're ready to go! Just run `cargo build` and it will use the icons you prepared. 87 | //! 88 | //! If you want to set a custom directory, you can also set `ICONIFY_OFFLINE_DIR`. 89 | 90 | use proc_macro::TokenStream; 91 | 92 | mod attrs; 93 | mod svg; 94 | 95 | /// Embeds an SVG from Iconify. 96 | /// For a list of icons, see [Iconify Icon Sets](https://icon-sets.iconify.design/). 97 | /// 98 | /// # Usage 99 | /// The first argument is the icon's package and name, separated by a colon. 100 | /// 101 | /// ``` 102 | /// let svg = iconify::svg!("mdi:home"); 103 | /// println!("{}", svg); 104 | /// ``` 105 | /// 106 | /// Additional optional arguments can also be 107 | /// passed to the macro to customize the SVG. 108 | /// * `color = ` 109 | /// * Sets the color of the SVG. This can be any valid CSS color. 110 | /// * `width = ` 111 | /// * Sets the width of the SVG. This can be any valid CSS width. 112 | /// * If this is not set, the SVG will be rendered at 1em. 113 | /// * `height = ` 114 | /// * Sets the height of the SVG. This can be any valid CSS height. 115 | /// * If this is not set, the SVG will be rendered at 1em. 116 | /// * `flip = ` 117 | /// * Flips the SVG horizontally, vertically, or both. 118 | /// * Available values: "horizontal", "vertical", "both" 119 | /// * `rotate = ` 120 | /// * Rotates the SVG by the given amount. 121 | /// * Available values: "90", "180", "270" 122 | /// * `view_box = ` 123 | /// * If set to true, the SVG will include an invisible bounding box. 124 | /// 125 | /// ``` 126 | /// iconify::svg!( 127 | /// "pack:name", 128 | /// color = "red", 129 | /// width = "128px", 130 | /// height = "128px", 131 | /// flip = "horizontal", 132 | /// rotate = "90", 133 | /// view_box = true 134 | /// ) 135 | /// ``` 136 | #[proc_macro] 137 | pub fn svg(input: TokenStream) -> TokenStream { 138 | match svg::iconify_svg_impl(input.into()) { 139 | Ok(output) => output.into(), 140 | Err(err) => err.to_compile_error().into(), 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 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 2023 Matthew Taylor 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 | -------------------------------------------------------------------------------- /src/svg.rs: -------------------------------------------------------------------------------- 1 | use core::fmt; 2 | use std::{env, str::FromStr}; 3 | 4 | use proc_macro2::{Span, TokenStream}; 5 | use quote::quote; 6 | use syn::parse::{Parse, ParseStream}; 7 | 8 | use crate::attrs::{get_lit_bool, get_lit_str}; 9 | 10 | trait AppendQueryPair { 11 | fn append_query_pair(&mut self, key: &str, value: &Option); 12 | } 13 | 14 | impl AppendQueryPair for url::form_urlencoded::Serializer<'_, url::UrlQuery<'_>> { 15 | fn append_query_pair(&mut self, key: &str, value: &Option) { 16 | if let Some(value) = value { 17 | self.append_pair(key, &value.to_string()); 18 | } 19 | } 20 | } 21 | 22 | enum IconifyRotation { 23 | Rotate90, 24 | Rotate180, 25 | Rotate270, 26 | } 27 | 28 | impl fmt::Display for IconifyRotation { 29 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 30 | match self { 31 | IconifyRotation::Rotate90 => write!(f, "90deg"), 32 | IconifyRotation::Rotate180 => write!(f, "180deg"), 33 | IconifyRotation::Rotate270 => write!(f, "270deg"), 34 | } 35 | } 36 | } 37 | 38 | impl FromStr for IconifyRotation { 39 | type Err = (); 40 | 41 | fn from_str(s: &str) -> Result { 42 | match s { 43 | "90" => Ok(IconifyRotation::Rotate90), 44 | "180" => Ok(IconifyRotation::Rotate180), 45 | "270" => Ok(IconifyRotation::Rotate270), 46 | _ => Err(()), 47 | } 48 | } 49 | } 50 | 51 | enum IconifyFlip { 52 | Horizontal, 53 | Vertical, 54 | Both, 55 | } 56 | 57 | impl fmt::Display for IconifyFlip { 58 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 59 | match self { 60 | IconifyFlip::Horizontal => write!(f, "horizontal"), 61 | IconifyFlip::Vertical => write!(f, "vertical"), 62 | IconifyFlip::Both => write!(f, "horizontal,vertical"), 63 | } 64 | } 65 | } 66 | 67 | impl FromStr for IconifyFlip { 68 | type Err = (); 69 | 70 | fn from_str(s: &str) -> Result { 71 | match s { 72 | "horizontal" => Ok(IconifyFlip::Horizontal), 73 | "vertical" => Ok(IconifyFlip::Vertical), 74 | "both" | "horizontal,vertical" | "vertical,horizontal" => Ok(IconifyFlip::Both), 75 | _ => Err(()), 76 | } 77 | } 78 | } 79 | 80 | struct IconifyInput { 81 | pack: String, 82 | name: String, 83 | color: Option, 84 | width: Option, 85 | height: Option, 86 | flip: Option, 87 | rotate: Option, 88 | view_box: bool, 89 | } 90 | 91 | impl IconifyInput { 92 | fn icon_url(&self) -> Result { 93 | let mut url = url::Url::parse(&iconify_url())?; 94 | 95 | // Set the pack and icon name in the url path. 96 | { 97 | let mut path_segments = url 98 | .path_segments_mut() 99 | .map_err(|_| url::ParseError::RelativeUrlWithoutBase)?; 100 | 101 | path_segments.push(&self.pack); 102 | path_segments.push(&format!("{}.svg", &self.name)); 103 | } 104 | 105 | // Set the query parameters. 106 | { 107 | let mut query_pairs = url.query_pairs_mut(); 108 | 109 | query_pairs.append_query_pair("color", &self.color); 110 | query_pairs.append_query_pair("width", &self.width); 111 | query_pairs.append_query_pair("height", &self.height); 112 | query_pairs.append_query_pair("flip", &self.flip.as_ref().map(IconifyFlip::to_string)); 113 | query_pairs.append_query_pair( 114 | "rotate", 115 | &self.rotate.as_ref().map(IconifyRotation::to_string), 116 | ); 117 | query_pairs.append_query_pair( 118 | "box", 119 | &self.view_box.then(|| Some("true".to_string())).flatten(), 120 | ); 121 | } 122 | 123 | Ok(url.to_string()) 124 | } 125 | 126 | #[cfg(all(not(test), feature = "cache"))] 127 | fn hash_digest(&self) -> Result { 128 | use hex::ToHex; 129 | 130 | let mut buf = [0u8; 8]; 131 | let url = self.icon_url().map_err(|err| { 132 | syn::Error::new(Span::call_site(), format!("failed to parse url: {err}")) 133 | })?; 134 | 135 | blake3::Hasher::new() 136 | .update(url.as_bytes()) 137 | .finalize_xof() 138 | .fill(&mut buf); 139 | 140 | Ok(buf.encode_hex::()) 141 | } 142 | } 143 | 144 | impl Parse for IconifyInput { 145 | fn parse(input: ParseStream) -> syn::Result { 146 | let pack_name_lit = input.parse::()?; 147 | let pack_name_string = pack_name_lit.value(); 148 | 149 | let mut pack_name = pack_name_string.split(':'); 150 | 151 | let error = || syn::Error::new(pack_name_lit.span(), "expected `pack_name:icon_name`"); 152 | let pack = pack_name.next().ok_or_else(error)?.to_string(); 153 | let name = pack_name.next().ok_or_else(error)?.to_string(); 154 | 155 | if pack_name.next().is_some() { 156 | return Err(error()); 157 | } 158 | 159 | let mut color = None; 160 | let mut width = None; 161 | let mut height = None; 162 | let mut flip = None; 163 | let mut rotate = None; 164 | let mut view_box = false; 165 | 166 | if input.peek(syn::Token![,]) { 167 | input.parse::()?; 168 | let metas = input.parse_terminated(syn::Meta::parse, syn::Token![,])?; 169 | 170 | for meta in metas { 171 | use syn::Meta::NameValue; 172 | match meta { 173 | // Parse syn!("...", color = ...)]. 174 | NameValue(m) if m.path.is_ident("color") => { 175 | let value = get_lit_str("color", &m.value)?; 176 | color = Some(value.value()); 177 | } 178 | // Parse syn!("...", width = ...)]. 179 | NameValue(m) if m.path.is_ident("width") => { 180 | let value = get_lit_str("width", &m.value)?; 181 | width = Some(value.value()); 182 | } 183 | // Parse syn!("...", height = ...)]. 184 | NameValue(m) if m.path.is_ident("height") => { 185 | let value = get_lit_str("height", &m.value)?; 186 | height = Some(value.value()); 187 | } 188 | // Parse syn!("...", flip = ...)]. 189 | NameValue(m) if m.path.is_ident("flip") => { 190 | let value = get_lit_str("flip", &m.value)?; 191 | let flip_val = IconifyFlip::from_str(&value.value()) 192 | .map_err(|_| syn::Error::new(value.span(), "Invalid flip value"))?; 193 | flip = Some(flip_val); 194 | } 195 | // Parse syn!("...", rotate = ...)]. 196 | NameValue(m) if m.path.is_ident("rotate") => { 197 | let value = get_lit_str("rotate", &m.value)?; 198 | let rotate_val = IconifyRotation::from_str(&value.value()).map_err(|_| { 199 | syn::Error::new_spanned( 200 | value, 201 | "Invalid rotate value. Rotate can be one of \"90\", \"180\", or \"270\".", 202 | ) 203 | })?; 204 | rotate = Some(rotate_val); 205 | } 206 | // Parse syn!("...", view_box = ...)]. 207 | NameValue(m) if m.path.is_ident("view_box") => { 208 | view_box = get_lit_bool("view_box", &m.value)?; 209 | } 210 | _ => { 211 | return Err(syn::Error::new_spanned( 212 | meta, 213 | "Not a name value pair: `foo = \"...\"`", 214 | )); 215 | } 216 | } 217 | } 218 | } 219 | 220 | Ok(Self { 221 | pack, 222 | name, 223 | color, 224 | width, 225 | height, 226 | flip, 227 | rotate, 228 | view_box, 229 | }) 230 | } 231 | } 232 | 233 | fn iconify_url() -> String { 234 | env::var("ICONIFY_URL").unwrap_or("https://api.iconify.design".to_string()) 235 | } 236 | 237 | #[cfg(all(not(test), feature = "cache"))] 238 | fn iconify_cache_dir() -> std::path::PathBuf { 239 | use directories::BaseDirs; 240 | use std::path::PathBuf; 241 | 242 | if let Ok(dir) = env::var("ICONIFY_CACHE_DIR") { 243 | return PathBuf::from(dir); 244 | } 245 | 246 | let dir = if cfg!(target_family = "unix") { 247 | // originally we used cache_dir for all non-Windows platforms but that returns 248 | // a path that's not writable in cross-rs Docker. /tmp should always work 249 | PathBuf::from("/tmp") 250 | } else if cfg!(target_os = "windows") { 251 | // I didn't like the idea of having a cache dir in the root of %LOCALAPPDATA%. 252 | PathBuf::from(BaseDirs::new().unwrap().cache_dir()).join("cache") 253 | } else { 254 | PathBuf::from(BaseDirs::new().unwrap().cache_dir()) 255 | }; 256 | 257 | dir.join("iconify-rs") 258 | } 259 | 260 | #[cfg(all(not(test), feature = "cache"))] 261 | fn iconify_cache_path(input: &IconifyInput) -> Result { 262 | let digest = input.hash_digest()?; 263 | 264 | let mut path = iconify_cache_dir(); 265 | path.push(&input.pack); 266 | path.push(format!("{}-{}", input.name, digest)); 267 | path.set_extension("svg"); 268 | Ok(path) 269 | } 270 | 271 | #[cfg(feature = "offline")] 272 | fn offline_dir() -> std::path::PathBuf { 273 | use std::path::PathBuf; 274 | 275 | if let Ok(dir) = env::var("ICONIFY_OFFLINE_DIR") { 276 | return PathBuf::from(dir); 277 | } 278 | 279 | let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); 280 | path.push("icons"); 281 | path 282 | } 283 | 284 | #[cfg(feature = "offline")] 285 | fn offline_icon_path(input: &IconifyInput) -> Result { 286 | let digest = input.hash_digest()?; 287 | 288 | let mut path = offline_dir(); 289 | path.push(&input.pack); 290 | path.push(format!("{}-{}", input.name, digest)); 291 | path.set_extension("svg"); 292 | Ok(path) 293 | } 294 | 295 | #[cfg(feature = "offline")] 296 | fn offline_svg(input: &IconifyInput) -> Result { 297 | let path = offline_icon_path(input)?; 298 | 299 | std::fs::read_to_string(&path).map_err(|err| { 300 | syn::Error::new( 301 | Span::call_site(), 302 | format!("failed to read offline icon. {err}.\nusually this means you need to prepare icons first with ICONIFY_PREPARE."), 303 | ) 304 | }) 305 | } 306 | 307 | #[cfg(feature = "offline")] 308 | fn prepare_offline_icons() -> bool { 309 | env::var("ICONIFY_PREPARE").ok().as_deref() == Some("true") 310 | } 311 | 312 | fn fetch_svg(iconify_input: &IconifyInput) -> Result { 313 | #[cfg(all(not(test), feature = "cache"))] 314 | let path = { 315 | let path = iconify_cache_path(iconify_input)?; 316 | 317 | if let Ok(text) = std::fs::read_to_string(&path) { 318 | return Ok(text); 319 | } 320 | 321 | path 322 | }; 323 | 324 | let url = iconify_input 325 | .icon_url() 326 | .map_err(|err| syn::Error::new(Span::call_site(), format!("couldn't parse url: {err}")))?; 327 | 328 | let response = ureq::get(&url).call().map_err(|err| { 329 | syn::Error::new(Span::call_site(), format!("failed to fetch icon: {err}")) 330 | })?; 331 | 332 | let text = response.into_string().map_err(|err| { 333 | syn::Error::new(Span::call_site(), format!("failed to fetch icon: {err}")) 334 | })?; 335 | 336 | // Iconify API does not set the status code to 404 when an icon is not found... amazing. 337 | if text == "404" { 338 | return Err(syn::Error::new( 339 | Span::call_site(), 340 | format!("icon not found: {}", url), 341 | )); 342 | } 343 | 344 | #[cfg(all(not(test), feature = "cache"))] 345 | { 346 | std::fs::create_dir_all(path.parent().unwrap()).unwrap(); 347 | std::fs::write(&path, &text).unwrap(); 348 | } 349 | 350 | Ok(text) 351 | } 352 | 353 | pub fn iconify_svg_impl(input: TokenStream) -> syn::Result { 354 | let iconify_input = syn::parse2::(input)?; 355 | 356 | // If we're using offline icons, we need to fetch them from the 357 | // iconify API during development. This is done by setting the 358 | // ICONIFY_PREPARE environment variable. 359 | #[cfg(feature = "offline")] 360 | let svg = if prepare_offline_icons() { 361 | fetch_svg(&iconify_input) 362 | } else { 363 | offline_svg(&iconify_input) 364 | }?; 365 | 366 | #[cfg(not(feature = "offline"))] 367 | let svg = fetch_svg(&iconify_input)?; 368 | 369 | #[cfg(feature = "offline")] 370 | if prepare_offline_icons() { 371 | // Prepare offline icons 372 | let path = offline_icon_path(&iconify_input)?; 373 | 374 | std::fs::create_dir_all(path.parent().unwrap()).unwrap(); 375 | std::fs::write(&path, &svg).unwrap(); 376 | } 377 | 378 | Ok(quote! { 379 | #svg 380 | }) 381 | } 382 | 383 | #[cfg(test)] 384 | mod tests { 385 | use super::iconify_svg_impl; 386 | use quote::quote; 387 | use std::result::Result; 388 | 389 | #[test] 390 | fn test_basic() -> Result<(), String> { 391 | let svg = iconify_svg_impl(quote! { 392 | "mdi:home" 393 | }) 394 | .unwrap() 395 | .to_string(); 396 | 397 | assert_eq!( 398 | svg, 399 | "\"\"" 400 | ); 401 | 402 | Ok(()) 403 | } 404 | 405 | #[test] 406 | fn test_basic_attributes() -> Result<(), String> { 407 | let svg = iconify_svg_impl(quote! { 408 | "mdi:home", 409 | color = "red", 410 | width = "2em", 411 | height = "3em", 412 | flip = "both", 413 | rotate = "90", 414 | view_box = true 415 | }) 416 | .unwrap() 417 | .to_string(); 418 | 419 | assert_eq!( 420 | svg, 421 | "\"\"" 422 | ); 423 | 424 | Ok(()) 425 | } 426 | 427 | #[test] 428 | fn test_pack_parse_fail() -> Result<(), String> { 429 | let no_colon = iconify_svg_impl(quote! { 430 | "mdi-home" 431 | }) 432 | .unwrap_err() 433 | .to_string(); 434 | 435 | let too_many_colons = iconify_svg_impl(quote! { 436 | "mdi:home:foo" 437 | }) 438 | .unwrap_err() 439 | .to_string(); 440 | 441 | assert_eq!(no_colon, "expected `pack_name:icon_name`"); 442 | assert_eq!(too_many_colons, "expected `pack_name:icon_name`"); 443 | 444 | Ok(()) 445 | } 446 | 447 | #[test] 448 | fn test_pack_not_found_fail() -> Result<(), String> { 449 | let pack_not_found = iconify_svg_impl(quote! { 450 | "this-is-not:an-icon-i-hope" 451 | }) 452 | .unwrap_err() 453 | .to_string(); 454 | 455 | assert_eq!( 456 | pack_not_found, 457 | "icon not found: https://api.iconify.design/this-is-not/an-icon-i-hope.svg?" 458 | ); 459 | 460 | Ok(()) 461 | } 462 | } 463 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "arrayref" 7 | version = "0.3.7" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" 10 | 11 | [[package]] 12 | name = "arrayvec" 13 | version = "0.7.4" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" 16 | 17 | [[package]] 18 | name = "base64" 19 | version = "0.22.0" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" 22 | 23 | [[package]] 24 | name = "bitflags" 25 | version = "2.5.0" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" 28 | 29 | [[package]] 30 | name = "blake3" 31 | version = "1.5.3" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" 34 | dependencies = [ 35 | "arrayref", 36 | "arrayvec", 37 | "cc", 38 | "cfg-if", 39 | "constant_time_eq", 40 | ] 41 | 42 | [[package]] 43 | name = "cc" 44 | version = "1.0.95" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" 47 | 48 | [[package]] 49 | name = "cfg-if" 50 | version = "1.0.0" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 53 | 54 | [[package]] 55 | name = "constant_time_eq" 56 | version = "0.3.0" 57 | source = "registry+https://github.com/rust-lang/crates.io-index" 58 | checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" 59 | 60 | [[package]] 61 | name = "directories" 62 | version = "5.0.1" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" 65 | dependencies = [ 66 | "dirs-sys", 67 | ] 68 | 69 | [[package]] 70 | name = "dirs-sys" 71 | version = "0.4.1" 72 | source = "registry+https://github.com/rust-lang/crates.io-index" 73 | checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" 74 | dependencies = [ 75 | "libc", 76 | "option-ext", 77 | "redox_users", 78 | "windows-sys 0.48.0", 79 | ] 80 | 81 | [[package]] 82 | name = "form_urlencoded" 83 | version = "1.2.1" 84 | source = "registry+https://github.com/rust-lang/crates.io-index" 85 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" 86 | dependencies = [ 87 | "percent-encoding", 88 | ] 89 | 90 | [[package]] 91 | name = "getrandom" 92 | version = "0.2.14" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" 95 | dependencies = [ 96 | "cfg-if", 97 | "libc", 98 | "wasi", 99 | ] 100 | 101 | [[package]] 102 | name = "hex" 103 | version = "0.4.3" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 106 | 107 | [[package]] 108 | name = "iconify" 109 | version = "0.3.1" 110 | dependencies = [ 111 | "blake3", 112 | "directories", 113 | "hex", 114 | "iconify", 115 | "proc-macro2", 116 | "quote", 117 | "syn", 118 | "ureq", 119 | "url", 120 | ] 121 | 122 | [[package]] 123 | name = "idna" 124 | version = "0.5.0" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" 127 | dependencies = [ 128 | "unicode-bidi", 129 | "unicode-normalization", 130 | ] 131 | 132 | [[package]] 133 | name = "libc" 134 | version = "0.2.153" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 137 | 138 | [[package]] 139 | name = "libredox" 140 | version = "0.1.3" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" 143 | dependencies = [ 144 | "bitflags", 145 | "libc", 146 | ] 147 | 148 | [[package]] 149 | name = "log" 150 | version = "0.4.21" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" 153 | 154 | [[package]] 155 | name = "once_cell" 156 | version = "1.19.0" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 159 | 160 | [[package]] 161 | name = "option-ext" 162 | version = "0.2.0" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" 165 | 166 | [[package]] 167 | name = "percent-encoding" 168 | version = "2.3.1" 169 | source = "registry+https://github.com/rust-lang/crates.io-index" 170 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" 171 | 172 | [[package]] 173 | name = "proc-macro2" 174 | version = "1.0.86" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" 177 | dependencies = [ 178 | "unicode-ident", 179 | ] 180 | 181 | [[package]] 182 | name = "quote" 183 | version = "1.0.36" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" 186 | dependencies = [ 187 | "proc-macro2", 188 | ] 189 | 190 | [[package]] 191 | name = "redox_users" 192 | version = "0.4.5" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" 195 | dependencies = [ 196 | "getrandom", 197 | "libredox", 198 | "thiserror", 199 | ] 200 | 201 | [[package]] 202 | name = "ring" 203 | version = "0.17.8" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" 206 | dependencies = [ 207 | "cc", 208 | "cfg-if", 209 | "getrandom", 210 | "libc", 211 | "spin", 212 | "untrusted", 213 | "windows-sys 0.52.0", 214 | ] 215 | 216 | [[package]] 217 | name = "rustls" 218 | version = "0.23.11" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" 221 | dependencies = [ 222 | "log", 223 | "once_cell", 224 | "ring", 225 | "rustls-pki-types", 226 | "rustls-webpki", 227 | "subtle", 228 | "zeroize", 229 | ] 230 | 231 | [[package]] 232 | name = "rustls-pki-types" 233 | version = "1.7.0" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" 236 | 237 | [[package]] 238 | name = "rustls-webpki" 239 | version = "0.102.5" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" 242 | dependencies = [ 243 | "ring", 244 | "rustls-pki-types", 245 | "untrusted", 246 | ] 247 | 248 | [[package]] 249 | name = "spin" 250 | version = "0.9.8" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" 253 | 254 | [[package]] 255 | name = "subtle" 256 | version = "2.5.0" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" 259 | 260 | [[package]] 261 | name = "syn" 262 | version = "2.0.71" 263 | source = "registry+https://github.com/rust-lang/crates.io-index" 264 | checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" 265 | dependencies = [ 266 | "proc-macro2", 267 | "quote", 268 | "unicode-ident", 269 | ] 270 | 271 | [[package]] 272 | name = "thiserror" 273 | version = "1.0.58" 274 | source = "registry+https://github.com/rust-lang/crates.io-index" 275 | checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" 276 | dependencies = [ 277 | "thiserror-impl", 278 | ] 279 | 280 | [[package]] 281 | name = "thiserror-impl" 282 | version = "1.0.58" 283 | source = "registry+https://github.com/rust-lang/crates.io-index" 284 | checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" 285 | dependencies = [ 286 | "proc-macro2", 287 | "quote", 288 | "syn", 289 | ] 290 | 291 | [[package]] 292 | name = "tinyvec" 293 | version = "1.6.0" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 296 | dependencies = [ 297 | "tinyvec_macros", 298 | ] 299 | 300 | [[package]] 301 | name = "tinyvec_macros" 302 | version = "0.1.1" 303 | source = "registry+https://github.com/rust-lang/crates.io-index" 304 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 305 | 306 | [[package]] 307 | name = "unicode-bidi" 308 | version = "0.3.15" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" 311 | 312 | [[package]] 313 | name = "unicode-ident" 314 | version = "1.0.12" 315 | source = "registry+https://github.com/rust-lang/crates.io-index" 316 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 317 | 318 | [[package]] 319 | name = "unicode-normalization" 320 | version = "0.1.23" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" 323 | dependencies = [ 324 | "tinyvec", 325 | ] 326 | 327 | [[package]] 328 | name = "untrusted" 329 | version = "0.9.0" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" 332 | 333 | [[package]] 334 | name = "ureq" 335 | version = "2.10.0" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "72139d247e5f97a3eff96229a7ae85ead5328a39efe76f8bf5a06313d505b6ea" 338 | dependencies = [ 339 | "base64", 340 | "log", 341 | "once_cell", 342 | "rustls", 343 | "rustls-pki-types", 344 | "url", 345 | "webpki-roots", 346 | ] 347 | 348 | [[package]] 349 | name = "url" 350 | version = "2.5.2" 351 | source = "registry+https://github.com/rust-lang/crates.io-index" 352 | checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" 353 | dependencies = [ 354 | "form_urlencoded", 355 | "idna", 356 | "percent-encoding", 357 | ] 358 | 359 | [[package]] 360 | name = "wasi" 361 | version = "0.11.0+wasi-snapshot-preview1" 362 | source = "registry+https://github.com/rust-lang/crates.io-index" 363 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 364 | 365 | [[package]] 366 | name = "webpki-roots" 367 | version = "0.26.1" 368 | source = "registry+https://github.com/rust-lang/crates.io-index" 369 | checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" 370 | dependencies = [ 371 | "rustls-pki-types", 372 | ] 373 | 374 | [[package]] 375 | name = "windows-sys" 376 | version = "0.48.0" 377 | source = "registry+https://github.com/rust-lang/crates.io-index" 378 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 379 | dependencies = [ 380 | "windows-targets 0.48.5", 381 | ] 382 | 383 | [[package]] 384 | name = "windows-sys" 385 | version = "0.52.0" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 388 | dependencies = [ 389 | "windows-targets 0.52.5", 390 | ] 391 | 392 | [[package]] 393 | name = "windows-targets" 394 | version = "0.48.5" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 397 | dependencies = [ 398 | "windows_aarch64_gnullvm 0.48.5", 399 | "windows_aarch64_msvc 0.48.5", 400 | "windows_i686_gnu 0.48.5", 401 | "windows_i686_msvc 0.48.5", 402 | "windows_x86_64_gnu 0.48.5", 403 | "windows_x86_64_gnullvm 0.48.5", 404 | "windows_x86_64_msvc 0.48.5", 405 | ] 406 | 407 | [[package]] 408 | name = "windows-targets" 409 | version = "0.52.5" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" 412 | dependencies = [ 413 | "windows_aarch64_gnullvm 0.52.5", 414 | "windows_aarch64_msvc 0.52.5", 415 | "windows_i686_gnu 0.52.5", 416 | "windows_i686_gnullvm", 417 | "windows_i686_msvc 0.52.5", 418 | "windows_x86_64_gnu 0.52.5", 419 | "windows_x86_64_gnullvm 0.52.5", 420 | "windows_x86_64_msvc 0.52.5", 421 | ] 422 | 423 | [[package]] 424 | name = "windows_aarch64_gnullvm" 425 | version = "0.48.5" 426 | source = "registry+https://github.com/rust-lang/crates.io-index" 427 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 428 | 429 | [[package]] 430 | name = "windows_aarch64_gnullvm" 431 | version = "0.52.5" 432 | source = "registry+https://github.com/rust-lang/crates.io-index" 433 | checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" 434 | 435 | [[package]] 436 | name = "windows_aarch64_msvc" 437 | version = "0.48.5" 438 | source = "registry+https://github.com/rust-lang/crates.io-index" 439 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 440 | 441 | [[package]] 442 | name = "windows_aarch64_msvc" 443 | version = "0.52.5" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" 446 | 447 | [[package]] 448 | name = "windows_i686_gnu" 449 | version = "0.48.5" 450 | source = "registry+https://github.com/rust-lang/crates.io-index" 451 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 452 | 453 | [[package]] 454 | name = "windows_i686_gnu" 455 | version = "0.52.5" 456 | source = "registry+https://github.com/rust-lang/crates.io-index" 457 | checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" 458 | 459 | [[package]] 460 | name = "windows_i686_gnullvm" 461 | version = "0.52.5" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" 464 | 465 | [[package]] 466 | name = "windows_i686_msvc" 467 | version = "0.48.5" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 470 | 471 | [[package]] 472 | name = "windows_i686_msvc" 473 | version = "0.52.5" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" 476 | 477 | [[package]] 478 | name = "windows_x86_64_gnu" 479 | version = "0.48.5" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 482 | 483 | [[package]] 484 | name = "windows_x86_64_gnu" 485 | version = "0.52.5" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" 488 | 489 | [[package]] 490 | name = "windows_x86_64_gnullvm" 491 | version = "0.48.5" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 494 | 495 | [[package]] 496 | name = "windows_x86_64_gnullvm" 497 | version = "0.52.5" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" 500 | 501 | [[package]] 502 | name = "windows_x86_64_msvc" 503 | version = "0.48.5" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 506 | 507 | [[package]] 508 | name = "windows_x86_64_msvc" 509 | version = "0.52.5" 510 | source = "registry+https://github.com/rust-lang/crates.io-index" 511 | checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" 512 | 513 | [[package]] 514 | name = "zeroize" 515 | version = "1.7.0" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" 518 | --------------------------------------------------------------------------------