├── .gitignore ├── .travis.yml ├── Cargo.toml ├── ChangeLog.md ├── LICENSE.md ├── README.md ├── docs ├── COPYRIGHT.txt ├── FiraSans-LICENSE.txt ├── FiraSans-Medium.woff ├── FiraSans-Regular.woff ├── Heuristica-Italic.woff ├── Heuristica-LICENSE.txt ├── LICENSE-APACHE.txt ├── LICENSE-MIT.txt ├── SourceCodePro-LICENSE.txt ├── SourceCodePro-Regular.woff ├── SourceCodePro-Semibold.woff ├── SourceSerifPro-Bold.woff ├── SourceSerifPro-LICENSE.txt ├── SourceSerifPro-Regular.woff ├── implementors │ ├── core │ │ ├── cmp │ │ │ └── trait.PartialEq.js │ │ ├── convert │ │ │ └── trait.From.js │ │ ├── fmt │ │ │ ├── trait.Debug.js │ │ │ └── trait.Display.js │ │ └── ops │ │ │ └── trait.Drop.js │ └── std │ │ └── error │ │ └── trait.Error.js ├── ispell │ ├── enum.IspellResult.html │ ├── error │ │ ├── struct.Error.html │ │ └── type.Result.html │ ├── index.html │ ├── ispell_result │ │ ├── enum.IspellResult.html │ │ └── struct.IspellError.html │ ├── sidebar-items.js │ ├── spell_checker │ │ └── struct.SpellChecker.html │ ├── spell_launcher │ │ └── struct.SpellLauncher.html │ ├── struct.Error.html │ ├── struct.IspellError.html │ ├── struct.SpellChecker.html │ ├── struct.SpellLauncher.html │ └── type.Result.html ├── jquery.js ├── main.css ├── main.js ├── normalize.css ├── playpen.js ├── rustdoc.css ├── search-index.js └── src │ └── ispell │ └── src │ ├── async_reader.rs.html │ ├── error.rs.html │ ├── ispell_result.rs.html │ ├── lib.rs.html │ ├── spell_checker.rs.html │ └── spell_launcher.rs.html ├── examples ├── dict.rs ├── readme.rs ├── simple.rs ├── sleep.sh └── timeout.rs └── src ├── async_reader.rs ├── error.rs ├── ispell_result.rs ├── lib.rs ├── spell_checker.rs └── spell_launcher.rs /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | *~ 4 | \#* 5 | .* -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | rust: 3 | - 1.12.0 4 | - beta 5 | - nightly 6 | before_install: 7 | - sudo apt-get -qq update 8 | - sudo apt-get install -y ispell aspell aspell-en aspell-fr 9 | matrix: 10 | allow_failures: 11 | - rust: nightly 12 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ispell" 3 | version = "0.3.1" 4 | authors = ["Elisabeth Henry "] 5 | description = "Easily run ispell, hunspell or aspell from Rust" 6 | readme = "README.md" 7 | keywords = ["ispell", "aspell", "spellchecker"] 8 | categories = ["api-bindings"] 9 | repository = "https://github.com/lise-henry/rust-ispell" 10 | documentation = "https://lise-henry.github.io/rust-ispell/ispell/" 11 | license = "MPL-2.0" 12 | exclude = ["docs/**"] 13 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | ChangeLog 2 | ========= 3 | 4 | 0.3.1 (2020-07-04) 5 | ---------------------- 6 | - correct reading of check output 7 | 8 | 0.3.0 (2016-09-30) 9 | ------------------ 10 | * Added a `timeout` method to SpellLauncher. This allows to 11 | specify a timeout (in milliseconds) when reading from spawned 12 | process's output, so it no longer blocks your program infinitely if 13 | it stops outputting text. 14 | * Added the following methods in `SpellChecker` to add words: 15 | * `add_word`: add a word for the current session; 16 | * `add_word_to_dictionary`: add a word to your personal directory 17 | (should be saved between sessions). 18 | 19 | **Breaking change**: rename `mispelled` in `IspellError` to 20 | `misspelled`. Yes, it's quite a shame (but ironical) that the only 21 | breaking change in this release of a spell checker library comes 22 | from a spelling issue, but well... 23 | 24 | 0.2.0 (2016-09-26) 25 | ------------------ 26 | * Slightly fix the API: 27 | * Remove `language` method as it was redundant with `dictionary`; 28 | * `aspell` method doesn't take a bool anymore; 29 | * Add `hunspell` method to set `SpellLauncher` to use `hunspell` 30 | * Documentation is now more complete. 31 | 32 | 0.1.0 (2016-09-26) 33 | ------------------ 34 | * First release. 35 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | ### 1. Definitions 5 | 6 | **1.1. “Contributor”** 7 | means each individual or legal entity that creates, contributes to 8 | the creation of, or owns Covered Software. 9 | 10 | **1.2. “Contributor Version”** 11 | means the combination of the Contributions of others (if any) used 12 | by a Contributor and that particular Contributor's Contribution. 13 | 14 | **1.3. “Contribution”** 15 | means Covered Software of a particular Contributor. 16 | 17 | **1.4. “Covered Software”** 18 | means Source Code Form to which the initial Contributor has attached 19 | the notice in Exhibit A, the Executable Form of such Source Code 20 | Form, and Modifications of such Source Code Form, in each case 21 | including portions thereof. 22 | 23 | **1.5. “Incompatible With Secondary Licenses”** 24 | means 25 | 26 | * **(a)** that the initial Contributor has attached the notice described 27 | in Exhibit B to the Covered Software; or 28 | * **(b)** that the Covered Software was made available under the terms of 29 | version 1.1 or earlier of the License, but not also under the 30 | terms of a Secondary License. 31 | 32 | **1.6. “Executable Form”** 33 | means any form of the work other than Source Code Form. 34 | 35 | **1.7. “Larger Work”** 36 | means a work that combines Covered Software with other material, in 37 | a separate file or files, that is not Covered Software. 38 | 39 | **1.8. “License”** 40 | means this document. 41 | 42 | **1.9. “Licensable”** 43 | means having the right to grant, to the maximum extent possible, 44 | whether at the time of the initial grant or subsequently, any and 45 | all of the rights conveyed by this License. 46 | 47 | **1.10. “Modifications”** 48 | means any of the following: 49 | 50 | * **(a)** any file in Source Code Form that results from an addition to, 51 | deletion from, or modification of the contents of Covered 52 | Software; or 53 | * **(b)** any new file in Source Code Form that contains any Covered 54 | Software. 55 | 56 | **1.11. “Patent Claims” of a Contributor** 57 | means any patent claim(s), including without limitation, method, 58 | process, and apparatus claims, in any patent Licensable by such 59 | Contributor that would be infringed, but for the grant of the 60 | License, by the making, using, selling, offering for sale, having 61 | made, import, or transfer of either its Contributions or its 62 | Contributor Version. 63 | 64 | **1.12. “Secondary License”** 65 | means either the GNU General Public License, Version 2.0, the GNU 66 | Lesser General Public License, Version 2.1, the GNU Affero General 67 | Public License, Version 3.0, or any later versions of those 68 | licenses. 69 | 70 | **1.13. “Source Code Form”** 71 | means the form of the work preferred for making modifications. 72 | 73 | **1.14. “You” (or “Your”)** 74 | means an individual or a legal entity exercising rights under this 75 | License. For legal entities, “You” includes any entity that 76 | controls, is controlled by, or is under common control with You. For 77 | purposes of this definition, “control” means **(a)** the power, direct 78 | or indirect, to cause the direction or management of such entity, 79 | whether by contract or otherwise, or **(b)** ownership of more than 80 | fifty percent (50%) of the outstanding shares or beneficial 81 | ownership of such entity. 82 | 83 | 84 | ### 2. License Grants and Conditions 85 | 86 | #### 2.1. Grants 87 | 88 | Each Contributor hereby grants You a world-wide, royalty-free, 89 | non-exclusive license: 90 | 91 | * **(a)** under intellectual property rights (other than patent or trademark) 92 | Licensable by such Contributor to use, reproduce, make available, 93 | modify, display, perform, distribute, and otherwise exploit its 94 | Contributions, either on an unmodified basis, with Modifications, or 95 | as part of a Larger Work; and 96 | * **(b)** under Patent Claims of such Contributor to make, use, sell, offer 97 | for sale, have made, import, and otherwise transfer either its 98 | Contributions or its Contributor Version. 99 | 100 | #### 2.2. Effective Date 101 | 102 | The licenses granted in Section 2.1 with respect to any Contribution 103 | become effective for each Contribution on the date the Contributor first 104 | distributes such Contribution. 105 | 106 | #### 2.3. Limitations on Grant Scope 107 | 108 | The licenses granted in this Section 2 are the only rights granted under 109 | this License. No additional rights or licenses will be implied from the 110 | distribution or licensing of Covered Software under this License. 111 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 112 | Contributor: 113 | 114 | * **(a)** for any code that a Contributor has removed from Covered Software; 115 | or 116 | * **(b)** for infringements caused by: **(i)** Your and any other third party's 117 | modifications of Covered Software, or **(ii)** the combination of its 118 | Contributions with other software (except as part of its Contributor 119 | Version); or 120 | * **(c)** under Patent Claims infringed by Covered Software in the absence of 121 | its Contributions. 122 | 123 | This License does not grant any rights in the trademarks, service marks, 124 | or logos of any Contributor (except as may be necessary to comply with 125 | the notice requirements in Section 3.4). 126 | 127 | #### 2.4. Subsequent Licenses 128 | 129 | No Contributor makes additional grants as a result of Your choice to 130 | distribute the Covered Software under a subsequent version of this 131 | License (see Section 10.2) or under the terms of a Secondary License (if 132 | permitted under the terms of Section 3.3). 133 | 134 | #### 2.5. Representation 135 | 136 | Each Contributor represents that the Contributor believes its 137 | Contributions are its original creation(s) or it has sufficient rights 138 | to grant the rights to its Contributions conveyed by this License. 139 | 140 | #### 2.6. Fair Use 141 | 142 | This License is not intended to limit any rights You have under 143 | applicable copyright doctrines of fair use, fair dealing, or other 144 | equivalents. 145 | 146 | #### 2.7. Conditions 147 | 148 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 149 | in Section 2.1. 150 | 151 | 152 | ### 3. Responsibilities 153 | 154 | #### 3.1. Distribution of Source Form 155 | 156 | All distribution of Covered Software in Source Code Form, including any 157 | Modifications that You create or to which You contribute, must be under 158 | the terms of this License. You must inform recipients that the Source 159 | Code Form of the Covered Software is governed by the terms of this 160 | License, and how they can obtain a copy of this License. You may not 161 | attempt to alter or restrict the recipients' rights in the Source Code 162 | Form. 163 | 164 | #### 3.2. Distribution of Executable Form 165 | 166 | If You distribute Covered Software in Executable Form then: 167 | 168 | * **(a)** such Covered Software must also be made available in Source Code 169 | Form, as described in Section 3.1, and You must inform recipients of 170 | the Executable Form how they can obtain a copy of such Source Code 171 | Form by reasonable means in a timely manner, at a charge no more 172 | than the cost of distribution to the recipient; and 173 | 174 | * **(b)** You may distribute such Executable Form under the terms of this 175 | License, or sublicense it under different terms, provided that the 176 | license for the Executable Form does not attempt to limit or alter 177 | the recipients' rights in the Source Code Form under this License. 178 | 179 | #### 3.3. Distribution of a Larger Work 180 | 181 | You may create and distribute a Larger Work under terms of Your choice, 182 | provided that You also comply with the requirements of this License for 183 | the Covered Software. If the Larger Work is a combination of Covered 184 | Software with a work governed by one or more Secondary Licenses, and the 185 | Covered Software is not Incompatible With Secondary Licenses, this 186 | License permits You to additionally distribute such Covered Software 187 | under the terms of such Secondary License(s), so that the recipient of 188 | the Larger Work may, at their option, further distribute the Covered 189 | Software under the terms of either this License or such Secondary 190 | License(s). 191 | 192 | #### 3.4. Notices 193 | 194 | You may not remove or alter the substance of any license notices 195 | (including copyright notices, patent notices, disclaimers of warranty, 196 | or limitations of liability) contained within the Source Code Form of 197 | the Covered Software, except that You may alter any license notices to 198 | the extent required to remedy known factual inaccuracies. 199 | 200 | #### 3.5. Application of Additional Terms 201 | 202 | You may choose to offer, and to charge a fee for, warranty, support, 203 | indemnity or liability obligations to one or more recipients of Covered 204 | Software. However, You may do so only on Your own behalf, and not on 205 | behalf of any Contributor. You must make it absolutely clear that any 206 | such warranty, support, indemnity, or liability obligation is offered by 207 | You alone, and You hereby agree to indemnify every Contributor for any 208 | liability incurred by such Contributor as a result of warranty, support, 209 | indemnity or liability terms You offer. You may include additional 210 | disclaimers of warranty and limitations of liability specific to any 211 | jurisdiction. 212 | 213 | 214 | ### 4. Inability to Comply Due to Statute or Regulation 215 | 216 | If it is impossible for You to comply with any of the terms of this 217 | License with respect to some or all of the Covered Software due to 218 | statute, judicial order, or regulation then You must: **(a)** comply with 219 | the terms of this License to the maximum extent possible; and **(b)** 220 | describe the limitations and the code they affect. Such description must 221 | be placed in a text file included with all distributions of the Covered 222 | Software under this License. Except to the extent prohibited by statute 223 | or regulation, such description must be sufficiently detailed for a 224 | recipient of ordinary skill to be able to understand it. 225 | 226 | 227 | ### 5. Termination 228 | 229 | **5.1.** The rights granted under this License will terminate automatically 230 | if You fail to comply with any of its terms. However, if You become 231 | compliant, then the rights granted under this License from a particular 232 | Contributor are reinstated **(a)** provisionally, unless and until such 233 | Contributor explicitly and finally terminates Your grants, and **(b)** on an 234 | ongoing basis, if such Contributor fails to notify You of the 235 | non-compliance by some reasonable means prior to 60 days after You have 236 | come back into compliance. Moreover, Your grants from a particular 237 | Contributor are reinstated on an ongoing basis if such Contributor 238 | notifies You of the non-compliance by some reasonable means, this is the 239 | first time You have received notice of non-compliance with this License 240 | from such Contributor, and You become compliant prior to 30 days after 241 | Your receipt of the notice. 242 | 243 | **5.2.** If You initiate litigation against any entity by asserting a patent 244 | infringement claim (excluding declaratory judgment actions, 245 | counter-claims, and cross-claims) alleging that a Contributor Version 246 | directly or indirectly infringes any patent, then the rights granted to 247 | You by any and all Contributors for the Covered Software under Section 248 | 2.1 of this License shall terminate. 249 | 250 | **5.3.** In the event of termination under Sections 5.1 or 5.2 above, all 251 | end user license agreements (excluding distributors and resellers) which 252 | have been validly granted by You or Your distributors under this License 253 | prior to termination shall survive termination. 254 | 255 | 256 | ### 6. Disclaimer of Warranty 257 | 258 | > Covered Software is provided under this License on an “as is” 259 | > basis, without warranty of any kind, either expressed, implied, or 260 | > statutory, including, without limitation, warranties that the 261 | > Covered Software is free of defects, merchantable, fit for a 262 | > particular purpose or non-infringing. The entire risk as to the 263 | > quality and performance of the Covered Software is with You. 264 | > Should any Covered Software prove defective in any respect, You 265 | > (not any Contributor) assume the cost of any necessary servicing, 266 | > repair, or correction. This disclaimer of warranty constitutes an 267 | > essential part of this License. No use of any Covered Software is 268 | > authorized under this License except under this disclaimer. 269 | 270 | ### 7. Limitation of Liability 271 | 272 | > Under no circumstances and under no legal theory, whether tort 273 | > (including negligence), contract, or otherwise, shall any 274 | > Contributor, or anyone who distributes Covered Software as 275 | > permitted above, be liable to You for any direct, indirect, 276 | > special, incidental, or consequential damages of any character 277 | > including, without limitation, damages for lost profits, loss of 278 | > goodwill, work stoppage, computer failure or malfunction, or any 279 | > and all other commercial damages or losses, even if such party 280 | > shall have been informed of the possibility of such damages. This 281 | > limitation of liability shall not apply to liability for death or 282 | > personal injury resulting from such party's negligence to the 283 | > extent applicable law prohibits such limitation. Some 284 | > jurisdictions do not allow the exclusion or limitation of 285 | > incidental or consequential damages, so this exclusion and 286 | > limitation may not apply to You. 287 | 288 | 289 | ### 8. Litigation 290 | 291 | Any litigation relating to this License may be brought only in the 292 | courts of a jurisdiction where the defendant maintains its principal 293 | place of business and such litigation shall be governed by laws of that 294 | jurisdiction, without reference to its conflict-of-law provisions. 295 | Nothing in this Section shall prevent a party's ability to bring 296 | cross-claims or counter-claims. 297 | 298 | 299 | ### 9. Miscellaneous 300 | 301 | This License represents the complete agreement concerning the subject 302 | matter hereof. If any provision of this License is held to be 303 | unenforceable, such provision shall be reformed only to the extent 304 | necessary to make it enforceable. Any law or regulation which provides 305 | that the language of a contract shall be construed against the drafter 306 | shall not be used to construe this License against a Contributor. 307 | 308 | 309 | ### 10. Versions of the License 310 | 311 | #### 10.1. New Versions 312 | 313 | Mozilla Foundation is the license steward. Except as provided in Section 314 | 10.3, no one other than the license steward has the right to modify or 315 | publish new versions of this License. Each version will be given a 316 | distinguishing version number. 317 | 318 | #### 10.2. Effect of New Versions 319 | 320 | You may distribute the Covered Software under the terms of the version 321 | of the License under which You originally received the Covered Software, 322 | or under the terms of any subsequent version published by the license 323 | steward. 324 | 325 | #### 10.3. Modified Versions 326 | 327 | If you create software not governed by this License, and you want to 328 | create a new license for such software, you may create and use a 329 | modified version of this License if you rename the license and remove 330 | any references to the name of the license steward (except to note that 331 | such modified license differs from this License). 332 | 333 | #### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses 334 | 335 | If You choose to distribute Source Code Form that is Incompatible With 336 | Secondary Licenses under the terms of this version of the License, the 337 | notice described in Exhibit B of this License must be attached. 338 | 339 | ## Exhibit A - Source Code Form License Notice 340 | 341 | This Source Code Form is subject to the terms of the Mozilla Public 342 | License, v. 2.0. If a copy of the MPL was not distributed with this 343 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 344 | 345 | If it is not possible or desirable to put the notice in a particular 346 | file, then You may include the notice in a location (such as a LICENSE 347 | file in a relevant directory) where a recipient would be likely to look 348 | for such a notice. 349 | 350 | You may add additional accurate notices of copyright ownership. 351 | 352 | ## Exhibit B - “Incompatible With Secondary Licenses” Notice 353 | 354 | This Source Code Form is "Incompatible With Secondary Licenses", as 355 | defined by the Mozilla Public License, v. 2.0. 356 | 357 | 358 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rust-ispell 2 | =========== 3 | 4 | This library allows to easily use `ispell` or `aspell` from Rust. 5 | 6 | Usage 7 | ----- 8 | 9 | Add this to your `Cargo.toml` 10 | 11 | ```toml 12 | [dependencies] 13 | ispell = "0.3" 14 | ``` 15 | 16 | Example 17 | ------- 18 | 19 | ```rust 20 | extern crate ispell; 21 | use ispell::SpellLauncher; 22 | 23 | fn main() { 24 | let mut checker = SpellLauncher::new() 25 | .aspell() 26 | .dictionary("en_GB") 27 | .launch() 28 | .unwrap(); 29 | let errors = checker.check("A simpel test to see if it detetcs typing errors").unwrap(); 30 | for e in errors { 31 | println!("'{}' (pos: {}) is misspelled!", &e.misspelled, e.position); 32 | if !e.suggestions.is_empty() { 33 | println!("Maybe you meant '{}'?", &e.suggestions[0]); 34 | } 35 | } 36 | } 37 | ``` 38 | 39 | will display: 40 | 41 | ``` 42 | 'simpel' (pos: 2) is misspelled! 43 | Maybe you meant 'simple'? 44 | 'detetcs' (pos: 27) is misspelled! 45 | Maybe you meant 'dietetics'? 46 | ``` 47 | 48 | (*Yes*, that is exactly what I meant.) 49 | 50 | Documentation 51 | ------------- 52 | 53 | For more information about using this library, see the 54 | [API documentation on Github.io](https://lise-henry.github.io/rust-ispell/ispell/) 55 | or on [docs.rs](https://docs.rs/releases/search?query=ispell). 56 | 57 | Requirements 58 | ------------ 59 | 60 | `rust-ispell` 0.3 requires the `1.12.0` (or a more recent) version of 61 | the 62 | `rustc` compiler, since it uses the `std::sync::mpcs::Receiver::recv_timeout` 63 | that was only stabilized in this version. 64 | 65 | ChangeLog 66 | --------- 67 | 68 | See [ChangeLog.md](ChangeLog.md). 69 | 70 | License 71 | ------- 72 | 73 | `rust-ispell` is free software, published under the 74 | [Mozilla Public License, version 2.0](https://www.mozilla.org/en-US/MPL/2.0/). 75 | -------------------------------------------------------------------------------- /docs/COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | These documentation pages include resources by third parties. This copyright 2 | file applies only to those resources. The following third party resources are 3 | included, and carry their own copyright notices and license terms: 4 | 5 | * Fira Sans (FiraSans-Regular.woff, FiraSans-Medium.woff): 6 | 7 | Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ 8 | with Reserved Font Name Fira Sans. 9 | 10 | Copyright (c) 2014, Telefonica S.A. 11 | 12 | Licensed under the SIL Open Font License, Version 1.1. 13 | See FiraSans-LICENSE.txt. 14 | 15 | * Heuristica (Heuristica-Italic.woff): 16 | 17 | Copyright 1989, 1991 Adobe Systems Incorporated. All rights reserved. 18 | Utopia is either a registered trademark or trademark of Adobe Systems 19 | Incorporated in the United States and/or other countries. Used under 20 | license. 21 | 22 | Copyright 2006 Han The Thanh, Vntopia font family, http://vntex.sf.net 23 | 24 | Copyright (c) 2008-2012, Andrey V. Panov (panov@canopus.iacp.dvo.ru), 25 | with Reserved Font Name Heuristica. 26 | 27 | Licensed under the SIL Open Font License, Version 1.1. 28 | See Heuristica-LICENSE.txt. 29 | 30 | * jQuery (jquery-2.1.4.min.js): 31 | 32 | Copyright 2005, 2015 jQuery Foundation, Inc. 33 | Licensed under the MIT license (see LICENSE-MIT.txt). 34 | 35 | * rustdoc.css, main.js, and playpen.js: 36 | 37 | Copyright 2015 The Rust Developers. 38 | Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE.txt) or 39 | the MIT license (LICENSE-MIT.txt) at your option. 40 | 41 | * normalize.css: 42 | 43 | Copyright (c) Nicolas Gallagher and Jonathan Neal. 44 | Licensed under the MIT license (see LICENSE-MIT.txt). 45 | 46 | * Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff): 47 | 48 | Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), 49 | with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark 50 | of Adobe Systems Incorporated in the United States and/or other countries. 51 | 52 | Licensed under the SIL Open Font License, Version 1.1. 53 | See SourceCodePro-LICENSE.txt. 54 | 55 | * Source Serif Pro (SourceSerifPro-Regular.woff, SourceSerifPro-Bold.woff): 56 | 57 | Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/), with 58 | Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of 59 | Adobe Systems Incorporated in the United States and/or other countries. 60 | 61 | Licensed under the SIL Open Font License, Version 1.1. 62 | See SourceSerifPro-LICENSE.txt. 63 | 64 | This copyright file is intended to be distributed with rustdoc output. 65 | -------------------------------------------------------------------------------- /docs/FiraSans-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ 2 | with Reserved Font Name Fira Sans. 3 | 4 | Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ 5 | with Reserved Font Name Fira Mono. 6 | 7 | Copyright (c) 2014, Telefonica S.A. 8 | 9 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 10 | This license is copied below, and is also available with a FAQ at: 11 | http://scripts.sil.org/OFL 12 | 13 | 14 | ----------------------------------------------------------- 15 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 16 | ----------------------------------------------------------- 17 | 18 | PREAMBLE 19 | The goals of the Open Font License (OFL) are to stimulate worldwide 20 | development of collaborative font projects, to support the font creation 21 | efforts of academic and linguistic communities, and to provide a free and 22 | open framework in which fonts may be shared and improved in partnership 23 | with others. 24 | 25 | The OFL allows the licensed fonts to be used, studied, modified and 26 | redistributed freely as long as they are not sold by themselves. The 27 | fonts, including any derivative works, can be bundled, embedded, 28 | redistributed and/or sold with any software provided that any reserved 29 | names are not used by derivative works. The fonts and derivatives, 30 | however, cannot be released under any other type of license. The 31 | requirement for fonts to remain under this license does not apply 32 | to any document created using the fonts or their derivatives. 33 | 34 | DEFINITIONS 35 | "Font Software" refers to the set of files released by the Copyright 36 | Holder(s) under this license and clearly marked as such. This may 37 | include source files, build scripts and documentation. 38 | 39 | "Reserved Font Name" refers to any names specified as such after the 40 | copyright statement(s). 41 | 42 | "Original Version" refers to the collection of Font Software components as 43 | distributed by the Copyright Holder(s). 44 | 45 | "Modified Version" refers to any derivative made by adding to, deleting, 46 | or substituting -- in part or in whole -- any of the components of the 47 | Original Version, by changing formats or by porting the Font Software to a 48 | new environment. 49 | 50 | "Author" refers to any designer, engineer, programmer, technical 51 | writer or other person who contributed to the Font Software. 52 | 53 | PERMISSION & CONDITIONS 54 | Permission is hereby granted, free of charge, to any person obtaining 55 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 56 | redistribute, and sell modified and unmodified copies of the Font 57 | Software, subject to the following conditions: 58 | 59 | 1) Neither the Font Software nor any of its individual components, 60 | in Original or Modified Versions, may be sold by itself. 61 | 62 | 2) Original or Modified Versions of the Font Software may be bundled, 63 | redistributed and/or sold with any software, provided that each copy 64 | contains the above copyright notice and this license. These can be 65 | included either as stand-alone text files, human-readable headers or 66 | in the appropriate machine-readable metadata fields within text or 67 | binary files as long as those fields can be easily viewed by the user. 68 | 69 | 3) No Modified Version of the Font Software may use the Reserved Font 70 | Name(s) unless explicit written permission is granted by the corresponding 71 | Copyright Holder. This restriction only applies to the primary font name as 72 | presented to the users. 73 | 74 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 75 | Software shall not be used to promote, endorse or advertise any 76 | Modified Version, except to acknowledge the contribution(s) of the 77 | Copyright Holder(s) and the Author(s) or with their explicit written 78 | permission. 79 | 80 | 5) The Font Software, modified or unmodified, in part or in whole, 81 | must be distributed entirely under this license, and must not be 82 | distributed under any other license. The requirement for fonts to 83 | remain under this license does not apply to any document created 84 | using the Font Software. 85 | 86 | TERMINATION 87 | This license becomes null and void if any of the above conditions are 88 | not met. 89 | 90 | DISCLAIMER 91 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 92 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 93 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 94 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 95 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 96 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 97 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 98 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 99 | OTHER DEALINGS IN THE FONT SOFTWARE. 100 | -------------------------------------------------------------------------------- /docs/FiraSans-Medium.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crowdagger/rust-ispell/d89b76733c86a669ffcc3088c8ef0d7f352e85a5/docs/FiraSans-Medium.woff -------------------------------------------------------------------------------- /docs/FiraSans-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crowdagger/rust-ispell/d89b76733c86a669ffcc3088c8ef0d7f352e85a5/docs/FiraSans-Regular.woff -------------------------------------------------------------------------------- /docs/Heuristica-Italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crowdagger/rust-ispell/d89b76733c86a669ffcc3088c8ef0d7f352e85a5/docs/Heuristica-Italic.woff -------------------------------------------------------------------------------- /docs/Heuristica-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 1989, 1991 Adobe Systems Incorporated. All rights reserved. 2 | Utopia is either a registered trademark or trademark of Adobe Systems 3 | Incorporated in the United States and/or other countries. Used under 4 | license. 5 | 6 | Copyright 2006 Han The Thanh, Vntopia font family, http://vntex.sf.net 7 | 8 | Copyright (c) 2008-2012, Andrey V. Panov (panov@canopus.iacp.dvo.ru), 9 | with Reserved Font Name Heuristica. 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 | -------------------------------------------------------------------------------- /docs/LICENSE-APACHE.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 | -------------------------------------------------------------------------------- /docs/LICENSE-MIT.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/SourceCodePro-LICENSE.txt: -------------------------------------------------------------------------------- 1 | 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. 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | 5 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /docs/SourceCodePro-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crowdagger/rust-ispell/d89b76733c86a669ffcc3088c8ef0d7f352e85a5/docs/SourceCodePro-Regular.woff -------------------------------------------------------------------------------- /docs/SourceCodePro-Semibold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crowdagger/rust-ispell/d89b76733c86a669ffcc3088c8ef0d7f352e85a5/docs/SourceCodePro-Semibold.woff -------------------------------------------------------------------------------- /docs/SourceSerifPro-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crowdagger/rust-ispell/d89b76733c86a669ffcc3088c8ef0d7f352e85a5/docs/SourceSerifPro-Bold.woff -------------------------------------------------------------------------------- /docs/SourceSerifPro-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 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. 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | 5 | This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /docs/SourceSerifPro-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crowdagger/rust-ispell/d89b76733c86a669ffcc3088c8ef0d7f352e85a5/docs/SourceSerifPro-Regular.woff -------------------------------------------------------------------------------- /docs/implementors/core/cmp/trait.PartialEq.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["ispell"] = ["impl PartialEq for Error","impl PartialEq for IspellError","impl PartialEq for IspellResult",]; 3 | 4 | if (window.register_implementors) { 5 | window.register_implementors(implementors); 6 | } else { 7 | window.pending_implementors = implementors; 8 | } 9 | 10 | })() 11 | -------------------------------------------------------------------------------- /docs/implementors/core/convert/trait.From.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["ispell"] = ["impl From<FromUtf8Error> for Error","impl From<Error> for Error",]; 3 | 4 | if (window.register_implementors) { 5 | window.register_implementors(implementors); 6 | } else { 7 | window.pending_implementors = implementors; 8 | } 9 | 10 | })() 11 | -------------------------------------------------------------------------------- /docs/implementors/core/fmt/trait.Debug.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["ispell"] = ["impl Debug for SpellLauncher","impl Debug for Error","impl Debug for IspellError","impl Debug for IspellResult",]; 3 | 4 | if (window.register_implementors) { 5 | window.register_implementors(implementors); 6 | } else { 7 | window.pending_implementors = implementors; 8 | } 9 | 10 | })() 11 | -------------------------------------------------------------------------------- /docs/implementors/core/fmt/trait.Display.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["ispell"] = ["impl Display for Error",]; 3 | 4 | if (window.register_implementors) { 5 | window.register_implementors(implementors); 6 | } else { 7 | window.pending_implementors = implementors; 8 | } 9 | 10 | })() 11 | -------------------------------------------------------------------------------- /docs/implementors/core/ops/trait.Drop.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["ispell"] = ["impl Drop for SpellChecker",]; 3 | 4 | if (window.register_implementors) { 5 | window.register_implementors(implementors); 6 | } else { 7 | window.pending_implementors = implementors; 8 | } 9 | 10 | })() 11 | -------------------------------------------------------------------------------- /docs/implementors/std/error/trait.Error.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["ispell"] = ["impl Error for Error",]; 3 | 4 | if (window.register_implementors) { 5 | window.register_implementors(implementors); 6 | } else { 7 | window.pending_implementors = implementors; 8 | } 9 | 10 | })() 11 | -------------------------------------------------------------------------------- /docs/ispell/enum.IspellResult.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell::IspellResult - Rust 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
46 |

Enum ispell::IspellResult 47 | 48 | [] 49 | 50 | [src]

51 |
pub enum IspellResult {
 52 |     Ok,
 53 |     Root(String),
 54 |     Compound,
 55 |     Miss(IspellError),
 56 |     Guess(IspellError),
 57 |     None(IspellError),
 58 | }

A result from ispell, corresponding to a line that is sent back for each word.

59 | 60 |

See the manpage ispell(1) for more informations about the meaning of each variant.

61 |

Variants

62 | Ok

The word was found in the dictionnary.

63 | 64 |

Corresponds to '*'

65 |
Root(String)

The word wasn't found, but a root word was found.

66 | 67 |

Corresponds to '+'

68 |
Compound

The word wasn't found, but corresponds to the concatenation of two words

69 | 70 |

Corresponds to '-'

71 |
Miss(IspellError)

The word wasn't found, but there are near misses

72 | 73 |

Corresponds to '&'

74 |
Guess(IspellError)

The word wasn't found, but could be formed by adding illegal affixes to a known root

75 | 76 |

Corresponds to '?'

77 |
None(IspellError)

The word wasn't found in the dictionnary and there are no suggestions

78 | 79 |

Corresponds to '#'

80 |

Trait Implementations

impl PartialEq for IspellResult
[src]

81 |

fn eq(&self, __arg_0: &IspellResult) -> bool

82 |

This method tests for self and other values to be equal, and is used by ==. Read more

83 |

fn ne(&self, __arg_0: &IspellResult) -> bool

84 |

This method tests for !=.

85 |

impl Debug for IspellResult
[src]

86 |

fn fmt(&self, __arg_0: &mut Formatter) -> Result

87 |

Formats the value using the given formatter.

88 |
89 | 90 | 91 | 92 | 93 | 138 | 139 | 140 | 141 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /docs/ispell/error/struct.Error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../ispell/struct.Error.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/ispell/error/type.Result.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../ispell/type.Result.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/ispell/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell - Rust 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
46 |

Crate ispell 47 | 48 | [] 49 | 50 | [src]

51 |

This library provides an interface for easily calling the ispell, aspell 52 | or hunspell command from Rust programs.

53 | 54 |

Example

55 |
 56 | use ispell::SpellLauncher;
 57 | let mut checker = SpellLauncher::new()
 58 |                  .aspell()
 59 |                  .launch()
 60 |                  .unwrap();
 61 | let errors = checker.check("Testing iff if it works").unwrap();
 62 | assert_eq!(&errors[0].misspelled, "iff");
 63 | assert_eq!(errors[0].position, 8);
64 | 65 |

The SpellLauncher

66 |

You can set the command that will be called by using the aspell, hunspell and 67 | ispell (default value) methods:

68 | 69 |
 70 | let result = SpellLauncher::new()
 71 |              .aspell()
 72 |              .launch();
73 | 74 |
 75 | let result = SpellLauncher::new()
 76 |              .hunspell()
 77 |              .launch();
78 | 79 |

You can also set the dictionary that must be used:

80 | 81 |
 82 | let checker = SpellLauncher::new()
 83 |               .aspell()
 84 |               .dictionary("en_GB")
 85 |               .launch()
 86 |               .unwrap();
87 | 88 |

The SpellChecker

89 |

If the command has been launched successfully, it will return a SpellChecker.

90 | 91 |

Checking words

92 |

The main usage of this struct is using the check method to get 93 | the errors (IspellError) the spell checker detects. The ispell 94 | API returns the position (in 95 | characters) from the beginning of the line. This means that, if 96 | you want to be able do to anything with these numbers, you'll have 97 | to call check line by line.

98 | 99 |

This method returns a list of IspellErrors, containing:

100 | 101 |
    102 |
  • the misspelled word;
  • 103 |
  • the position (number of characters since the beginning of the 104 | line);
  • 105 |
  • a (possibly empty) list of suggestions.
  • 106 |
107 | 108 |
109 | let mut checker = SpellLauncher::new()
110 |                   .launch()
111 |                   .unwrap();
112 | let errors = checker.check("Does thit message contain any erors?").unwrap();
113 | for e in errors {
114 |     println!("{} was misspelled at pos {}.", e.misspelled, e.position);
115 |     println!("There are {} suggestions for alternatives", e.suggestions.len());
116 | }
117 | 118 |

SpellChecker also provides the check_raw method, whose behaviour mimics more closely 119 | ispell's output.

120 | 121 |

Adding words

122 |

There are two methods to add words so they are no more detected as errors:

123 | 124 |
    125 |
  • add_word adds a word to this current session, but doesn't save it;
  • 126 |
  • add_word_to_dictionary adds a word to your personal dictionary, saving it for 127 | next sessions.
  • 128 |
129 | 130 |
131 | let mut checker = SpellLauncher::new()
132 |                   .launch()
133 |                   .unwrap();
134 | checker.add_word("foobar"); // Add a word only to this session
135 | checker.add_word_to_dictionary("rustacean"); // Add a word and saves it
136 | let errors = checker.check("foobar rustacean").unwrap();
137 | assert!(errors.is_empty());
138 | 139 |

Languages

140 |

ispell, aspell and hunspell all allow you to specify which dictionary must be used, 141 | but they don't necessarily use the same naming scheme. ispell uses full names:

142 | 143 |
144 | let result = SpellLauncher::new()
145 |              .dictionary("american")
146 |              .launch();
147 | 148 |

hunspell uses unicode language codes:

149 | 150 |
151 | let result = SpellLauncher::new()
152 |              .hunspell()
153 |              .dictionary("en_US")
154 |              .launch();
155 | 156 |

whereas aspell accepts both versions.

157 | 158 |

Character encoding

159 |

This library tries to set encoding to utf-8, but ispell, hunspell and aspell take different arguments 160 | for that (-T, -i and --encoding, respectively). This is why 161 | you should use the ispell, aspell and hunspell methods 162 | intead of setting the command to invoke with the command method.

163 | 164 |

Requirements

165 |

rust-ispell requires the 1.12.0 (or a more recent) version of the 166 | rustc compiler, since it uses the std::sync::mpcs::Receiver::recv_timeout 167 | that was only stabilized in this version.

168 |

Structs

169 | 170 | 171 | 173 | 176 | 177 | 178 | 180 | 183 | 184 | 185 | 187 | 190 | 191 | 192 | 194 | 197 |
Error 174 |

Error type returned by methods of this library

175 |
IspellError 181 |

An ispell error, corresponding to a word that isn't in the dictonary.

182 |
SpellChecker 188 |

Spell Checker

189 |
SpellLauncher 195 |

Spell Launcher wizard (ah, ah). A builder for SpellChecker.

196 |

Enums

198 | 199 | 200 | 202 | 205 |
IspellResult 203 |

A result from ispell, corresponding to a line that is sent back for each word.

204 |

Type Definitions

206 | 207 | 208 | 210 | 213 |
Result 211 |

Result type (returned by most methods of this library)

212 |
214 | 215 | 216 | 217 | 218 | 263 | 264 | 265 | 266 | 271 | 272 | 273 | 274 | 275 | 276 | -------------------------------------------------------------------------------- /docs/ispell/ispell_result/enum.IspellResult.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../ispell/enum.IspellResult.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/ispell/ispell_result/struct.IspellError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../ispell/struct.IspellError.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/ispell/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"enum":[["IspellResult","A result from ispell, corresponding to a line that is sent back for each word."]],"struct":[["Error","Error type returned by methods of this library"],["IspellError","An ispell error, corresponding to a word that isn't in the dictonary."],["SpellChecker","Spell Checker"],["SpellLauncher","Spell Launcher wizard (ah, ah). A builder for `SpellChecker`."]],"type":[["Result","Result type (returned by most methods of this library)"]]}); -------------------------------------------------------------------------------- /docs/ispell/spell_checker/struct.SpellChecker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../ispell/struct.SpellChecker.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/ispell/spell_launcher/struct.SpellLauncher.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../ispell/struct.SpellLauncher.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/ispell/struct.Error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell::Error - Rust 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
46 |

Struct ispell::Error 47 | 48 | [] 49 | 50 | [src]

51 |
pub struct Error {
 52 |     // some fields omitted
 53 | }

Error type returned by methods of this library

54 |

Methods

impl Error
[src]

55 |

fn new<S: Into<String>>(msg: S) -> Error

56 |

Creates a new default error

57 |

fn process<S: Into<String>>(msg: S) -> Error

58 |

Create a new process error

59 | 60 |

(for errors launching Ispell)

61 |

fn utf8<S: Into<String>>(msg: S) -> Error

62 |

Create a new UTF8 error

63 | 64 |

(for errors converting to UTF8)

65 |

fn protocol<S: Into<String>>(msg: S) -> Error

66 |

Creates a new protocol error

67 | 68 |

(when we didn't understand ispell output)

69 |

fn invalid_word<S: Into<String>>(msg: S) -> Error

70 |

Creates a new invalid word error

71 | 72 |

(when the user uses illegal characters in a word)

73 |

Trait Implementations

impl PartialEq for Error
[src]

74 |

fn eq(&self, __arg_0: &Error) -> bool

75 |

This method tests for self and other values to be equal, and is used by ==. Read more

76 |

fn ne(&self, __arg_0: &Error) -> bool

77 |

This method tests for !=.

78 |

impl Debug for Error
[src]

79 |

fn fmt(&self, __arg_0: &mut Formatter) -> Result

80 |

Formats the value using the given formatter.

81 |

impl Error for Error
[src]

82 |

fn description(&self) -> &str

83 |

A short description of the error. Read more

84 |

fn cause(&self) -> Option<&Error>
1.0.0

85 |

The lower-level cause of this error, if any. Read more

86 |

impl Display for Error
[src]

87 |

fn fmt(&self, f: &mut Formatter) -> Result

88 |

Formats the value using the given formatter.

89 |

impl From<FromUtf8Error> for Error
[src]

90 |

fn from(err: FromUtf8Error) -> Error

91 |

Performs the conversion.

92 |

impl From<Error> for Error
[src]

93 |

fn from(err: Error) -> Error

94 |

Performs the conversion.

95 |
96 | 97 | 98 | 99 | 100 | 145 | 146 | 147 | 148 | 153 | 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /docs/ispell/struct.IspellError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell::IspellError - Rust 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
46 |

Struct ispell::IspellError 47 | 48 | [] 49 | 50 | [src]

51 |
pub struct IspellError {
 52 |     pub misspelled: String,
 53 |     pub position: usize,
 54 |     pub suggestions: Vec<String>,
 55 | }

An ispell error, corresponding to a word that isn't in the dictonary.

56 |

Fields

misspelled: String 57 |

The misspelled word

58 |
position: usize 59 |

The position of the word 60 | (number of characters since the beginning of the new line)

61 |
suggestions: Vec<String> 62 |

A list of suggestions

63 |

Trait Implementations

impl PartialEq for IspellError
[src]

64 |

fn eq(&self, __arg_0: &IspellError) -> bool

65 |

This method tests for self and other values to be equal, and is used by ==. Read more

66 |

fn ne(&self, __arg_0: &IspellError) -> bool

67 |

This method tests for !=.

68 |

impl Debug for IspellError
[src]

69 |

fn fmt(&self, __arg_0: &mut Formatter) -> Result

70 |

Formats the value using the given formatter.

71 |
72 | 73 | 74 | 75 | 76 | 121 | 122 | 123 | 124 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/ispell/struct.SpellChecker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell::SpellChecker - Rust 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
46 |

Struct ispell::SpellChecker 47 | 48 | [] 49 | 50 | [src]

51 |
pub struct SpellChecker {
 52 |     // some fields omitted
 53 | }

Spell Checker

54 | 55 |

Checks the spelling of a line.

56 | 57 |

Example

58 |
 59 | use ispell::SpellLauncher;
 60 | let mut checker = SpellLauncher::new().launch().unwrap();
 61 | let errors = checker.check("This should not contain any error").unwrap();
 62 | assert!(errors.is_empty());
63 |

Methods

impl SpellChecker
[src]

64 |

fn add_word_to_dictionary(&mut self, word: &str) -> Result<()>

65 |

Adds a word to your personal dictionary

66 | 67 |

The word will be saved to your words file (e.g. ~/.ispell_LANG, ~/.hunspell_LANG, or~/.aspell.LANG.pws), so it will be memorized next time you use i/a/hun/spell. If you only want to add the word to this current session, useadd_word`.

68 | 69 |

Returns

70 |

An error if word contains spaces or illegal characters

71 | 72 |

Examples

73 |

Adding a valid word

74 | 75 |
 76 | use ispell::SpellLauncher;
 77 | 
 78 | fn main() {
 79 |     let mut checker = SpellLauncher::new()
 80 |         .launch()
 81 |         .unwrap();
 82 |     
 83 |     // "rustacean" is not a valid word...
 84 |     // (unless you already ran this code example)
 85 |     let errors = checker.check("rustacean").unwrap();
 86 |     assert_eq!(errors.len(), 1);
 87 | 
 88 |     // let's add it to our personal dictionary
 89 |     checker.add_word_to_dictionary("rustacean").unwrap();
 90 | 
 91 |     // now it is a valid word
 92 |     let errors = checker.check("rustacean").unwrap();
 93 |     assert!(errors.is_empty());
 94 | }
95 |

fn add_word(&mut self, word: &str) -> Result<()>

96 |

Add a word to current session.

97 | 98 |

This word won't be memorized the next time you use i/a/hun/spell. If you want this behaviour, 99 | use add_word_to_dictionary.

100 | 101 |

Returns

102 |

An error if word contains spaces or illegal characters

103 | 104 |
105 | use ispell::SpellLauncher;
106 | 
107 | fn main() {
108 |     let mut checker = SpellLauncher::new()
109 |         .launch()
110 |         .unwrap();
111 |     
112 |     // "rustaholic" is not a valid word...
113 |     // (even if you already ran this code example)
114 |     let errors = checker.check("rustaholic").unwrap();
115 |     assert_eq!(errors.len(), 1);
116 | 
117 |     // let's add it to this session
118 |     checker.add_word("rustaholic").unwrap();
119 | 
120 |     // now it is a valid word
121 |     let errors = checker.check("rustaholic").unwrap();
122 |     assert!(errors.is_empty());
123 | }
124 |

fn check(&mut self, text: &str) -> Result<Vec<IspellError>>

125 |

Checks the spelling of a line.

126 | 127 |

This method only returns the errors that ispell detects. Since the position returned 128 | in those errors is the number of characters since the beginning of the line, this method 129 | needs to be called line by line and not on a full document.

130 |

fn check_raw(&mut self, text: &str) -> Result<Vec<IspellResult>>

131 |

Checks the spelling of a string

132 | 133 |

This method returns a vector of all ispell answers, even when 134 | there is no errors. Usually, the check method, which only returns 135 | errors, will be more useful.

136 |

Trait Implementations

impl Drop for SpellChecker
[src]

137 |

fn drop(&mut self)

138 |

A method called when the value goes out of scope. Read more

139 |
140 | 141 | 142 | 143 | 144 | 189 | 190 | 191 | 192 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /docs/ispell/struct.SpellLauncher.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell::SpellLauncher - Rust 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
46 |

Struct ispell::SpellLauncher 47 | 48 | [] 49 | 50 | [src]

51 |
pub struct SpellLauncher {
 52 |     // some fields omitted
 53 | }

Spell Launcher wizard (ah, ah). A builder for SpellChecker.

54 | 55 |

Runs ispell or one of its variant.

56 | 57 |

Examples

58 |
    59 |
  • Launches ispell with british dictionary:
  • 60 |
61 | 62 |
 63 | use ispell::SpellLauncher;
 64 | let checker = SpellLauncher::new()
 65 |               .dictionary("british")
 66 |               .launch()
 67 |               .unwrap();
68 | 69 |
    70 |
  • Launches aspell with french (France) language:
  • 71 |
72 | 73 |
 74 | use ispell::SpellLauncher;
 75 | let checker = SpellLauncher::new()
 76 |               .aspell()
 77 |               .dictionary("fr_FR")
 78 |               .launch()
 79 |               .unwrap();
80 |

Methods

impl SpellLauncher
[src]

81 |

fn new() -> SpellLauncher

82 |

Creates a new spell checker with default options

83 |

fn aspell(&mut self) -> &mut SpellLauncher

84 |

Sets mode to aspell instead of ispell.

85 | 86 |

Will run aspell as the command if it is not set

87 |

fn hunspell(&mut self) -> &mut SpellLauncher

88 |

Sets compatibility mode to hunspell instead of ispell.

89 | 90 |

Will run hunspell as the command if it is not set

91 |

fn ispell(&mut self) -> &mut SpellLauncher

92 |

Sets compatibility mode to ispell

93 | 94 |

Will run ispell as the command if it is not set 95 | (default setting)

96 |

fn timeout(&mut self, timeout: u64) -> &mut SpellLauncher

97 |

Sets the timeout when checking ispell

98 | 99 |

If the spawned process takes longer than this timeout to answer to a query, 100 | it will be killed and an error will be returned, preventing your program 101 | from freezing indefinitely.

102 | 103 |

The timeout is set in milliseconds, and is 1000 (a second) by default.

104 |

fn command<S: Into<String>>(&mut self, command: S) -> &mut SpellLauncher

105 |

Set the name of the command to run

106 | 107 |

By default, it inferred from the mode (which is ispell by default).

108 | 109 |

Unless you want to run a specific (ispell-compatible) command, you shouldn't use this method directly, but rather 110 | use the aspell or hunspell methods, since this also allow the the library to know which actual program 111 | is runned and to set encoding options accordingly.

112 |

fn dictionary<S: Into<String>>(&mut self, lang: S) -> &mut SpellLauncher

113 |

Determine the dictionary that should be used.

114 | 115 |

Note that ispell, hunspell and aspell have different naming schemes:

116 | 117 |
    118 |
  • ispell accepts full names, e.g. "american", "british", "french", ...
  • 119 |
  • hunspell accepts unicode language codes, e.g. "fr_FR", "en_GB", ...
  • 120 |
  • aspell accepts both.
  • 121 |
122 | 123 |

Example

124 |
125 | use ispell::SpellLauncher;
126 | let checker = SpellLauncher::new()
127 |               .aspell()
128 |               .dictionary("en_GB")
129 |               .launch()
130 |               .unwrap();
131 |

fn launch(&self) -> Result<SpellChecker>

132 |

Launch ispell (or aspell or hunspell) and return a SpellChecker

133 |

Trait Implementations

impl Debug for SpellLauncher
[src]

134 |

fn fmt(&self, __arg_0: &mut Formatter) -> Result

135 |

Formats the value using the given formatter.

136 |
137 | 138 | 139 | 140 | 141 | 186 | 187 | 188 | 189 | 194 | 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /docs/ispell/type.Result.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell::Result - Rust 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
46 |

ispell::Result 47 | 48 | [] 49 | 50 | [src]

51 |
type Result<T> = Result<T, Error>;

Result type (returned by most methods of this library)

52 |
53 | 54 | 55 | 56 | 57 | 102 | 103 | 104 | 105 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /docs/main.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 The Rust Project Developers. See the COPYRIGHT 3 | * file at the top-level directory of this distribution and at 4 | * http://rust-lang.org/COPYRIGHT. 5 | * 6 | * Licensed under the Apache License, Version 2.0 or the MIT license 8 | * , at your 9 | * option. This file may not be copied, modified, or distributed 10 | * except according to those terms. 11 | */ 12 | 13 | /* General structure and fonts */ 14 | 15 | body { 16 | background-color: white; 17 | color: black; 18 | } 19 | 20 | h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { 21 | color: black; 22 | } 23 | h1.fqn { 24 | border-bottom-color: #D5D5D5; 25 | } 26 | h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { 27 | border-bottom-color: #DDDDDD; 28 | } 29 | .in-band, code { 30 | background-color: white; 31 | } 32 | 33 | div.stability > em > code { 34 | background-color: initial; 35 | } 36 | 37 | .docblock code { 38 | background-color: #F5F5F5; 39 | } 40 | pre { 41 | background-color: #F5F5F5; 42 | } 43 | 44 | .sidebar .location { 45 | background: #e1e1e1; 46 | color: #333; 47 | } 48 | 49 | .block a:hover { 50 | background: #F5F5F5; 51 | } 52 | 53 | .line-numbers span { color: #c67e2d; } 54 | .line-numbers .line-highlighted { 55 | background-color: #f6fdb0 !important; 56 | } 57 | 58 | :target { background: #FDFFD3; } 59 | .content .highlighted { 60 | color: #000 !important; 61 | background-color: #ccc; 62 | } 63 | .content .highlighted a, .content .highlighted span { color: #000 !important; } 64 | .content .highlighted.trait { background-color: #fece7e; } 65 | .content .highlighted.mod { background-color: #afc6e4; } 66 | .content .highlighted.enum { background-color: #b4d1b9; } 67 | .content .highlighted.struct { background-color: #e7b1a0; } 68 | .content .highlighted.fn { background-color: #c6afb3; } 69 | .content .highlighted.method { background-color: #c6afb3; } 70 | .content .highlighted.tymethod { background-color: #c6afb3; } 71 | .content .highlighted.type { background-color: #c6afb3; } 72 | 73 | .docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { 74 | border-bottom-color: #DDD; 75 | } 76 | 77 | .docblock table { 78 | border-color: #ddd; 79 | } 80 | 81 | .docblock table td { 82 | border-top-color: #ddd; 83 | border-bottom-color: #ddd; 84 | } 85 | 86 | .docblock table th { 87 | border-top-color: #ddd; 88 | border-bottom-color: #ddd; 89 | } 90 | 91 | .content span.primitive, .content a.primitive, .block a.current.primitive { color: #39a7bf; } 92 | .content span.externcrate, 93 | .content span.mod, .content a.mod, .block a.current.mod { color: #4d76ae; } 94 | .content span.fn, .content a.fn, .block a.current.fn, 95 | .content span.method, .content a.method, .block a.current.method, 96 | .content span.tymethod, .content a.tymethod, .block a.current.tymethod, 97 | .content .fnname { color: #8c6067; } 98 | 99 | pre.rust .comment { color: #8E908C; } 100 | pre.rust .doccomment { color: #4D4D4C; } 101 | 102 | nav { 103 | border-bottom-color: #e0e0e0; 104 | } 105 | nav.main .current { 106 | border-top-color: #000; 107 | border-bottom-color: #000; 108 | } 109 | nav.main .separator { 110 | border-color: 1px solid #000; 111 | } 112 | a { 113 | color: #000; 114 | } 115 | 116 | .docblock a, .stability a { 117 | color: #3873AD; 118 | } 119 | 120 | a.test-arrow { 121 | color: #f5f5f5; 122 | } 123 | 124 | .content span.trait, .content a.trait, .block a.current.trait { color: #7c5af3; } 125 | 126 | .search-input { 127 | color: #555; 128 | box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent; 129 | background-color: white; 130 | } 131 | 132 | em.stab.unstable { background: #FFF5D6; border-color: #FFC600; } 133 | em.stab.deprecated { background: #F3DFFF; border-color: #7F0087; } 134 | -------------------------------------------------------------------------------- /docs/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.0 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} 2 | -------------------------------------------------------------------------------- /docs/playpen.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT 2 | // file at the top-level directory of this distribution and at 3 | // http://rust-lang.org/COPYRIGHT. 4 | // 5 | // Licensed under the Apache License, Version 2.0 or the MIT license 7 | // , at your 8 | // option. This file may not be copied, modified, or distributed 9 | // except according to those terms. 10 | 11 | /*jslint browser: true, es5: true */ 12 | /*globals $: true, rootPath: true */ 13 | 14 | document.addEventListener('DOMContentLoaded', function() { 15 | 'use strict'; 16 | 17 | if (!window.playgroundUrl) { 18 | return; 19 | } 20 | 21 | var featureRegexp = new RegExp('^\s*#!\\[feature\\(\.*?\\)\\]'); 22 | var elements = document.querySelectorAll('pre.rust-example-rendered'); 23 | 24 | Array.prototype.forEach.call(elements, function(el) { 25 | el.onmouseover = function(e) { 26 | if (el.contains(e.relatedTarget)) { 27 | return; 28 | } 29 | 30 | var a = document.createElement('a'); 31 | a.setAttribute('class', 'test-arrow'); 32 | a.textContent = 'Run'; 33 | 34 | var code = el.previousElementSibling.textContent; 35 | 36 | var channel = ''; 37 | if (featureRegexp.test(code)) { 38 | channel = '&version=nightly'; 39 | } 40 | 41 | a.setAttribute('href', window.playgroundUrl + '?code=' + 42 | encodeURIComponent(code) + channel); 43 | a.setAttribute('target', '_blank'); 44 | 45 | el.appendChild(a); 46 | }; 47 | 48 | el.onmouseout = function(e) { 49 | if (el.contains(e.relatedTarget)) { 50 | return; 51 | } 52 | 53 | el.removeChild(el.querySelectorAll('a.test-arrow')[0]); 54 | }; 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /docs/search-index.js: -------------------------------------------------------------------------------- 1 | var searchIndex = {}; 2 | searchIndex["ispell"] = {"doc":"This library provides an interface for easily calling the `ispell`, `aspell`\nor `hunspell` command from Rust programs.","items":[[3,"IspellError","ispell","An ispell error, corresponding to a word that isn't in the dictonary.",null,null],[12,"misspelled","","The misspelled word",0,null],[12,"position","","The position of the word\n(number of characters since the beginning of the new line)",0,null],[12,"suggestions","","A list of suggestions",0,null],[3,"SpellChecker","","Spell Checker",null,null],[3,"SpellLauncher","","Spell Launcher wizard (ah, ah). A builder for `SpellChecker`.",null,null],[3,"Error","","Error type returned by methods of this library",null,null],[4,"IspellResult","","A result from ispell, corresponding to a line that is sent back for each word.",null,null],[13,"Ok","","The word was found in the dictionnary.",1,null],[13,"Root","","The word wasn't found, but a root word was found.",1,null],[13,"Compound","","The word wasn't found, but corresponds to the concatenation of two words",1,null],[13,"Miss","","The word wasn't found, but there are near misses",1,null],[13,"Guess","","The word wasn't found, but could be formed by adding illegal affixes to a known root",1,null],[13,"None","","The word wasn't found in the dictionnary and there are no suggestions",1,null],[11,"add_word_to_dictionary","","Adds a word to your personal dictionary",2,null],[11,"add_word","","Add a word to current session.",2,null],[11,"check","","Checks the spelling of a line.",2,null],[11,"check_raw","","Checks the spelling of a string",2,null],[11,"drop","","",2,null],[11,"fmt","","",3,null],[11,"new","","Creates a new spell checker with default options",3,{"inputs":[],"output":{"name":"spelllauncher"}}],[11,"aspell","","Sets mode to aspell instead of ispell.",3,null],[11,"hunspell","","Sets compatibility mode to hunspell instead of ispell.",3,null],[11,"ispell","","Sets compatibility mode to ispell",3,null],[11,"timeout","","Sets the timeout when checking ispell",3,null],[11,"command","","Set the name of the command to run",3,null],[11,"dictionary","","Determine the dictionary that should be used.",3,null],[11,"launch","","Launch `ispell` (or `aspell` or `hunspell`) and return a `SpellChecker`",3,null],[11,"eq","","",4,null],[11,"ne","","",4,null],[11,"fmt","","",4,null],[11,"new","","Creates a new default error",4,{"inputs":[{"name":"s"}],"output":{"name":"error"}}],[11,"process","","Create a new process error",4,{"inputs":[{"name":"s"}],"output":{"name":"error"}}],[11,"utf8","","Create a new UTF8 error",4,{"inputs":[{"name":"s"}],"output":{"name":"error"}}],[11,"protocol","","Creates a new protocol error",4,{"inputs":[{"name":"s"}],"output":{"name":"error"}}],[11,"invalid_word","","Creates a new invalid word error",4,{"inputs":[{"name":"s"}],"output":{"name":"error"}}],[11,"description","","",4,null],[11,"fmt","","",4,null],[11,"from","","",4,{"inputs":[{"name":"fromutf8error"}],"output":{"name":"error"}}],[11,"from","","",4,{"inputs":[{"name":"error"}],"output":{"name":"error"}}],[11,"eq","","",0,null],[11,"ne","","",0,null],[11,"fmt","","",0,null],[11,"eq","","",1,null],[11,"ne","","",1,null],[11,"fmt","","",1,null],[6,"Result","","Result type (returned by most methods of this library)",null,null]],"paths":[[3,"IspellError"],[4,"IspellResult"],[3,"SpellChecker"],[3,"SpellLauncher"],[3,"Error"]]}; 3 | initSearch(searchIndex); 4 | -------------------------------------------------------------------------------- /docs/src/ispell/src/async_reader.rs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | async_reader.rs.html -- source 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
 1
 46 |  2
 47 |  3
 48 |  4
 49 |  5
 50 |  6
 51 |  7
 52 |  8
 53 |  9
 54 | 10
 55 | 11
 56 | 12
 57 | 13
 58 | 14
 59 | 15
 60 | 16
 61 | 17
 62 | 18
 63 | 19
 64 | 20
 65 | 21
 66 | 22
 67 | 23
 68 | 24
 69 | 25
 70 | 26
 71 | 27
 72 | 28
 73 | 29
 74 | 30
 75 | 31
 76 | 32
 77 | 33
 78 | 34
 79 | 35
 80 | 36
 81 | 37
 82 | 38
 83 | 39
 84 | 40
 85 | 41
 86 | 42
 87 | 43
 88 | 44
 89 | 45
 90 | 46
 91 | 47
 92 | 48
 93 | 49
 94 | 50
 95 | 51
 96 | 52
 97 | 53
 98 | 54
 99 | 55
100 | 56
101 | 57
102 | 
103 | // This Source Code Form is subject to the terms of the Mozilla Public
104 | // License, v. 2.0. If a copy of the MPL was not distributed with
105 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/.
106 | 
107 | use std::process::ChildStdout;
108 | use std::io::Read;
109 | use std::sync::mpsc::Sender;
110 | 
111 | use error::Result;
112 | 
113 | const BUF_LEN: usize = 42;
114 | 
115 | /// An asynchronous reader, that reads from a spawned command stdout
116 | /// and sends it to a channel
117 | pub struct AsyncReader {
118 |     stdout: ChildStdout,
119 |     sender: Sender<Result<String>>,
120 | 
121 | }
122 | 
123 | impl AsyncReader {
124 |     /// Create a new AsyncReader
125 |     pub fn new(stdout: ChildStdout, sender: Sender<Result<String>>) -> AsyncReader {
126 |         AsyncReader {
127 |             stdout: stdout,
128 |             sender: sender,
129 |         }
130 |     }
131 |     
132 |     /// Reads the output from ispell and sends it over the channel
133 |     pub fn read_loop(&mut self)  {
134 |         loop {
135 |             let result = self.read();
136 |             match self.sender.send(result) {
137 |                 Ok(_) => (),
138 |                 Err(_) => break, // main process was aborted
139 |             }
140 |         }
141 |     }
142 | 
143 |     /// Reads a string
144 |     fn read(&mut self) -> Result<String> {
145 |         let mut buffer = [0; BUF_LEN];
146 |         let mut output = vec!();
147 |         loop {
148 |             let n = try!(self.stdout.read(&mut buffer));
149 |             output.extend_from_slice(&buffer[0..n]);
150 |             if n < BUF_LEN {
151 |                 break;
152 |             } else {
153 |                 continue;
154 |             }
155 |         }
156 |         let s = try!(String::from_utf8(output));
157 |         Ok(s)
158 |     }
159 | }
160 | 
161 |
162 | 163 | 164 | 165 | 166 | 211 | 212 | 213 | 214 | 219 | 220 | 221 | 222 | 223 | 224 | -------------------------------------------------------------------------------- /docs/src/ispell/src/error.rs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | error.rs.html -- source 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
  1
 46 |   2
 47 |   3
 48 |   4
 49 |   5
 50 |   6
 51 |   7
 52 |   8
 53 |   9
 54 |  10
 55 |  11
 56 |  12
 57 |  13
 58 |  14
 59 |  15
 60 |  16
 61 |  17
 62 |  18
 63 |  19
 64 |  20
 65 |  21
 66 |  22
 67 |  23
 68 |  24
 69 |  25
 70 |  26
 71 |  27
 72 |  28
 73 |  29
 74 |  30
 75 |  31
 76 |  32
 77 |  33
 78 |  34
 79 |  35
 80 |  36
 81 |  37
 82 |  38
 83 |  39
 84 |  40
 85 |  41
 86 |  42
 87 |  43
 88 |  44
 89 |  45
 90 |  46
 91 |  47
 92 |  48
 93 |  49
 94 |  50
 95 |  51
 96 |  52
 97 |  53
 98 |  54
 99 |  55
100 |  56
101 |  57
102 |  58
103 |  59
104 |  60
105 |  61
106 |  62
107 |  63
108 |  64
109 |  65
110 |  66
111 |  67
112 |  68
113 |  69
114 |  70
115 |  71
116 |  72
117 |  73
118 |  74
119 |  75
120 |  76
121 |  77
122 |  78
123 |  79
124 |  80
125 |  81
126 |  82
127 |  83
128 |  84
129 |  85
130 |  86
131 |  87
132 |  88
133 |  89
134 |  90
135 |  91
136 |  92
137 |  93
138 |  94
139 |  95
140 |  96
141 |  97
142 |  98
143 |  99
144 | 100
145 | 101
146 | 102
147 | 103
148 | 104
149 | 
150 | // This Source Code Form is subject to the terms of the Mozilla Public
151 | // License, v. 2.0. If a copy of the MPL was not distributed with
152 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/.
153 | 
154 | use std::error;
155 | use std::result;
156 | use std::fmt;
157 | use std::string::FromUtf8Error;
158 | use std::io;
159 | 
160 | /// Internal ErrorType
161 | #[derive(Debug, PartialEq)]
162 | enum ErrorType {
163 |     /// Default
164 |     Default,
165 |     Process,
166 |     Utf8,
167 |     Protocol,
168 |     InvalidWord,
169 | }
170 | 
171 | /// Result type (returned by most methods of this library)
172 | pub type Result<T> = result::Result<T, Error>;
173 | 
174 | #[derive(Debug, PartialEq)]
175 | /// Error type returned by methods of this library
176 | pub struct Error {
177 |     msg: String,
178 |     variant: ErrorType
179 | }
180 | 
181 | impl Error {
182 |     /// Creates a new default error
183 |     pub fn new<S: Into<String>>(msg: S) -> Error {
184 |         Error {
185 |             msg: msg.into(),
186 |             variant: ErrorType::Default,
187 |         }
188 |     }
189 | 
190 |     /// Create a new process error
191 |     ///
192 |     /// (for errors launching Ispell)
193 |     pub fn process<S: Into<String>>(msg: S) -> Error {
194 |         Error {
195 |             msg: msg.into(),
196 |             variant: ErrorType::Process
197 |         }
198 |     }
199 | 
200 |     /// Create a new UTF8 error
201 |     ///
202 |     /// (for errors converting to UTF8)
203 |     pub fn utf8<S: Into<String>>(msg: S) -> Error {
204 |         Error {
205 |             msg: msg.into(),
206 |             variant: ErrorType::Utf8,
207 |         }
208 |     }
209 | 
210 |     /// Creates a new protocol error
211 |     ///
212 |     /// (when we didn't understand ispell output)
213 |     pub fn protocol<S: Into<String>>(msg: S) -> Error {
214 |         Error {
215 |             msg: msg.into(),
216 |             variant: ErrorType::Protocol,
217 |         }
218 |     }
219 | 
220 |     /// Creates a new invalid word error
221 |     ///
222 |     /// (when the user uses illegal characters in a word)
223 |     pub fn invalid_word<S: Into<String>>(msg: S) -> Error {
224 |         Error {
225 |             msg: msg.into(),
226 |             variant: ErrorType::InvalidWord,
227 |         }
228 |     }
229 | }
230 | 
231 | impl error::Error for Error {
232 |     fn description(&self) -> &str {
233 |         &self.msg
234 |     }
235 | }
236 | 
237 | impl fmt::Display for Error {
238 |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
239 |         write!(f, "{}", self.msg)
240 |     }
241 | }
242 | 
243 | impl From<FromUtf8Error> for Error {
244 |     fn from(err: FromUtf8Error) -> Error {
245 |         Error::utf8(format!("error decoding ispell output to utf8: {}", err))
246 |     }
247 | }
248 | 
249 | impl From<io::Error> for Error {
250 |     fn from(err: io::Error) -> Error {
251 |         Error::process(format!("error while reading/writing to ispell: {}", err))
252 |     }
253 | }
254 | 
255 |
256 | 257 | 258 | 259 | 260 | 305 | 306 | 307 | 308 | 313 | 314 | 315 | 316 | 317 | 318 | -------------------------------------------------------------------------------- /docs/src/ispell/src/ispell_result.rs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ispell_result.rs.html -- source 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 33 | 34 | 44 | 45 |
 1
 46 |  2
 47 |  3
 48 |  4
 49 |  5
 50 |  6
 51 |  7
 52 |  8
 53 |  9
 54 | 10
 55 | 11
 56 | 12
 57 | 13
 58 | 14
 59 | 15
 60 | 16
 61 | 17
 62 | 18
 63 | 19
 64 | 20
 65 | 21
 66 | 22
 67 | 23
 68 | 24
 69 | 25
 70 | 26
 71 | 27
 72 | 28
 73 | 29
 74 | 30
 75 | 31
 76 | 32
 77 | 33
 78 | 34
 79 | 35
 80 | 36
 81 | 37
 82 | 38
 83 | 39
 84 | 40
 85 | 41
 86 | 42
 87 | 43
 88 | 44
 89 | 45
 90 | 46
 91 | 47
 92 | 48
 93 | 49
 94 | 50
 95 | 51
 96 | 52
 97 | 53
 98 | 54
 99 | 
100 | // This Source Code Form is subject to the terms of the Mozilla Public
101 | // License, v. 2.0. If a copy of the MPL was not distributed with
102 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/.
103 | 
104 | 
105 | /// An ispell error, corresponding to a word that isn't in the dictonary.
106 | #[derive(Debug, PartialEq)]
107 | pub struct IspellError {
108 |     /// The misspelled word
109 |     pub misspelled: String,
110 | 
111 |     /// The position of the word
112 |     /// (number of characters since the beginning of the new line)
113 |     pub position: usize,
114 | 
115 |     /// A list of suggestions
116 |     pub suggestions: Vec<String>,
117 | }
118 | 
119 | /// A result from ispell, corresponding to a line that is sent back for each word.
120 | ///
121 | /// See the manpage `ispell(1)` for more informations about the meaning of each variant.
122 | #[derive(Debug, PartialEq)]
123 | pub enum IspellResult {
124 |     /// The word was found in the dictionnary.
125 |     ///
126 |     /// Corresponds to '*'
127 |     Ok,
128 |     
129 |     /// The word wasn't found, but a root word was found.
130 |     /// 
131 |     /// Corresponds to '+'
132 |     Root(String),
133 | 
134 |     /// The word wasn't found, but corresponds to the concatenation of two words
135 |     ///
136 |     /// Corresponds to '-'
137 |     Compound,
138 | 
139 |     /// The word wasn't found, but there are near misses
140 |     ///
141 |     /// Corresponds to '&'
142 |     Miss(IspellError),
143 | 
144 |     /// The word wasn't found, but could be formed by adding illegal affixes to a known root
145 |     ///
146 |     /// Corresponds to '?'
147 |     Guess(IspellError),
148 | 
149 |     /// The word wasn't found in the dictionnary and there are no suggestions
150 |     ///
151 |     /// Corresponds to '#'
152 |     None(IspellError),
153 | }
154 | 
155 |
156 | 157 | 158 | 159 | 160 | 205 | 206 | 207 | 208 | 213 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /examples/dict.rs: -------------------------------------------------------------------------------- 1 | extern crate ispell; 2 | use ispell::SpellLauncher; 3 | 4 | fn main() { 5 | let mut checker = SpellLauncher::new() 6 | .launch() 7 | .unwrap(); 8 | 9 | // "foobar" is not a valid word... 10 | let errors = checker.check("foobar").unwrap(); 11 | println!("errors: {:?}", errors); 12 | assert_eq!(errors.len(), 1); 13 | 14 | // let's add it 15 | checker.add_word("foobar").unwrap(); 16 | let errors = checker.check("foobar").unwrap(); 17 | println!("errors: {:?}", errors); 18 | assert!(errors.is_empty()); 19 | } 20 | -------------------------------------------------------------------------------- /examples/readme.rs: -------------------------------------------------------------------------------- 1 | extern crate ispell; 2 | use ispell::SpellLauncher; 3 | 4 | fn main() { 5 | let mut checker = SpellLauncher::new() 6 | .aspell() 7 | .command("aspell") 8 | .dictionary("en") 9 | .launch() 10 | .unwrap(); 11 | let errors = checker.check("A simpel test to to see if it detetcs typing errors").unwrap(); 12 | for e in errors { 13 | println!("'{}' (pos: {}) is misspelled!", &e.misspelled, e.position); 14 | if !e.suggestions.is_empty() { 15 | println!("Maybe you meant '{}'?", &e.suggestions[0]); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/simple.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with 3 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | extern crate ispell; 6 | use ispell::{SpellLauncher, IspellError}; 7 | 8 | fn display(errors: &[IspellError]) { 9 | if errors.is_empty() { 10 | println!("No error, congratulations!"); 11 | } else { 12 | for e in errors { 13 | print!("'{}' (at pos {}) is misspelled.", e.misspelled, e.position); 14 | if !e.suggestions.is_empty() { 15 | print!(" Maybe you meant '{}'?", e.suggestions[0]); 16 | } 17 | println!(""); 18 | } 19 | } 20 | } 21 | 22 | fn main() { 23 | let checker = SpellLauncher::new() 24 | .dictionary("en_GB") 25 | .command("hunspell") 26 | .launch(); 27 | match checker { 28 | Ok(mut checker) => { 29 | let res = checker.check("test of a msitake").unwrap(); 30 | display(&res); 31 | let res = checker.check("test without mistake (?)").unwrap(); 32 | display(&res); 33 | let res = checker.check("Another test wiht a mistake").unwrap(); 34 | display(&res); 35 | }, 36 | Err(err) => println!("Error: {}", err) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/sleep.sh: -------------------------------------------------------------------------------- 1 | sleep 10 2 | -------------------------------------------------------------------------------- /examples/timeout.rs: -------------------------------------------------------------------------------- 1 | extern crate ispell; 2 | use ispell::SpellLauncher; 3 | 4 | fn main() { 5 | let checker = SpellLauncher::new() 6 | .command("examples/sleep.sh") 7 | .timeout(5) 8 | .launch(); 9 | assert!(checker.is_err()); 10 | if let Err(err) = checker { 11 | println!("{}", err); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/async_reader.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with 3 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use std::process::ChildStdout; 6 | use std::io::{BufReader, BufRead}; 7 | use std::sync::mpsc::Sender; 8 | 9 | use error::Result; 10 | 11 | 12 | /// An asynchronous reader, that reads from a spawned command stdout 13 | /// and sends it to a channel 14 | pub struct AsyncReader { 15 | stdout: BufReader, 16 | sender: Sender>, 17 | } 18 | 19 | impl AsyncReader { 20 | /// Create a new AsyncReader 21 | pub fn new(stdout: ChildStdout, sender: Sender>) -> AsyncReader { 22 | AsyncReader { 23 | stdout: BufReader::new(stdout), 24 | sender: sender, 25 | } 26 | } 27 | 28 | /// Reads the output from ispell and sends it over the channel 29 | pub fn read_loop(&mut self) { 30 | loop { 31 | let result = self.read(); 32 | match self.sender.send(result) { 33 | Ok(_) => (), 34 | Err(_) => break, // main process was aborted 35 | } 36 | } 37 | } 38 | 39 | /// Reads a string 40 | fn read(&mut self) -> Result { 41 | let mut output = String::new(); 42 | loop { 43 | self.stdout.read_line(&mut output)?; 44 | if output.ends_with("\n\n") || output == "\n" || output.starts_with("@") { 45 | break; 46 | } 47 | } 48 | Ok(output) 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with 3 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use std::error; 6 | use std::result; 7 | use std::fmt; 8 | use std::string::FromUtf8Error; 9 | use std::io; 10 | 11 | /// Internal ErrorType 12 | #[derive(Debug, PartialEq)] 13 | enum ErrorType { 14 | /// Default 15 | Default, 16 | Process, 17 | Utf8, 18 | Protocol, 19 | InvalidWord, 20 | } 21 | 22 | /// Result type (returned by most methods of this library) 23 | pub type Result = result::Result; 24 | 25 | #[derive(Debug, PartialEq)] 26 | /// Error type returned by methods of this library 27 | pub struct Error { 28 | msg: String, 29 | variant: ErrorType 30 | } 31 | 32 | impl Error { 33 | /// Creates a new default error 34 | pub fn new>(msg: S) -> Error { 35 | Error { 36 | msg: msg.into(), 37 | variant: ErrorType::Default, 38 | } 39 | } 40 | 41 | /// Create a new process error 42 | /// 43 | /// (for errors launching Ispell) 44 | pub fn process>(msg: S) -> Error { 45 | Error { 46 | msg: msg.into(), 47 | variant: ErrorType::Process 48 | } 49 | } 50 | 51 | /// Create a new UTF8 error 52 | /// 53 | /// (for errors converting to UTF8) 54 | pub fn utf8>(msg: S) -> Error { 55 | Error { 56 | msg: msg.into(), 57 | variant: ErrorType::Utf8, 58 | } 59 | } 60 | 61 | /// Creates a new protocol error 62 | /// 63 | /// (when we didn't understand ispell output) 64 | pub fn protocol>(msg: S) -> Error { 65 | Error { 66 | msg: msg.into(), 67 | variant: ErrorType::Protocol, 68 | } 69 | } 70 | 71 | /// Creates a new invalid word error 72 | /// 73 | /// (when the user uses illegal characters in a word) 74 | pub fn invalid_word>(msg: S) -> Error { 75 | Error { 76 | msg: msg.into(), 77 | variant: ErrorType::InvalidWord, 78 | } 79 | } 80 | } 81 | 82 | impl error::Error for Error { 83 | fn description(&self) -> &str { 84 | &self.msg 85 | } 86 | } 87 | 88 | impl fmt::Display for Error { 89 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 90 | write!(f, "{}", self.msg) 91 | } 92 | } 93 | 94 | impl From for Error { 95 | fn from(err: FromUtf8Error) -> Error { 96 | Error::utf8(format!("error decoding ispell output to utf8: {}", err)) 97 | } 98 | } 99 | 100 | impl From for Error { 101 | fn from(err: io::Error) -> Error { 102 | Error::process(format!("error while reading/writing to ispell: {}", err)) 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/ispell_result.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with 3 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | 6 | /// An ispell error, corresponding to a word that isn't in the dictonary. 7 | #[derive(Debug, PartialEq)] 8 | pub struct IspellError { 9 | /// The misspelled word 10 | pub misspelled: String, 11 | 12 | /// The position of the word 13 | /// (number of characters since the beginning of the new line) 14 | pub position: usize, 15 | 16 | /// A list of suggestions 17 | pub suggestions: Vec, 18 | } 19 | 20 | /// A result from ispell, corresponding to a line that is sent back for each word. 21 | /// 22 | /// See the manpage `ispell(1)` for more informations about the meaning of each variant. 23 | #[derive(Debug, PartialEq)] 24 | pub enum IspellResult { 25 | /// The word was found in the dictionnary. 26 | /// 27 | /// Corresponds to '*' 28 | Ok, 29 | 30 | /// The word wasn't found, but a root word was found. 31 | /// 32 | /// Corresponds to '+' 33 | Root(String), 34 | 35 | /// The word wasn't found, but corresponds to the concatenation of two words 36 | /// 37 | /// Corresponds to '-' 38 | Compound, 39 | 40 | /// The word wasn't found, but there are near misses 41 | /// 42 | /// Corresponds to '&' 43 | Miss(IspellError), 44 | 45 | /// The word wasn't found, but could be formed by adding illegal affixes to a known root 46 | /// 47 | /// Corresponds to '?' 48 | Guess(IspellError), 49 | 50 | /// The word wasn't found in the dictionnary and there are no suggestions 51 | /// 52 | /// Corresponds to '#' 53 | None(IspellError), 54 | } 55 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with 3 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | //! This library provides an interface for easily calling the `ispell`, `aspell` 6 | //! or `hunspell` command from Rust programs. 7 | //! 8 | //! # Example 9 | //! 10 | //! ``` 11 | //! use ispell::SpellLauncher; 12 | //! let mut checker = SpellLauncher::new() 13 | //! .aspell() 14 | //! .launch() 15 | //! .unwrap(); 16 | //! let errors = checker.check("Testing iff if it works").unwrap(); 17 | //! assert_eq!(&errors[0].misspelled, "iff"); 18 | //! assert_eq!(errors[0].position, 8); 19 | //! ``` 20 | //! 21 | //! # The `SpellLauncher` 22 | //! 23 | //! You can set the command that will be called by using the `aspell`, `hunspell` and 24 | //! `ispell` (default value) methods: 25 | //! 26 | //! ``` 27 | //! # use ispell::SpellLauncher; 28 | //! let result = SpellLauncher::new() 29 | //! .aspell() 30 | //! .launch(); 31 | //! ``` 32 | //! 33 | //! ``` 34 | //! # use ispell::SpellLauncher; 35 | //! let result = SpellLauncher::new() 36 | //! .hunspell() 37 | //! .launch(); 38 | //! ``` 39 | //! 40 | //! You can also set the dictionary that must be used: 41 | //! 42 | //! ``` 43 | //! # use ispell::SpellLauncher; 44 | //! let checker = SpellLauncher::new() 45 | //! .aspell() 46 | //! .dictionary("en_GB") 47 | //! .launch() 48 | //! .unwrap(); 49 | //! ``` 50 | //! 51 | //! # The `SpellChecker` 52 | //! 53 | //! If the command has been launched successfully, it will return a `SpellChecker`. 54 | //! 55 | //! ## Checking words 56 | //! 57 | //! The main usage of this struct is using the `check` method to get 58 | //! the errors (`IspellError`) the spell checker detects. The `ispell` 59 | //! API returns the position (in 60 | //! characters) from the beginning of the line. This means that, if 61 | //! you want to be able do to anything with these numbers, you'll have 62 | //! to call `check` line by line. 63 | //! 64 | //! This method returns a list of `IspellError`s, containing: 65 | //! 66 | //! * the misspelled word; 67 | //! * the position (number of characters since the beginning of the 68 | //! line); 69 | //! * a (possibly empty) list of suggestions. 70 | //! 71 | //! ``` 72 | //! # use ispell::SpellLauncher; 73 | //! let mut checker = SpellLauncher::new() 74 | //! .launch() 75 | //! .unwrap(); 76 | //! let errors = checker.check("Does thit message contain any erors?").unwrap(); 77 | //! for e in errors { 78 | //! println!("{} was misspelled at pos {}.", e.misspelled, e.position); 79 | //! println!("There are {} suggestions for alternatives", e.suggestions.len()); 80 | //! } 81 | //! ``` 82 | //! 83 | //! `SpellChecker` also provides the `check_raw` method, whose behaviour mimics more closely 84 | //! ispell's output. 85 | //! 86 | //! ## Adding words 87 | //! 88 | //! There are two methods to add words so they are no more detected as errors: 89 | //! 90 | //! * `add_word` adds a word to this current session, but doesn't save it; 91 | //! * `add_word_to_dictionary` adds a word to your personal dictionary, saving it for 92 | //! next sessions. 93 | //! 94 | //! ``` 95 | //! # use ispell::SpellLauncher; 96 | //! let mut checker = SpellLauncher::new() 97 | //! .launch() 98 | //! .unwrap(); 99 | //! checker.add_word("foobar"); // Add a word only to this session 100 | //! checker.add_word_to_dictionary("rustacean"); // Add a word and saves it 101 | //! let errors = checker.check("foobar rustacean").unwrap(); 102 | //! assert!(errors.is_empty()); 103 | //! ``` 104 | //! 105 | //! # Languages 106 | //! 107 | //! `ispell`, `aspell` and `hunspell` all allow you to specify which dictionary must be used, 108 | //! but they don't necessarily use the same naming scheme. `ispell` uses full names: 109 | //! 110 | //! ``` 111 | //! # use ispell::SpellLauncher; 112 | //! let result = SpellLauncher::new() 113 | //! .dictionary("american") 114 | //! .launch(); 115 | //! ``` 116 | //! 117 | //! `hunspell` uses unicode language codes: 118 | //! 119 | //! ``` 120 | //! # use ispell::SpellLauncher; 121 | //! let result = SpellLauncher::new() 122 | //! .hunspell() 123 | //! .dictionary("en_US") 124 | //! .launch(); 125 | //! ``` 126 | //! 127 | //! whereas `aspell` accepts both versions. 128 | //! 129 | //! # Character encoding 130 | //! 131 | //! This library tries to set encoding to `utf-8`, but ispell, hunspell and aspell take different arguments 132 | //! for that (`-T`, `-i` and `--encoding`, respectively). This is why 133 | //! you should use the `ispell`, `aspell` and `hunspell` methods 134 | //! intead of setting the command to invoke with the `command` method. 135 | //! 136 | //! # Requirements 137 | //! 138 | //! `rust-ispell` requires the `1.12.0` (or a more recent) version of the 139 | //! `rustc` compiler, since it uses the `std::sync::mpcs::Receiver::recv_timeout` 140 | //! that was only stabilized in this version. 141 | 142 | mod spell_checker; 143 | mod spell_launcher; 144 | mod error; 145 | mod ispell_result; 146 | mod async_reader; 147 | 148 | pub use ispell_result::IspellResult; 149 | pub use ispell_result::IspellError; 150 | pub use spell_checker::SpellChecker; 151 | pub use spell_launcher::SpellLauncher; 152 | pub use error::Error; 153 | pub use error::Result; 154 | -------------------------------------------------------------------------------- /src/spell_checker.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with 3 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use std::process::{Child, ChildStdin}; 6 | use std::io::Write; 7 | use std::time::Duration; 8 | use std::thread; 9 | use std::sync::mpsc::{channel, Receiver, TryRecvError}; 10 | 11 | use error::{Result, Error}; 12 | use ispell_result::{IspellResult, IspellError}; 13 | use async_reader::AsyncReader; 14 | 15 | /// Spell Checker 16 | /// 17 | /// Checks the spelling of a line. 18 | /// 19 | /// # Example 20 | /// 21 | /// ``` 22 | /// use ispell::SpellLauncher; 23 | /// let mut checker = SpellLauncher::new().launch().unwrap(); 24 | /// let errors = checker.check("This should not contain any error").unwrap(); 25 | /// assert!(errors.is_empty()); 26 | /// ``` 27 | pub struct SpellChecker { 28 | ispell: Child, 29 | stdin: ChildStdin, 30 | receiver: Receiver>, 31 | timeout: Duration, 32 | _child: thread::JoinHandle<()>, 33 | } 34 | 35 | impl SpellChecker { 36 | /// Creates a new spell checker from a running process 37 | #[doc(hidden)] 38 | pub fn new(mut process: Child, timeout: u64) -> Result { 39 | let stdin = if let Some(stdin) = process.stdin.take() { 40 | stdin 41 | } else { 42 | return Err(Error::process("could not access stdin of spawned process")); 43 | }; 44 | 45 | let stdout = if let Some(stdout) = process.stdout.take() { 46 | stdout 47 | } else { 48 | return Err(Error::process("could not access stdin of spawned process")); 49 | }; 50 | 51 | let (sender, receiver) = channel(); 52 | let mut reader = AsyncReader::new(stdout, sender); 53 | let child = thread::spawn(move || { 54 | reader.read_loop(); 55 | }); 56 | 57 | let mut checker = SpellChecker { 58 | ispell: process, 59 | stdin: stdin, 60 | timeout: Duration::from_millis(timeout), 61 | receiver: receiver, 62 | _child: child, 63 | }; 64 | 65 | // Read the first line that displays Version 66 | // checker.write_str("")?; 67 | let s = checker.read_str()?; 68 | match s.chars().next() { 69 | Some('@') => Ok(checker), 70 | _ => Err(Error::protocol(format!("First line of ispell output doesn't start with '@', aborting"))) 71 | } 72 | } 73 | 74 | /// Reads the output from ispell 75 | fn read_str(&mut self) -> Result { 76 | match self.receiver.recv_timeout(self.timeout) { 77 | Ok(result) => result, 78 | Err(_) => return Err(Error::process("timeout error: spawned process didn't respond in time, aborting")), 79 | } 80 | } 81 | 82 | /// Flushes the stdout of the spawned process, so we are sure we start 83 | /// reading an answer to what we just wrote 84 | fn flush_stdout(&mut self) -> Result<()> { 85 | loop { 86 | match self.receiver.try_recv() { 87 | Ok(_) => continue, 88 | Err(TryRecvError::Empty) => break, 89 | Err(TryRecvError::Disconnected) => return Err(Error::process("spawned process closed its stdout early, aborting")), 90 | } 91 | } 92 | Ok(()) 93 | } 94 | 95 | /// Write to ispell stdin 96 | fn write_str(&mut self, text: &str) -> Result<()> { 97 | // First, clear ispell's stdout just in case 98 | self.flush_stdout()?; 99 | 100 | self.stdin.write_all(b"^")?; 101 | self.stdin.write_all(text.as_bytes())?; 102 | self.stdin.write_all(b"\n")?; 103 | self.stdin.flush()?; 104 | Ok(()) 105 | } 106 | 107 | /// Adds a word to your personal dictionary 108 | /// 109 | /// The word will be saved to your words file (e.g. `~/.ispell_LANG,` `~/.hunspell_LANG, or `~/.aspell.LANG.pws`), 110 | /// so it will be memorized next time you use i/a/hun/spell. If you only want to add the word to 111 | /// this current session, use `add_word`. 112 | /// 113 | /// # Returns 114 | /// 115 | /// An error if connection to ispell failed, or `word` contains multiple words (i.e., spaces). 116 | /// 117 | /// Note that a successful return of this method doesn't mean that the word was successfully added, as 118 | /// it is possible that it contains invalid character and ispell will reject it. 119 | /// 120 | /// # Examples 121 | /// 122 | /// Adding a valid word 123 | /// 124 | /// ```rust,no_run 125 | /// use ispell::SpellLauncher; 126 | /// 127 | /// fn main() { 128 | /// let mut checker = SpellLauncher::new() 129 | /// .launch() 130 | /// .unwrap(); 131 | /// 132 | /// // "rustacean" is not a valid word... 133 | /// // (unless you already ran this code example) 134 | /// let errors = checker.check("rustacean").unwrap(); 135 | /// assert_eq!(errors.len(), 1); 136 | /// 137 | /// // let's add it to our personal dictionary 138 | /// checker.add_word_to_dictionary("rustacean").unwrap(); 139 | /// 140 | /// // now it is a valid word 141 | /// let errors = checker.check("rustacean").unwrap(); 142 | /// assert!(errors.is_empty()); 143 | /// } 144 | /// ``` 145 | /// 146 | /// Invalid word: contains spaces 147 | /// 148 | /// ```rust,no_run 149 | /// # use ispell::SpellLauncher; 150 | /// 151 | /// # fn main() { 152 | /// let mut checker = SpellLauncher::new() 153 | /// .launch() 154 | /// .unwrap(); 155 | /// 156 | /// let res = checker.add_word_to_dictionary("multiple words"); 157 | /// assert!(res.is_err()); 158 | /// # } 159 | /// ``` 160 | pub fn add_word_to_dictionary(&mut self, word: &str) -> Result<()> { 161 | if word.contains(|c:char| c.is_whitespace()) { 162 | return Err(Error::invalid_word(format!("word '{}' contains space(s)", 163 | word))); 164 | } 165 | self.stdin.write_all(b"*")?; 166 | self.stdin.write_all(word.as_bytes())?; 167 | self.stdin.write_all(b"\n")?; 168 | 169 | // Save the dictionary 170 | self.stdin.flush()?; 171 | self.stdin.write_all(b"#\n")?; 172 | self.stdin.flush()?; 173 | Ok(()) 174 | } 175 | 176 | /// Add a word to current session. 177 | /// 178 | /// Similar to `add_word_to_dictionary`, except `word` won't be memorized the next time you use i/a/hun/spell. 179 | /// 180 | /// ```rust 181 | /// use ispell::SpellLauncher; 182 | /// 183 | /// fn main() { 184 | /// let mut checker = SpellLauncher::new() 185 | /// .launch() 186 | /// .unwrap(); 187 | /// 188 | /// // "rustaholic" is not a valid word... 189 | /// // (even if you already ran this code example) 190 | /// let errors = checker.check("rustaholic").unwrap(); 191 | /// assert_eq!(errors.len(), 1); 192 | /// 193 | /// // let's add it to this session 194 | /// checker.add_word("rustaholic").unwrap(); 195 | /// 196 | /// // now it is a valid word 197 | /// let errors = checker.check("rustaholic").unwrap(); 198 | /// assert!(errors.is_empty()); 199 | /// } 200 | /// ``` 201 | pub fn add_word(&mut self, word: &str) -> Result<()> { 202 | if word.contains(|c:char| c.is_whitespace()) { 203 | return Err(Error::invalid_word(format!("word '{}' contains space(s)", 204 | word))); 205 | } 206 | self.stdin.write_all(b"@")?; 207 | self.stdin.write_all(word.as_bytes())?; 208 | self.stdin.write_all(b"\n")?; 209 | self.stdin.flush()?; 210 | Ok(()) 211 | } 212 | 213 | 214 | /// Checks the spelling of a line. 215 | /// 216 | /// This method only returns the errors that ispell detects. Since the position returned 217 | /// in those errors is the number of characters since the beginning of the line, this method 218 | /// needs to be called line by line and not on a full document. 219 | pub fn check(&mut self, text: &str) -> Result> { 220 | let results = self.check_raw(text)?; 221 | let mut errors = vec!(); 222 | 223 | for elem in results.into_iter() { 224 | match elem { 225 | IspellResult::Miss(error) 226 | | IspellResult::Guess(error) 227 | | IspellResult::None(error) 228 | => errors.push(error), 229 | 230 | _ => (), 231 | } 232 | } 233 | Ok(errors) 234 | } 235 | 236 | 237 | /// Checks the spelling of a string 238 | /// 239 | /// This method returns a vector of all `ispell` answers, even when 240 | /// there is no errors. Usually, the `check` method, which only returns 241 | /// errors, will be more useful. 242 | pub fn check_raw(&mut self, text: &str) -> Result> { 243 | self.write_str(text)?; 244 | 245 | let mut output = Vec::new(); 246 | 247 | if let Ok(s) = self.read_str() { 248 | for line in s.lines() { 249 | if line.is_empty() { 250 | break; 251 | } 252 | let first = line.chars().next().unwrap(); 253 | match first { 254 | '*' => output.push(IspellResult::Ok), 255 | '-' => output.push(IspellResult::Compound), 256 | '+' => { 257 | let words:Vec<_> = line.split_whitespace().collect(); 258 | if words.len() != 2 { 259 | return Err(Error::protocol(format!("'root' line ill-formatted: {}", line))); 260 | } 261 | output.push(IspellResult::Root(words[1].to_owned())); 262 | }, 263 | '#' => { 264 | let error = get_ispell_error(line, 3)?; 265 | output.push(IspellResult::None(error)); 266 | }, 267 | '&' | '?' => { 268 | let parts: Vec<_> = line.split(':').collect(); 269 | if parts.len() != 2 { 270 | return Err(Error::protocol(format!("unexpected output from ispell: {}", line))); 271 | } 272 | let mut error = get_ispell_error(parts[0], 4)?; 273 | let suggestions: Vec<_> = parts[1].split(",") 274 | .map(|s| s.trim().to_owned()) 275 | .collect(); 276 | error.suggestions = suggestions; 277 | if first == '&' { 278 | output.push(IspellResult::Miss(error)); 279 | } else { 280 | output.push(IspellResult::Guess(error)); 281 | } 282 | }, 283 | _ => return Err(Error::protocol(format!("unexpected output: {}", line))), 284 | } 285 | } 286 | } 287 | 288 | Ok(output) 289 | } 290 | } 291 | 292 | 293 | impl Drop for SpellChecker { 294 | fn drop(&mut self) { 295 | // We could do this more nicely 296 | self.ispell.kill().unwrap(); 297 | } 298 | } 299 | 300 | 301 | /// Transforms a string looking like "# unkwnown POS' or '& unknown n POS' to an IspellError 302 | fn get_ispell_error(input: &str, n: usize) -> Result { 303 | let words: Vec<_> = input.split_whitespace().collect(); 304 | if words.len() != n { 305 | return Err(Error::protocol(format!("unexpected result: {}", input))); 306 | } 307 | let misspelled = words[1].to_owned(); 308 | let position:usize = words[n - 1].parse() 309 | .map_err(|_| Error::protocol(format!("could not parse '{}' as an int", words[2])))?; 310 | Ok(IspellError { 311 | misspelled: misspelled, 312 | position: position - 1, // remove the '^' character we add for escaping 313 | suggestions: vec!(), 314 | }) 315 | } 316 | 317 | 318 | #[test] 319 | fn add_word() { 320 | use spell_launcher::SpellLauncher; 321 | 322 | let mut checker = SpellLauncher::new() 323 | .launch() 324 | .unwrap(); 325 | 326 | checker.add_word("notaword").unwrap(); 327 | assert!(checker.check("notaword").unwrap().is_empty()); 328 | 329 | checker.add_word("stillnotaword2").unwrap(); 330 | assert_eq!(checker.check("stillnotaword2").unwrap().len(), 1); 331 | } 332 | -------------------------------------------------------------------------------- /src/spell_launcher.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with 3 | // this file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use std::process::Command; 6 | use std::process::Stdio; 7 | 8 | use spell_checker::SpellChecker; 9 | use error::{Result, Error}; 10 | 11 | /// Spell Launcher wizard (ah, ah). A builder for `SpellChecker`. 12 | /// 13 | /// Runs `ispell` or one of its variant. 14 | /// 15 | /// # Examples 16 | /// 17 | /// * Launches `ispell` with `british` dictionary: 18 | /// 19 | /// ```no_run 20 | /// use ispell::SpellLauncher; 21 | /// let checker = SpellLauncher::new() 22 | /// .dictionary("british") 23 | /// .launch() 24 | /// .unwrap(); 25 | /// ``` 26 | /// 27 | /// * Launches `aspell` with french (France) language: 28 | /// 29 | /// ``` 30 | /// use ispell::SpellLauncher; 31 | /// let checker = SpellLauncher::new() 32 | /// .aspell() 33 | /// .dictionary("fr_FR") 34 | /// .launch() 35 | /// .unwrap(); 36 | /// ``` 37 | #[derive(Debug)] 38 | pub struct SpellLauncher { 39 | lang: Option, 40 | command: Option, 41 | mode: Mode, 42 | timeout: u64, 43 | } 44 | 45 | #[derive(Debug)] 46 | enum Mode { 47 | Ispell, 48 | Aspell, 49 | Hunspell, 50 | } 51 | 52 | impl SpellLauncher { 53 | /// Creates a new spell checker with default options 54 | pub fn new() -> SpellLauncher { 55 | SpellLauncher { 56 | lang: None, 57 | command: None, 58 | mode: Mode::Ispell, 59 | timeout: 1000, 60 | } 61 | } 62 | 63 | /// Sets mode to aspell instead of ispell. 64 | /// 65 | /// Will run `aspell` as the command if it is not set 66 | pub fn aspell(&mut self) -> &mut SpellLauncher { 67 | self.mode = Mode::Aspell; 68 | self 69 | } 70 | 71 | /// Sets compatibility mode to hunspell instead of ispell. 72 | /// 73 | /// Will run `hunspell` as the command if it is not set 74 | pub fn hunspell(&mut self) -> &mut SpellLauncher { 75 | self.mode = Mode::Hunspell; 76 | self 77 | } 78 | 79 | /// Sets compatibility mode to ispell 80 | /// 81 | /// Will run `ispell` as the command if it is not set 82 | /// (default setting) 83 | pub fn ispell(&mut self) -> &mut SpellLauncher { 84 | self.mode = Mode::Ispell; 85 | self 86 | } 87 | 88 | 89 | /// Sets the timeout when checking ispell 90 | /// 91 | /// If the spawned process takes longer than this timeout to answer to a query, 92 | /// it will be killed and an error will be returned, preventing your program 93 | /// from freezing indefinitely. 94 | /// 95 | /// The timeout is set in milliseconds, and is 1000 (a second) by default. 96 | pub fn timeout(&mut self, timeout: u64) -> &mut SpellLauncher { 97 | self.timeout = timeout; 98 | self 99 | } 100 | 101 | /// Set the name of the command to run 102 | /// 103 | /// By default, it inferred from the mode (which is `ispell` by default). 104 | /// 105 | /// Unless you want to run a specific (ispell-compatible) command, you shouldn't use this method directly, but rather 106 | /// use the `aspell` or `hunspell` methods, since this also allow the the library to know which actual program 107 | /// is runned and to set encoding options accordingly. 108 | pub fn command>(&mut self, command: S) -> &mut SpellLauncher { 109 | self.command = Some(command.into()); 110 | self 111 | } 112 | 113 | /// Determine the dictionary that should be used. 114 | /// 115 | /// Note that `ispell`, `hunspell` and `aspell` have different naming schemes: 116 | /// 117 | /// * `ispell` accepts full names, e.g. "american", "british", "french", ... 118 | /// * `hunspell` accepts unicode language codes, e.g. "fr_FR", "en_GB", ... 119 | /// * `aspell` accepts both. 120 | /// 121 | /// # Example 122 | /// 123 | /// ``` 124 | /// use ispell::SpellLauncher; 125 | /// let checker = SpellLauncher::new() 126 | /// .aspell() 127 | /// .dictionary("en_GB") 128 | /// .launch() 129 | /// .unwrap(); 130 | /// ``` 131 | pub fn dictionary>(&mut self, lang: S) -> &mut SpellLauncher { 132 | self.lang = Some(lang.into()); 133 | self 134 | } 135 | 136 | /// Launch `ispell` (or `aspell` or `hunspell`) and return a `SpellChecker` 137 | pub fn launch(&self) -> Result { 138 | let command_name: &str = if let Some(ref command) = self.command { 139 | command 140 | } else { 141 | match self.mode { 142 | Mode::Ispell => "ispell", 143 | Mode::Aspell => "aspell", 144 | Mode::Hunspell => "hunspell", 145 | } 146 | }; 147 | let mut command = Command::new(command_name); 148 | command.arg("-a") 149 | .stdin(Stdio::piped()) 150 | .stdout(Stdio::piped()); 151 | if let Some(ref lang) = self.lang { 152 | command.arg("-d") 153 | .arg(lang); 154 | } 155 | // Try to set encoding to utf-8 156 | if self.command.is_none() { // only do this if it isn't a custom command 157 | match self.mode { 158 | Mode::Hunspell => command.args(&["-i", "utf-8"]), 159 | Mode::Aspell => command.arg("--encoding=utf-8"), 160 | Mode::Ispell => command.arg("-Tutf8"), 161 | }; 162 | } 163 | 164 | let res = command.spawn(); 165 | 166 | match res { 167 | Ok(child) => SpellChecker::new(child, self.timeout), 168 | Err(err) => Err(Error::process(format!("could not successfully spawn process '{}': {}", command_name, err))) 169 | } 170 | } 171 | } 172 | --------------------------------------------------------------------------------