commit b0e69479d102e38507aed7f94dd1bc0e4def91dd Author: Travis CI User Date: Wed Nov 13 03:15:51 2019 +0000 Documentation for lawliet89/rocket_cors@f9603e1 diff --git a/.lock b/.lock new file mode 100755 index 0000000..e69de29 diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt new file mode 100644 index 0000000..af77776 --- /dev/null +++ b/COPYRIGHT.txt @@ -0,0 +1,45 @@ +These documentation pages include resources by third parties. This copyright +file applies only to those resources. The following third party resources are +included, and carry their own copyright notices and license terms: + +* Fira Sans (FiraSans-Regular.woff, FiraSans-Medium.woff): + + Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ + with Reserved Font Name Fira Sans. + + Copyright (c) 2014, Telefonica S.A. + + Licensed under the SIL Open Font License, Version 1.1. + See FiraSans-LICENSE.txt. + +* rustdoc.css, main.js, and playpen.js: + + Copyright 2015 The Rust Developers. + Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE.txt) or + the MIT license (LICENSE-MIT.txt) at your option. + +* normalize.css: + + Copyright (c) Nicolas Gallagher and Jonathan Neal. + Licensed under the MIT license (see LICENSE-MIT.txt). + +* Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff): + + 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. + + Licensed under the SIL Open Font License, Version 1.1. + See SourceCodePro-LICENSE.txt. + +* Source Serif Pro (SourceSerifPro-Regular.ttf.woff, + SourceSerifPro-Bold.ttf.woff, SourceSerifPro-It.ttf.woff): + + 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. + + Licensed under the SIL Open Font License, Version 1.1. + See SourceSerifPro-LICENSE.txt. + +This copyright file is intended to be distributed with rustdoc output. diff --git a/FiraSans-LICENSE.txt b/FiraSans-LICENSE.txt new file mode 100644 index 0000000..d444ea9 --- /dev/null +++ b/FiraSans-LICENSE.txt @@ -0,0 +1,94 @@ +Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. +with Reserved Font Name < Fira >, + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/FiraSans-Medium.woff b/FiraSans-Medium.woff new file mode 100644 index 0000000..7d742c5 Binary files /dev/null and b/FiraSans-Medium.woff differ diff --git a/FiraSans-Regular.woff b/FiraSans-Regular.woff new file mode 100644 index 0000000..d8e0363 Binary files /dev/null and b/FiraSans-Regular.woff differ diff --git a/LICENSE-APACHE.txt b/LICENSE-APACHE.txt new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/LICENSE-APACHE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/LICENSE-MIT.txt b/LICENSE-MIT.txt new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/LICENSE-MIT.txt @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/SourceCodePro-LICENSE.txt b/SourceCodePro-LICENSE.txt new file mode 100644 index 0000000..0754257 --- /dev/null +++ b/SourceCodePro-LICENSE.txt @@ -0,0 +1,93 @@ +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. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/SourceCodePro-Regular.woff b/SourceCodePro-Regular.woff new file mode 100644 index 0000000..5576670 Binary files /dev/null and b/SourceCodePro-Regular.woff differ diff --git a/SourceCodePro-Semibold.woff b/SourceCodePro-Semibold.woff new file mode 100644 index 0000000..ca972a1 Binary files /dev/null and b/SourceCodePro-Semibold.woff differ diff --git a/SourceSerifPro-Bold.ttf.woff b/SourceSerifPro-Bold.ttf.woff new file mode 100644 index 0000000..ca25431 Binary files /dev/null and b/SourceSerifPro-Bold.ttf.woff differ diff --git a/SourceSerifPro-It.ttf.woff b/SourceSerifPro-It.ttf.woff new file mode 100644 index 0000000..a287bbe Binary files /dev/null and b/SourceSerifPro-It.ttf.woff differ diff --git a/SourceSerifPro-LICENSE.md b/SourceSerifPro-LICENSE.md new file mode 100644 index 0000000..22cb755 --- /dev/null +++ b/SourceSerifPro-LICENSE.md @@ -0,0 +1,93 @@ +Copyright 2014-2018 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/SourceSerifPro-Regular.ttf.woff b/SourceSerifPro-Regular.ttf.woff new file mode 100644 index 0000000..a3d55cf Binary files /dev/null and b/SourceSerifPro-Regular.ttf.woff differ diff --git a/aliases.js b/aliases.js new file mode 100644 index 0000000..d4b584e --- /dev/null +++ b/aliases.js @@ -0,0 +1,2 @@ +var ALIASES = {}; +ALIASES["rocket_cors"] = {}; diff --git a/brush.svg b/brush.svg new file mode 100644 index 0000000..072264a --- /dev/null +++ b/brush.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/dark.css b/dark.css new file mode 100644 index 0000000..18ec39a --- /dev/null +++ b/dark.css @@ -0,0 +1 @@ +body{background-color:#353535;color:#ddd;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){color:#ddd;}h1.fqn{border-bottom-color:#d2d2d2;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){border-bottom-color:#d2d2d2;}.in-band{background-color:#353535;}.invisible{background:rgba(0,0,0,0);}.docblock code,.docblock-short code{background-color:#2A2A2A;}pre{background-color:#2A2A2A;}.sidebar{background-color:#505050;}.sidebar .current{background-color:#333;}.source .sidebar{background-color:#353535;}.sidebar .location{border-color:#fff;background:#575757;color:#DDD;}.sidebar .version{border-bottom-color:#DDD;}.sidebar-title{border-top-color:#777;border-bottom-color:#777;}.block a:hover{background:#444;}.line-numbers span{color:#3B91E2;}.line-numbers .line-highlighted{background-color:#0a042f !important;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom-color:#DDD;}.docblock table,.docblock table td,.docblock table th{border-color:#ddd;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#ddd;}.content .highlighted{color:#eee !important;background-color:#616161;}.content .highlighted a,.content .highlighted span{color:#eee !important;}.content .highlighted.trait{background-color:#013191;}.content .highlighted.traitalias{background-color:#013191;}.content .highlighted.mod,.content .highlighted.externcrate{background-color:#afc6e4;}.content .highlighted.mod{background-color:#803a1b;}.content .highlighted.externcrate{background-color:#396bac;}.content .highlighted.enum{background-color:#5b4e68;}.content .highlighted.struct{background-color:#194e9f;}.content .highlighted.union{background-color:#b7bd49;}.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod{background-color:#4950ed;}.content .highlighted.type{background-color:#38902c;}.content .highlighted.foreigntype{background-color:#b200d6;}.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro{background-color:#217d1c;}.content .highlighted.constant,.content .highlighted.static{background-color:#0063cc;}.content .highlighted.primitive{background-color:#00708a;}.content .highlighted.keyword{background-color:#884719;}.content span.enum,.content a.enum,.block a.current.enum{color:#82b089;}.content span.struct,.content a.struct,.block a.current.struct{color:#2dbfb8;}.content span.type,.content a.type,.block a.current.type{color:#ff7f00;}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{color:#dd7de8;}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{color:#09bd00;}.content span.union,.content a.union,.block a.current.union{color:#a6ae37;}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{color:#82a5c9;}.content span.primitive,.content a.primitive,.block a.current.primitive{color:#43aec7;}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{color:#bda000;}.content span.trait,.content a.trait,.block a.current.trait{color:#b78cf2;}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{color:#b397da;}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{color:#2BAB63;}.content span.keyword,.content a.keyword,.block a.current.keyword{color:#de5249;}pre.rust .comment{color:#8d8d8b;}pre.rust .doccomment{color:#8ca375;}nav:not(.sidebar){border-bottom-color:#4e4e4e;}nav.main .current{border-top-color:#eee;border-bottom-color:#eee;}nav.main .separator{border-color:#eee;}a{color:#ddd;}.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),.docblock-short a:not(.srclink):not(.test-arrow),.stability a{color:#D2991D;}.stab.internal a{color:#304FFE;}a.test-arrow{color:#dedede;}.collapse-toggle{color:#999;}#crate-search{color:#111;background-color:#f0f0f0;border-color:#000;box-shadow:0 0 0 1px #000,0 0 0 2px transparent;}.search-input{color:#111;background-color:#f0f0f0;box-shadow:0 0 0 1px #000,0 0 0 2px transparent;}.search-input:focus{border-color:#008dfd;}#crate-search+.search-input:focus{box-shadow:0 0 8px 4px #078dd8;}.module-item .stab{color:#ddd;}.stab.unstable{background:#FFF5D6;border-color:#FFC600;color:#2f2f2f;}.stab.internal{background:#FFB9B3;border-color:#B71C1C;color:#2f2f2f;}.stab.deprecated{background:#F3DFFF;border-color:#7F0087;color:#2f2f2f;}.stab.portability{background:#C4ECFF;border-color:#7BA5DB;color:#2f2f2f;}.stab.portability>code{color:#ddd;}#help>div{background:#4d4d4d;border-color:#bfbfbf;}#help dt{border-color:#bfbfbf;background:rgba(0,0,0,0);color:black;}.since{color:grey;}tr.result span.primitive::after,tr.result span.keyword::after{color:#ddd;}.line-numbers :target{background-color:transparent;}pre.rust .kw{color:#ab8ac1;}pre.rust .kw-2,pre.rust .prelude-ty{color:#769acb;}pre.rust .number,pre.rust .string{color:#83a300;}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{color:#ee6868;}pre.rust .macro,pre.rust .macro-nonterminal{color:#3E999F;}pre.rust .lifetime{color:#d97f26;}pre.rust .question-mark{color:#ff9011;}.example-wrap>pre.line-number{border-color:#4a4949;}a.test-arrow{background-color:rgba(78,139,202,0.2);}a.test-arrow:hover{background-color:#4e8bca;}.toggle-label{color:#999;}:target>code,:target>.in-band{background-color:#494a3d;}pre.compile_fail{border-left:2px solid rgba(255,0,0,.6);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.6);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.6);}.information>.compile_fail:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.6);}.information>.ignore:hover{color:rgba(255,142,0,1);}.search-failed a{color:#0089ff;}.tooltip .tooltiptext{background-color:black;color:#fff;}.tooltip .tooltiptext::after{border-color:transparent black transparent transparent;}.important-traits .tooltip .tooltiptext{background-color:white;color:black;border-color:black;}#titles>div:not(.selected){background-color:#252525;border-top-color:#252525;}#titles>div:hover,#titles>div.selected{border-top-color:#0089ff;}#titles>div>div.count{color:#888;}.modal{background-color:rgba(0,0,0,0.3);}.modal-content{background-color:#272727;border-color:#999;}.modal-content>.close{background-color:#272727;border-color:#999;}.modal-content>.close:hover{background-color:#ff1f1f;color:white;}.modal-content>.whiter{background-color:#272727;}.modal-content>.close:hover+.whiter{background-color:#ff1f1f;}@media (max-width:700px){.sidebar-menu{background-color:#505050;border-bottom-color:#e0e0e0;border-right-color:#e0e0e0;}.sidebar-elems{background-color:#505050;border-right-color:#000;}#sidebar-filler{background-color:#505050;border-bottom-color:#e0e0e0;}}kbd{color:#000;background-color:#fafbfc;border-color:#d1d5da;border-bottom-color:#c6cbd1;box-shadow-color:#c6cbd1;}#theme-picker,#settings-menu{border-color:#e0e0e0;background:#f0f0f0;}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus{border-color:#ffb900;}#theme-choices{border-color:#e0e0e0;background-color:#353535;}#theme-choices>button:not(:first-child){border-top-color:#e0e0e0;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:#4e4e4e;}@media (max-width:700px){#theme-picker{background:#f0f0f0;}}#all-types{background-color:#505050;}#all-types:hover{background-color:#606060;}.search-results td span.alias{color:#fff;}.search-results td span.grey{color:#ccc;}#sidebar-toggle{background-color:#565656;}#sidebar-toggle:hover{background-color:#676767;}#source-sidebar{background-color:#565656;}#source-sidebar>.title{border-bottom-color:#ccc;}div.files>a:hover,div.name:hover{background-color:#444;}div.files>.selected{background-color:#333;}.setting-line>.title{border-bottom-color:#ddd;} \ No newline at end of file diff --git a/down-arrow.svg b/down-arrow.svg new file mode 100644 index 0000000..c0f59f0 --- /dev/null +++ b/down-arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..b8ad237 Binary files /dev/null and b/favicon.ico differ diff --git a/implementors/core/clone/trait.Clone.js b/implementors/core/clone/trait.Clone.js new file mode 100644 index 0000000..a512e9a --- /dev/null +++ b/implementors/core/clone/trait.Clone.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Clone for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Clone for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl<T: Clone> Clone for AllOrSome<T>",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl Clone for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl Clone for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl Clone for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},{text:"impl Clone for Cors",synthetic:false,types:["rocket_cors::Cors"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/cmp/trait.Eq.js b/implementors/core/cmp/trait.Eq.js new file mode 100644 index 0000000..d3c7fa3 --- /dev/null +++ b/implementors/core/cmp/trait.Eq.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Eq for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Eq for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl Eq for AccessControlRequestHeaders",synthetic:false,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl<T: Eq> Eq for AllOrSome<T>",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl Eq for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl Eq for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl Eq for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/cmp/trait.PartialEq.js b/implementors/core/cmp/trait.PartialEq.js new file mode 100644 index 0000000..edf345d --- /dev/null +++ b/implementors/core/cmp/trait.PartialEq.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl PartialEq<HeaderFieldName> for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl PartialEq<Origin> for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl PartialEq<AccessControlRequestHeaders> for AccessControlRequestHeaders",synthetic:false,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl<T: PartialEq> PartialEq<AllOrSome<T>> for AllOrSome<T>",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl PartialEq<Method> for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl PartialEq<Origins> for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl PartialEq<CorsOptions> for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/convert/trait.From.js b/implementors/core/convert/trait.From.js new file mode 100644 index 0000000..203e535 --- /dev/null +++ b/implementors/core/convert/trait.From.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl<'a> From<&'a str> for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl<'a> From<String> for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl From<ParseError> for Error",synthetic:false,types:["rocket_cors::Error"]},{text:"impl From<Error> for Error",synthetic:false,types:["rocket_cors::Error"]},{text:"impl From<Method> for Method",synthetic:false,types:["rocket_cors::Method"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/default/trait.Default.js b/implementors/core/default/trait.Default.js new file mode 100644 index 0000000..b446ff8 --- /dev/null +++ b/implementors/core/default/trait.Default.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl<T> Default for AllOrSome<T>",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl Default for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl Default for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/fmt/trait.Debug.js b/implementors/core/fmt/trait.Debug.js new file mode 100644 index 0000000..17f76d3 --- /dev/null +++ b/implementors/core/fmt/trait.Debug.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Debug for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Debug for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl Debug for AccessControlRequestMethod",synthetic:false,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl Debug for AccessControlRequestHeaders",synthetic:false,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl Debug for Error",synthetic:false,types:["rocket_cors::Error"]},{text:"impl<T: Debug> Debug for AllOrSome<T>",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl Debug for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl Debug for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl Debug for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},{text:"impl Debug for Cors",synthetic:false,types:["rocket_cors::Cors"]},{text:"impl<'r, R: Debug> Debug for Responder<'r, R>",synthetic:false,types:["rocket_cors::Responder"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/fmt/trait.Display.js b/implementors/core/fmt/trait.Display.js new file mode 100644 index 0000000..166383a --- /dev/null +++ b/implementors/core/fmt/trait.Display.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Display for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Display for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl Display for Error",synthetic:false,types:["rocket_cors::Error"]},{text:"impl Display for Method",synthetic:false,types:["rocket_cors::Method"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/hash/trait.Hash.js b/implementors/core/hash/trait.Hash.js new file mode 100644 index 0000000..da4da7b --- /dev/null +++ b/implementors/core/hash/trait.Hash.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Hash for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Hash for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl Hash for Method",synthetic:false,types:["rocket_cors::Method"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/marker/trait.Copy.js b/implementors/core/marker/trait.Copy.js new file mode 100644 index 0000000..d693cd9 --- /dev/null +++ b/implementors/core/marker/trait.Copy.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Copy for Method",synthetic:false,types:["rocket_cors::Method"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/marker/trait.Freeze.js b/implementors/core/marker/trait.Freeze.js new file mode 100644 index 0000000..290bf0d --- /dev/null +++ b/implementors/core/marker/trait.Freeze.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Freeze for Method",synthetic:true,types:["rocket_cors::Method"]},{text:"impl Freeze for Origins",synthetic:true,types:["rocket_cors::Origins"]},{text:"impl Freeze for CorsOptions",synthetic:true,types:["rocket_cors::CorsOptions"]},{text:"impl !Freeze for Cors",synthetic:true,types:["rocket_cors::Cors"]},{text:"impl<'r> Freeze for Guard<'r>",synthetic:true,types:["rocket_cors::Guard"]},{text:"impl<'r, R> Freeze for Responder<'r, R> where
    R: Freeze, 
",synthetic:true,types:["rocket_cors::Responder"]},{text:"impl<'r, F, R> !Freeze for ManualResponder<'r, F, R>",synthetic:true,types:["rocket_cors::ManualResponder"]},{text:"impl Freeze for Error",synthetic:true,types:["rocket_cors::Error"]},{text:"impl<T> Freeze for AllOrSome<T> where
    T: Freeze, 
",synthetic:true,types:["rocket_cors::AllOrSome"]},{text:"impl Freeze for HeaderFieldName",synthetic:true,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Freeze for AccessControlRequestMethod",synthetic:true,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl Freeze for AccessControlRequestHeaders",synthetic:true,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl Freeze for Origin",synthetic:true,types:["rocket_cors::headers::Origin"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/marker/trait.Send.js b/implementors/core/marker/trait.Send.js new file mode 100644 index 0000000..0798e44 --- /dev/null +++ b/implementors/core/marker/trait.Send.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Send for Method",synthetic:true,types:["rocket_cors::Method"]},{text:"impl Send for Origins",synthetic:true,types:["rocket_cors::Origins"]},{text:"impl Send for CorsOptions",synthetic:true,types:["rocket_cors::CorsOptions"]},{text:"impl Send for Cors",synthetic:true,types:["rocket_cors::Cors"]},{text:"impl<'r> Send for Guard<'r>",synthetic:true,types:["rocket_cors::Guard"]},{text:"impl<'r, R> !Send for Responder<'r, R>",synthetic:true,types:["rocket_cors::Responder"]},{text:"impl<'r, F, R> Send for ManualResponder<'r, F, R> where
    F: Send,
    R: Send
",synthetic:true,types:["rocket_cors::ManualResponder"]},{text:"impl Send for Error",synthetic:true,types:["rocket_cors::Error"]},{text:"impl<T> Send for AllOrSome<T> where
    T: Send
",synthetic:true,types:["rocket_cors::AllOrSome"]},{text:"impl Send for HeaderFieldName",synthetic:true,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Send for AccessControlRequestMethod",synthetic:true,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl Send for AccessControlRequestHeaders",synthetic:true,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl Send for Origin",synthetic:true,types:["rocket_cors::headers::Origin"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/marker/trait.StructuralEq.js b/implementors/core/marker/trait.StructuralEq.js new file mode 100644 index 0000000..b8b731c --- /dev/null +++ b/implementors/core/marker/trait.StructuralEq.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl StructuralEq for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl StructuralEq for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl StructuralEq for AccessControlRequestHeaders",synthetic:false,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl<T> StructuralEq for AllOrSome<T>",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl StructuralEq for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl StructuralEq for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl StructuralEq for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/marker/trait.StructuralPartialEq.js b/implementors/core/marker/trait.StructuralPartialEq.js new file mode 100644 index 0000000..db0791b --- /dev/null +++ b/implementors/core/marker/trait.StructuralPartialEq.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl StructuralPartialEq for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl StructuralPartialEq for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl StructuralPartialEq for AccessControlRequestHeaders",synthetic:false,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl<T> StructuralPartialEq for AllOrSome<T>",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl StructuralPartialEq for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl StructuralPartialEq for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl StructuralPartialEq for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/marker/trait.Sync.js b/implementors/core/marker/trait.Sync.js new file mode 100644 index 0000000..22e9bd5 --- /dev/null +++ b/implementors/core/marker/trait.Sync.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Sync for Method",synthetic:true,types:["rocket_cors::Method"]},{text:"impl Sync for Origins",synthetic:true,types:["rocket_cors::Origins"]},{text:"impl Sync for CorsOptions",synthetic:true,types:["rocket_cors::CorsOptions"]},{text:"impl Sync for Cors",synthetic:true,types:["rocket_cors::Cors"]},{text:"impl<'r> Sync for Guard<'r>",synthetic:true,types:["rocket_cors::Guard"]},{text:"impl<'r, R> !Sync for Responder<'r, R>",synthetic:true,types:["rocket_cors::Responder"]},{text:"impl<'r, F, R> Sync for ManualResponder<'r, F, R> where
    F: Sync,
    R: Sync
",synthetic:true,types:["rocket_cors::ManualResponder"]},{text:"impl Sync for Error",synthetic:true,types:["rocket_cors::Error"]},{text:"impl<T> Sync for AllOrSome<T> where
    T: Sync
",synthetic:true,types:["rocket_cors::AllOrSome"]},{text:"impl Sync for HeaderFieldName",synthetic:true,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Sync for AccessControlRequestMethod",synthetic:true,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl Sync for AccessControlRequestHeaders",synthetic:true,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl Sync for Origin",synthetic:true,types:["rocket_cors::headers::Origin"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/marker/trait.Unpin.js b/implementors/core/marker/trait.Unpin.js new file mode 100644 index 0000000..6bc17db --- /dev/null +++ b/implementors/core/marker/trait.Unpin.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Unpin for Method",synthetic:true,types:["rocket_cors::Method"]},{text:"impl Unpin for Origins",synthetic:true,types:["rocket_cors::Origins"]},{text:"impl Unpin for CorsOptions",synthetic:true,types:["rocket_cors::CorsOptions"]},{text:"impl Unpin for Cors",synthetic:true,types:["rocket_cors::Cors"]},{text:"impl<'r> Unpin for Guard<'r>",synthetic:true,types:["rocket_cors::Guard"]},{text:"impl<'r, R> !Unpin for Responder<'r, R>",synthetic:true,types:["rocket_cors::Responder"]},{text:"impl<'r, F, R> Unpin for ManualResponder<'r, F, R> where
    F: Unpin,
    R: Unpin
",synthetic:true,types:["rocket_cors::ManualResponder"]},{text:"impl Unpin for Error",synthetic:true,types:["rocket_cors::Error"]},{text:"impl<T> Unpin for AllOrSome<T> where
    T: Unpin
",synthetic:true,types:["rocket_cors::AllOrSome"]},{text:"impl Unpin for HeaderFieldName",synthetic:true,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Unpin for AccessControlRequestMethod",synthetic:true,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl Unpin for AccessControlRequestHeaders",synthetic:true,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl Unpin for Origin",synthetic:true,types:["rocket_cors::headers::Origin"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/ops/deref/trait.Deref.js b/implementors/core/ops/deref/trait.Deref.js new file mode 100644 index 0000000..c520da7 --- /dev/null +++ b/implementors/core/ops/deref/trait.Deref.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Deref for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl Deref for Method",synthetic:false,types:["rocket_cors::Method"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/core/str/trait.FromStr.js b/implementors/core/str/trait.FromStr.js new file mode 100644 index 0000000..5bb8e0d --- /dev/null +++ b/implementors/core/str/trait.FromStr.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl FromStr for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl FromStr for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl FromStr for AccessControlRequestMethod",synthetic:false,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl FromStr for AccessControlRequestHeaders",synthetic:false,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl FromStr for Method",synthetic:false,types:["rocket_cors::Method"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/rocket/fairing/trait.Fairing.js b/implementors/rocket/fairing/trait.Fairing.js new file mode 100644 index 0000000..701be6e --- /dev/null +++ b/implementors/rocket/fairing/trait.Fairing.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Fairing for Cors",synthetic:false,types:["rocket_cors::Cors"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/rocket/request/from_request/trait.FromRequest.js b/implementors/rocket/request/from_request/trait.FromRequest.js new file mode 100644 index 0000000..560b83a --- /dev/null +++ b/implementors/rocket/request/from_request/trait.FromRequest.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl<'a, 'r> FromRequest<'a, 'r> for Origin",synthetic:false,types:["rocket_cors::headers::Origin"]},{text:"impl<'a, 'r> FromRequest<'a, 'r> for AccessControlRequestMethod",synthetic:false,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl<'a, 'r> FromRequest<'a, 'r> for AccessControlRequestHeaders",synthetic:false,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl<'a, 'r> FromRequest<'a, 'r> for Guard<'r>",synthetic:false,types:["rocket_cors::Guard"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/rocket/response/responder/trait.Responder.js b/implementors/rocket/response/responder/trait.Responder.js new file mode 100644 index 0000000..105483c --- /dev/null +++ b/implementors/rocket/response/responder/trait.Responder.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl<'r> Responder<'r> for Error",synthetic:false,types:["rocket_cors::Error"]},{text:"impl<'r, R: Responder<'r>> Responder<'r> for Responder<'r, R>",synthetic:false,types:["rocket_cors::Responder"]},{text:"impl<'r, F, R> Responder<'r> for ManualResponder<'r, F, R> where
    F: FnOnce(Guard<'r>) -> R + 'r,
    R: Responder<'r>, 
",synthetic:false,types:["rocket_cors::ManualResponder"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/serde/de/trait.Deserialize.js b/implementors/serde/de/trait.Deserialize.js new file mode 100644 index 0000000..87182e3 --- /dev/null +++ b/implementors/serde/de/trait.Deserialize.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl<'de> Deserialize<'de> for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl<'de, T> Deserialize<'de> for AllOrSome<T> where
    T: Deserialize<'de>, 
",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl<'de> Deserialize<'de> for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl<'de> Deserialize<'de> for Origins where
    Origins: Default
",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl<'de> Deserialize<'de> for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/serde/ser/trait.Serialize.js b/implementors/serde/ser/trait.Serialize.js new file mode 100644 index 0000000..2b4821b --- /dev/null +++ b/implementors/serde/ser/trait.Serialize.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Serialize for HeaderFieldName",synthetic:false,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl<T> Serialize for AllOrSome<T> where
    T: Serialize
",synthetic:false,types:["rocket_cors::AllOrSome"]},{text:"impl Serialize for Method",synthetic:false,types:["rocket_cors::Method"]},{text:"impl Serialize for Origins",synthetic:false,types:["rocket_cors::Origins"]},{text:"impl Serialize for CorsOptions",synthetic:false,types:["rocket_cors::CorsOptions"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/std/error/trait.Error.js b/implementors/std/error/trait.Error.js new file mode 100644 index 0000000..8e46544 --- /dev/null +++ b/implementors/std/error/trait.Error.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl Error for Error",synthetic:false,types:["rocket_cors::Error"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/std/panic/trait.RefUnwindSafe.js b/implementors/std/panic/trait.RefUnwindSafe.js new file mode 100644 index 0000000..9424032 --- /dev/null +++ b/implementors/std/panic/trait.RefUnwindSafe.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl RefUnwindSafe for Method",synthetic:true,types:["rocket_cors::Method"]},{text:"impl RefUnwindSafe for Origins",synthetic:true,types:["rocket_cors::Origins"]},{text:"impl RefUnwindSafe for CorsOptions",synthetic:true,types:["rocket_cors::CorsOptions"]},{text:"impl !RefUnwindSafe for Cors",synthetic:true,types:["rocket_cors::Cors"]},{text:"impl<'r> RefUnwindSafe for Guard<'r>",synthetic:true,types:["rocket_cors::Guard"]},{text:"impl<'r, R> !RefUnwindSafe for Responder<'r, R>",synthetic:true,types:["rocket_cors::Responder"]},{text:"impl<'r, F, R> !RefUnwindSafe for ManualResponder<'r, F, R>",synthetic:true,types:["rocket_cors::ManualResponder"]},{text:"impl RefUnwindSafe for Error",synthetic:true,types:["rocket_cors::Error"]},{text:"impl<T> RefUnwindSafe for AllOrSome<T> where
    T: RefUnwindSafe
",synthetic:true,types:["rocket_cors::AllOrSome"]},{text:"impl RefUnwindSafe for HeaderFieldName",synthetic:true,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl RefUnwindSafe for AccessControlRequestMethod",synthetic:true,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl RefUnwindSafe for AccessControlRequestHeaders",synthetic:true,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl RefUnwindSafe for Origin",synthetic:true,types:["rocket_cors::headers::Origin"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/implementors/std/panic/trait.UnwindSafe.js b/implementors/std/panic/trait.UnwindSafe.js new file mode 100644 index 0000000..a14b56f --- /dev/null +++ b/implementors/std/panic/trait.UnwindSafe.js @@ -0,0 +1,9 @@ +(function() {var implementors = {}; +implementors["rocket_cors"] = [{text:"impl UnwindSafe for Method",synthetic:true,types:["rocket_cors::Method"]},{text:"impl UnwindSafe for Origins",synthetic:true,types:["rocket_cors::Origins"]},{text:"impl UnwindSafe for CorsOptions",synthetic:true,types:["rocket_cors::CorsOptions"]},{text:"impl UnwindSafe for Cors",synthetic:true,types:["rocket_cors::Cors"]},{text:"impl<'r> UnwindSafe for Guard<'r>",synthetic:true,types:["rocket_cors::Guard"]},{text:"impl<'r, R> !UnwindSafe for Responder<'r, R>",synthetic:true,types:["rocket_cors::Responder"]},{text:"impl<'r, F, R> !UnwindSafe for ManualResponder<'r, F, R>",synthetic:true,types:["rocket_cors::ManualResponder"]},{text:"impl UnwindSafe for Error",synthetic:true,types:["rocket_cors::Error"]},{text:"impl<T> UnwindSafe for AllOrSome<T> where
    T: UnwindSafe
",synthetic:true,types:["rocket_cors::AllOrSome"]},{text:"impl UnwindSafe for HeaderFieldName",synthetic:true,types:["rocket_cors::headers::HeaderFieldName"]},{text:"impl UnwindSafe for AccessControlRequestMethod",synthetic:true,types:["rocket_cors::headers::AccessControlRequestMethod"]},{text:"impl UnwindSafe for AccessControlRequestHeaders",synthetic:true,types:["rocket_cors::headers::AccessControlRequestHeaders"]},{text:"impl UnwindSafe for Origin",synthetic:true,types:["rocket_cors::headers::Origin"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + })() \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..2ea1d91 --- /dev/null +++ b/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/light.css b/light.css new file mode 100644 index 0000000..7c9ca18 --- /dev/null +++ b/light.css @@ -0,0 +1 @@ + body{background-color:white;color:black;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){color:black;}h1.fqn{border-bottom-color:#D5D5D5;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){border-bottom-color:#DDDDDD;}.in-band{background-color:white;}.invisible{background:rgba(0,0,0,0);}.docblock code,.docblock-short code{background-color:#F5F5F5;}pre{background-color:#F5F5F5;}.sidebar{background-color:#F1F1F1;}.sidebar .current{background-color:#fff;}.source .sidebar{background-color:#fff;}.sidebar .location{border-color:#000;background-color:#fff;color:#333;}.sidebar .version{border-bottom-color:#DDD;}.sidebar-title{border-top-color:#777;border-bottom-color:#777;}.block a:hover{background:#F5F5F5;}.line-numbers span{color:#c67e2d;}.line-numbers .line-highlighted{background-color:#f6fdb0 !important;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom-color:#ddd;}.docblock table,.docblock table td,.docblock table th{border-color:#ddd;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#4E4C4C;}.content .highlighted{color:#000 !important;background-color:#ccc;}.content .highlighted a,.content .highlighted span{color:#000 !important;}.content .highlighted.trait{background-color:#c7b6ff;}.content .highlighted.traitalias{background-color:#c7b6ff;}.content .highlighted.mod,.content .highlighted.externcrate{background-color:#afc6e4;}.content .highlighted.enum{background-color:#b4d1b9;}.content .highlighted.struct{background-color:#e7b1a0;}.content .highlighted.union{background-color:#b7bd49;}.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod{background-color:#c6afb3;}.content .highlighted.type{background-color:#ffc891;}.content .highlighted.foreigntype{background-color:#f5c4ff;}.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro{background-color:#8ce488;}.content .highlighted.constant,.content .highlighted.static{background-color:#c3e0ff;}.content .highlighted.primitive{background-color:#9aecff;}.content .highlighted.keyword{background-color:#f99650;}.content span.enum,.content a.enum,.block a.current.enum{color:#508157;}.content span.struct,.content a.struct,.block a.current.struct{color:#ad448e;}.content span.type,.content a.type,.block a.current.type{color:#ba5d00;}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{color:#cd00e2;}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{color:#068000;}.content span.union,.content a.union,.block a.current.union{color:#767b27;}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{color:#546e8a;}.content span.primitive,.content a.primitive,.block a.current.primitive{color:#2c8093;}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{color:#4d76ae;}.content span.trait,.content a.trait,.block a.current.trait{color:#7c5af3;}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{color:#6841f1;}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{color:#9a6e31;}.content span.keyword,.content a.keyword,.block a.current.keyword{color:#de5249;}pre.rust .comment{color:#8E908C;}pre.rust .doccomment{color:#4D4D4C;}nav:not(.sidebar){border-bottom-color:#e0e0e0;}nav.main .current{border-top-color:#000;border-bottom-color:#000;}nav.main .separator{border:1px solid #000;}a{color:#000;}.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),.docblock-short a:not(.srclink):not(.test-arrow),.stability a{color:#3873AD;}.stab.internal a{color:#304FFE;}a.test-arrow{color:#f5f5f5;}.collapse-toggle{color:#999;}#crate-search{color:#555;background-color:white;border-color:#e0e0e0;box-shadow:0 0 0 1px #e0e0e0,0 0 0 2px transparent;}.search-input{color:#555;background-color:white;box-shadow:0 0 0 1px #e0e0e0,0 0 0 2px transparent;}.search-input:focus{border-color:#66afe9;}#crate-search+.search-input:focus{box-shadow:0 0 8px #078dd8;}.module-item .stab{color:#000;}.stab.unstable{background:#FFF5D6;border-color:#FFC600;}.stab.internal{background:#FFB9B3;border-color:#B71C1C;}.stab.deprecated{background:#F3DFFF;border-color:#7F0087;}.stab.portability{background:#C4ECFF;border-color:#7BA5DB;}.stab.portability>code{color:#000;}#help>div{background:#e9e9e9;border-color:#bfbfbf;}.since{color:grey;}tr.result span.primitive::after,tr.result span.keyword::after{color:black;}.line-numbers :target{background-color:transparent;}pre.rust .kw{color:#8959A8;}pre.rust .kw-2,pre.rust .prelude-ty{color:#4271AE;}pre.rust .number,pre.rust .string{color:#718C00;}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{color:#C82829;}pre.rust .macro,pre.rust .macro-nonterminal{color:#3E999F;}pre.rust .lifetime{color:#B76514;}pre.rust .question-mark{color:#ff9011;}.example-wrap>pre.line-number{border-color:#c7c7c7;}a.test-arrow{background-color:rgba(78,139,202,0.2);}a.test-arrow:hover{background-color:#4e8bca;}.toggle-label{color:#999;}:target>code,:target>.in-band{background:#FDFFD3;}pre.compile_fail{border-left:2px solid rgba(255,0,0,.4);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.4);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.3);}.information>.compile_fail:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.3);}.information>.ignore:hover{color:rgba(255,142,0,1);}.search-failed a{color:#0089ff;}.tooltip .tooltiptext{background-color:black;color:#fff;}.tooltip .tooltiptext::after{border-color:transparent black transparent transparent;}.important-traits .tooltip .tooltiptext{background-color:white;color:black;border-color:black;}#titles>div:not(.selected){background-color:#e6e6e6;border-top-color:#e6e6e6;}#titles>div:hover,#titles>div.selected{border-top-color:#0089ff;}#titles>div>div.count{color:#888;}.modal{background-color:rgba(0,0,0,0.3);}.modal-content{background-color:#eee;border-color:#999;}.modal-content>.close{background-color:#eee;border-color:#999;}.modal-content>.close:hover{background-color:#ff1f1f;color:white;}.modal-content>.whiter{background-color:#eee;}.modal-content>.close:hover+.whiter{background-color:#ff1f1f;}@media (max-width:700px){.sidebar-menu{background-color:#F1F1F1;border-bottom-color:#e0e0e0;border-right-color:#e0e0e0;}.sidebar-elems{background-color:#F1F1F1;border-right-color:#000;}#sidebar-filler{background-color:#F1F1F1;border-bottom-color:#e0e0e0;}}kbd{color:#000;background-color:#fafbfc;border-color:#d1d5da;border-bottom-color:#c6cbd1;box-shadow-color:#c6cbd1;}#theme-picker,#settings-menu{border-color:#e0e0e0;background-color:#fff;}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus{border-color:#717171;}#theme-choices{border-color:#ccc;background-color:#fff;}#theme-choices>button:not(:first-child){border-top-color:#e0e0e0;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:#eee;}@media (max-width:700px){#theme-picker{background:#fff;}}#all-types{background-color:#fff;}#all-types:hover{background-color:#f9f9f9;}.search-results td span.alias{color:#000;}.search-results td span.grey{color:#999;}#sidebar-toggle{background-color:#F1F1F1;}#sidebar-toggle:hover{background-color:#E0E0E0;}#source-sidebar{background-color:#F1F1F1;}#source-sidebar>.title{border-bottom-color:#ccc;}div.files>a:hover,div.name:hover{background-color:#E0E0E0;}div.files>.selected{background-color:#fff;}.setting-line>.title{border-bottom-color:#D5D5D5;} \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..8408d27 --- /dev/null +++ b/main.js @@ -0,0 +1,7 @@ +if(!String.prototype.startsWith){String.prototype.startsWith=function(searchString,position){position=position||0;return this.indexOf(searchString,position)===position}}if(!String.prototype.endsWith){String.prototype.endsWith=function(suffix,length){var l=length||this.length;return this.indexOf(suffix,l-suffix.length)!==-1}}if(!DOMTokenList.prototype.add){DOMTokenList.prototype.add=function(className){if(className&&!hasClass(this,className)){if(this.className&&this.className.length>0){this.className+=" "+className}else{this.className=className}}}}if(!DOMTokenList.prototype.remove){DOMTokenList.prototype.remove=function(className){if(className&&this.className){this.className=(" "+this.className+" ").replace(" "+className+" "," ").trim()}}}function getSearchInput(){return document.getElementsByClassName("search-input")[0]}function getSearchElement(){return document.getElementById("search")}(function(){"use strict";var itemTypes=["mod","externcrate","import","struct","enum","fn","type","static","trait","impl","tymethod","method","structfield","variant","macro","primitive","associatedtype","constant","associatedconstant","union","foreigntype","keyword","existential","attr","derive","traitalias"];var disableShortcuts=getCurrentValue("rustdoc-disable-shortcuts")==="true";var search_input=getSearchInput();var currentTab=0;var titleBeforeSearch=document.title;function getPageId(){var id=document.location.href.split("#")[1];if(id){return id.split("?")[0].split("&")[0]}return null}function showSidebar(){var elems=document.getElementsByClassName("sidebar-elems")[0];if(elems){addClass(elems,"show-it")}var sidebar=document.getElementsByClassName("sidebar")[0];if(sidebar){addClass(sidebar,"mobile");var filler=document.getElementById("sidebar-filler");if(!filler){var div=document.createElement("div");div.id="sidebar-filler";sidebar.appendChild(div)}}var themePickers=document.getElementsByClassName("theme-picker");if(themePickers&&themePickers.length>0){themePickers[0].style.display="none"}}function hideSidebar(){var elems=document.getElementsByClassName("sidebar-elems")[0];if(elems){removeClass(elems,"show-it")}var sidebar=document.getElementsByClassName("sidebar")[0];removeClass(sidebar,"mobile");var filler=document.getElementById("sidebar-filler");if(filler){filler.remove()}document.getElementsByTagName("body")[0].style.marginTop="";var themePickers=document.getElementsByClassName("theme-picker");if(themePickers&&themePickers.length>0){themePickers[0].style.display=null}}var TY_PRIMITIVE=itemTypes.indexOf("primitive");var TY_KEYWORD=itemTypes.indexOf("keyword");onEachLazy(document.getElementsByClassName("js-only"),function(e){removeClass(e,"js-only")});function getQueryStringParams(){var params={};window.location.search.substring(1).split("&").map(function(s){var pair=s.split("=");params[decodeURIComponent(pair[0])]=typeof pair[1]==="undefined"?null:decodeURIComponent(pair[1])});return params}function browserSupportsHistoryApi(){return window.history&&typeof window.history.pushState==="function"}function isHidden(elem){return elem.offsetHeight===0}var main=document.getElementById("main");var savedHash="";function handleHashes(ev){var search=getSearchElement();if(ev!==null&&search&&!hasClass(search,"hidden")&&ev.newURL){addClass(search,"hidden");removeClass(main,"hidden");var hash=ev.newURL.slice(ev.newURL.indexOf("#")+1);if(browserSupportsHistoryApi()){history.replaceState(hash,"","?search=#"+hash)}var elem=document.getElementById(hash);if(elem){elem.scrollIntoView()}}if(savedHash!==window.location.hash){savedHash=window.location.hash;if(savedHash.length===0){return}var elem=document.getElementById(savedHash.slice(1));if(!elem||!isHidden(elem)){return}var parent=elem.parentNode;if(parent&&hasClass(parent,"impl-items")){onEachLazy(parent.getElementsByClassName("collapsed"),function(e){if(e.parentNode===parent){e.click();return true}});if(isHidden(elem)){if(hasClass(parent.lastElementChild,"collapse-toggle")){parent.lastElementChild.click()}}}}}function highlightSourceLines(match,ev){if(typeof match==="undefined"){hideSidebar();match=window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/)}if(!match){return}var from=parseInt(match[1],10);var to=from;if(typeof match[2]!=="undefined"){to=parseInt(match[2],10)}if(to0){collapseDocs(collapses[0],"show")}}}}function getVirtualKey(ev){if("key"in ev&&typeof ev.key!="undefined"){return ev.key}var c=ev.charCode||ev.keyCode;if(c==27){return"Escape"}return String.fromCharCode(c)}function getHelpElement(){return document.getElementById("help")}function displayHelp(display,ev,help){var help=help?help:getHelpElement();if(display===true){if(hasClass(help,"hidden")){ev.preventDefault();removeClass(help,"hidden");addClass(document.body,"blur")}}else if(hasClass(help,"hidden")===false){ev.preventDefault();addClass(help,"hidden");removeClass(document.body,"blur")}}function handleEscape(ev){var help=getHelpElement();var search=getSearchElement();hideModal();if(hasClass(help,"hidden")===false){displayHelp(false,ev,help)}else if(hasClass(search,"hidden")===false){ev.preventDefault();addClass(search,"hidden");removeClass(main,"hidden");document.title=titleBeforeSearch}defocusSearchBar()}function handleShortcut(ev){if(ev.ctrlKey||ev.altKey||ev.metaKey||disableShortcuts===true){return}if(document.activeElement.tagName==="INPUT"){switch(getVirtualKey(ev)){case"Escape":handleEscape(ev);break}}else{switch(getVirtualKey(ev)){case"Escape":handleEscape(ev);break;case"s":case"S":displayHelp(false,ev);hideModal();ev.preventDefault();focusSearchBar();break;case"+":case"-":ev.preventDefault();toggleAllDocs();break;case"?":if(ev.shiftKey){hideModal();displayHelp(true,ev)}break}}}function findParentElement(elem,tagName){do{if(elem&&elem.tagName===tagName){return elem}elem=elem.parentNode}while(elem);return null}document.onkeypress=handleShortcut;document.onkeydown=handleShortcut;document.onclick=function(ev){if(hasClass(ev.target,"collapse-toggle")){collapseDocs(ev.target,"toggle")}else if(hasClass(ev.target.parentNode,"collapse-toggle")){collapseDocs(ev.target.parentNode,"toggle")}else if(ev.target.tagName==="SPAN"&&hasClass(ev.target.parentNode,"line-numbers")){var prev_id=0;var set_fragment=function(name){if(browserSupportsHistoryApi()){history.replaceState(null,null,"#"+name);highlightSourceLines()}else{location.replace("#"+name)}};var cur_id=parseInt(ev.target.id,10);if(ev.shiftKey&&prev_id){if(prev_id>cur_id){var tmp=prev_id;prev_id=cur_id;cur_id=tmp}set_fragment(prev_id+"-"+cur_id)}else{prev_id=cur_id;set_fragment(cur_id)}}else if(hasClass(getHelpElement(),"hidden")===false){var help=getHelpElement();var is_inside_help_popup=ev.target!==help&&help.contains(ev.target);if(is_inside_help_popup===false){addClass(help,"hidden");removeClass(document.body,"blur")}}else{var a=findParentElement(ev.target,"A");if(a&&a.hash){expandSection(a.hash.replace(/^#/,""))}}};var x=document.getElementsByClassName("version-selector");if(x.length>0){x[0].onchange=function(){var i,match,url=document.location.href,stripped="",len=rootPath.match(/\.\.\//g).length+1;for(i=0;i-1){var obj=searchIndex[results[i].id];obj.lev=results[i].lev;if(isType!==true||obj.type){var res=buildHrefAndPath(obj);obj.displayPath=pathSplitter(res[0]);obj.fullPath=obj.displayPath+obj.name;obj.fullPath+="|"+obj.ty;obj.href=res[1];out.push(obj);if(out.length>=MAX_RESULTS){break}}}}return out}function sortResults(results,isType){var ar=[];for(var entry in results){if(results.hasOwnProperty(entry)){ar.push(results[entry])}}results=ar;var i;var nresults=results.length;for(i=0;ib?+1:-1)}a=(aaa.index<0);b=(bbb.index<0);if(a!==b){return a-b}a=aaa.index;b=bbb.index;if(a!==b){return a-b}if((aaa.item.ty===TY_PRIMITIVE&&bbb.item.ty!==TY_KEYWORD)||(aaa.item.ty===TY_KEYWORD&&bbb.item.ty!==TY_PRIMITIVE)){return-1}if((bbb.item.ty===TY_PRIMITIVE&&aaa.item.ty!==TY_PRIMITIVE)||(bbb.item.ty===TY_KEYWORD&&aaa.item.ty!==TY_KEYWORD)){return 1}a=(aaa.item.desc==="");b=(bbb.item.desc==="");if(a!==b){return a-b}a=aaa.item.ty;b=bbb.item.ty;if(a!==b){return a-b}a=aaa.item.path;b=bbb.item.path;if(a!==b){return(a>b?+1:-1)}return 0});var length=results.length;for(i=0;i"));return{name:val.substring(0,val.indexOf("<")),generics:values.split(/\s*,\s*/),}}return{name:val,generics:[],}}function checkGenerics(obj,val){var lev_distance=MAX_LEV_DISTANCE+1;if(val.generics.length>0){if(obj.length>GENERICS_DATA&&obj[GENERICS_DATA].length>=val.generics.length){var elems=obj[GENERICS_DATA].slice(0);var total=0;var done=0;var vlength=val.generics.length;for(var y=0;yGENERICS_DATA&&obj[GENERICS_DATA].length>=val.generics.length){var elems=obj[GENERICS_DATA].slice(0);var allFound=true;for(var y=0;allFound===true&&yGENERICS_DATA&&obj[GENERICS_DATA].length!==0){var tmp_lev=checkGenerics(obj,val);if(tmp_lev<=MAX_LEV_DISTANCE){return tmp_lev}}else{return 0}}if(literalSearch===true){if(obj.length>GENERICS_DATA&&obj[GENERICS_DATA].length>0){var length=obj[GENERICS_DATA].length;for(x=0;xGENERICS_DATA&&obj[GENERICS_DATA].length>0){var olength=obj[GENERICS_DATA].length;for(x=0;x0){var length=obj.type[INPUTS_DATA].length;for(var i=0;iOUTPUT_DATA){var ret=obj.type[OUTPUT_DATA];if(!obj.type[OUTPUT_DATA].length){ret=[ret]}for(var x=0;xlength){return MAX_LEV_DISTANCE+1}for(var i=0;ilength){break}var lev_total=0;var aborted=false;for(var x=0;xMAX_LEV_DISTANCE){aborted=true;break}lev_total+=lev}if(aborted===false){ret_lev=Math.min(ret_lev,Math.round(lev_total/clength))}}return ret_lev}function typePassesFilter(filter,type){if(filter<0)return true;if(filter===type)return true;var name=itemTypes[type];switch(itemTypes[filter]){case"constant":return(name=="associatedconstant");case"fn":return(name=="method"||name=="tymethod");case"type":return(name=="primitive"||name=="keyword")}return false}function generateId(ty){if(ty.parent&&ty.parent.name){return itemTypes[ty.ty]+ty.path+ty.parent.name+ty.name}return itemTypes[ty.ty]+ty.path+ty.name}var nSearchWords=searchWords.length;var i;var ty;var fullId;var returned;var in_args;if((val.charAt(0)==="\""||val.charAt(0)==="'")&&val.charAt(val.length-1)===val.charAt(0)){val=extractGenerics(val.substr(1,val.length-2));for(i=0;i")>-1){var trimmer=function(s){return s.trim()};var parts=val.split("->").map(trimmer);var input=parts[0];var inputs=input.split(",").map(trimmer).sort();for(i=0;iOUTPUT_DATA?type[OUTPUT_DATA].name:"";returned=checkReturned(ty,output,true);if(output.name==="*"||returned===true){in_args=false;var is_module=false;if(input==="*"){is_module=true}else{var allFound=true;for(var it=0;allFound===true&&it1?paths.length-1:1);for(j=0;j1){lev=checkPath(contains,paths[paths.length-1],ty);if(lev>MAX_LEV_DISTANCE){continue}else if(lev>0){lev_add=lev/10}}returned=MAX_LEV_DISTANCE+1;in_args=MAX_LEV_DISTANCE+1;var index=-1;lev=MAX_LEV_DISTANCE+1;fullId=generateId(ty);if(searchWords[j].indexOf(split[i])>-1||searchWords[j].indexOf(val)>-1||searchWords[j].replace(/_/g,"").indexOf(val)>-1){if(typePassesFilter(typeFilter,ty.ty)&&results[fullId]===undefined){index=searchWords[j].replace(/_/g,"").indexOf(val)}}if((lev=levenshtein(searchWords[j],val))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){lev=MAX_LEV_DISTANCE+1}else{lev+=1}}if((in_args=findArg(ty,valGenerics))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){in_args=MAX_LEV_DISTANCE+1}}if((returned=checkReturned(ty,valGenerics))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){returned=MAX_LEV_DISTANCE+1}}lev+=lev_add;if(lev>0&&val.length>3&&searchWords[j].indexOf(val)>-1){if(val.length<6){lev-=1}else{lev=0}}if(in_args<=MAX_LEV_DISTANCE){if(results_in_args[fullId]===undefined){results_in_args[fullId]={id:j,index:index,lev:in_args,}}results_in_args[fullId].lev=Math.min(results_in_args[fullId].lev,in_args)}if(returned<=MAX_LEV_DISTANCE){if(results_returned[fullId]===undefined){results_returned[fullId]={id:j,index:index,lev:returned,}}results_returned[fullId].lev=Math.min(results_returned[fullId].lev,returned)}if(index!==-1||lev<=MAX_LEV_DISTANCE){if(index!==-1&&paths.length<2){lev=0}if(results[fullId]===undefined){results[fullId]={id:j,index:index,lev:lev,}}results[fullId].lev=Math.min(results[fullId].lev,lev)}}}var ret={"in_args":sortResults(results_in_args,true),"returned":sortResults(results_returned,true),"others":sortResults(results),};if(ALIASES&&ALIASES[window.currentCrate]&&ALIASES[window.currentCrate][query.raw]){var aliases=ALIASES[window.currentCrate][query.raw];for(i=0;iMAX_RESULTS){ret.others.pop()}}}return ret}function validateResult(name,path,keys,parent){for(var i=0;i-1||path.indexOf(keys[i])>-1||(parent!==undefined&&parent.name.toLowerCase().indexOf(keys[i])>-1)||levenshtein(name,keys[i])<=MAX_LEV_DISTANCE)){return false}}return true}function getQuery(raw){var matches,type,query;query=raw;matches=query.match(/^(fn|mod|struct|enum|trait|type|const|macro)\s*:\s*/i);if(matches){type=matches[1].replace(/^const$/,"constant");query=query.substring(matches[0].length)}return{raw:raw,query:query,type:type,id:query+type}}function initSearchNav(){var hoverTimeout;var click_func=function(e){var el=e.target;while(el.tagName!=="TR"){el=el.parentNode}var dst=e.target.getElementsByTagName("a");if(dst.length<1){return}dst=dst[0];if(window.location.pathname===dst.pathname){addClass(getSearchElement(),"hidden");removeClass(main,"hidden");document.location.href=dst.href}};var mouseover_func=function(e){var el=e.target;while(el.tagName!=="TR"){el=el.parentNode}clearTimeout(hoverTimeout);hoverTimeout=setTimeout(function(){onEachLazy(document.getElementsByClassName("search-results"),function(e){onEachLazy(e.getElementsByClassName("result"),function(i_e){removeClass(i_e,"highlighted")})});addClass(el,"highlighted")},20)};onEachLazy(document.getElementsByClassName("search-results"),function(e){onEachLazy(e.getElementsByClassName("result"),function(i_e){i_e.onclick=click_func;i_e.onmouseover=mouseover_func})});search_input.onkeydown=function(e){var actives=[[],[],[]];var current=0;onEachLazy(document.getElementById("results").childNodes,function(e){onEachLazy(e.getElementsByClassName("highlighted"),function(e){actives[current].push(e)});current+=1});if(e.which===38){if(!actives[currentTab].length||!actives[currentTab][0].previousElementSibling){return}addClass(actives[currentTab][0].previousElementSibling,"highlighted");removeClass(actives[currentTab][0],"highlighted")}else if(e.which===40){if(!actives[currentTab].length){var results=document.getElementById("results").childNodes;if(results.length>0){var res=results[currentTab].getElementsByClassName("result");if(res.length>0){addClass(res[0],"highlighted")}}}else if(actives[currentTab][0].nextElementSibling){addClass(actives[currentTab][0].nextElementSibling,"highlighted");removeClass(actives[currentTab][0],"highlighted")}}else if(e.which===13){if(actives[currentTab].length){document.location.href=actives[currentTab][0].getElementsByTagName("a")[0].href}}else if(e.which===9){if(e.shiftKey){printTab(currentTab>0?currentTab-1:2)}else{printTab(currentTab>1?0:currentTab+1)}e.preventDefault()}else if(e.which===16){}else if(e.which===27){handleEscape(e)}else if(actives[currentTab].length>0){removeClass(actives[currentTab][0],"highlighted")}}}function buildHrefAndPath(item){var displayPath;var href;var type=itemTypes[item.ty];var name=item.name;if(type==="mod"){displayPath=item.path+"::";href=rootPath+item.path.replace(/::/g,"/")+"/"+name+"/index.html"}else if(type==="primitive"||type==="keyword"){displayPath="";href=rootPath+item.path.replace(/::/g,"/")+"/"+type+"."+name+".html"}else if(type==="externcrate"){displayPath="";href=rootPath+name+"/index.html"}else if(item.parent!==undefined){var myparent=item.parent;var anchor="#"+type+"."+name;var parentType=itemTypes[myparent.ty];if(parentType==="primitive"){displayPath=myparent.name+"::"}else{displayPath=item.path+"::"+myparent.name+"::"}href=rootPath+item.path.replace(/::/g,"/")+"/"+parentType+"."+myparent.name+".html"+anchor}else{displayPath=item.path+"::";href=rootPath+item.path.replace(/::/g,"/")+"/"+type+"."+name+".html"}return[displayPath,href]}function escape(content){var h1=document.createElement("h1");h1.textContent=content;return h1.innerHTML}function pathSplitter(path){var tmp=""+path.replace(/::/g,"::");if(tmp.endsWith("")){return tmp.slice(0,tmp.length-6)}return tmp}function addTab(array,query,display){var extraStyle="";if(display===false){extraStyle=" style=\"display: none;\""}var output="";var duplicates={};var length=0;if(array.length>0){output="";array.forEach(function(item){var name,type;name=item.name;type=itemTypes[item.ty];if(item.is_alias!==true){if(duplicates[item.fullPath]){return}duplicates[item.fullPath]=true}length+=1;output+=""});output+="
"+""+(item.is_alias===true?(""+item.alias+"  - see "):"")+item.displayPath+""+name+""+""+""+escape(item.desc)+" 
"}else{output="
No results :(
"+"Try on DuckDuckGo?

"+"Or try looking in one of these:
"}return[output,length]}function makeTabHeader(tabNb,text,nbElems){if(currentTab===tabNb){return"
"+text+"
("+nbElems+")
"}return"
"+text+"
("+nbElems+")
"}function showResults(results){if(results.others.length===1&&getCurrentValue("rustdoc-go-to-only-result")==="true"){var elem=document.createElement("a");elem.href=results.others[0].href;elem.style.display="none";document.body.appendChild(elem);elem.click()}var query=getQuery(search_input.value);currentResults=query.id;var ret_others=addTab(results.others,query);var ret_in_args=addTab(results.in_args,query,false);var ret_returned=addTab(results.returned,query,false);var output="

Results for "+escape(query.query)+(query.type?" (type: "+escape(query.type)+")":"")+"

"+"
"+makeTabHeader(0,"In Names",ret_others[1])+makeTabHeader(1,"In Parameters",ret_in_args[1])+makeTabHeader(2,"In Return Types",ret_returned[1])+"
"+ret_others[0]+ret_in_args[0]+ret_returned[0]+"
";addClass(main,"hidden");var search=getSearchElement();removeClass(search,"hidden");search.innerHTML=output;var tds=search.getElementsByTagName("td");var td_width=0;if(tds.length>0){td_width=tds[0].offsetWidth}var width=search.offsetWidth-40-td_width;onEachLazy(search.getElementsByClassName("desc"),function(e){e.style.width=width+"px"});initSearchNav();var elems=document.getElementById("titles").childNodes;elems[0].onclick=function(){printTab(0)};elems[1].onclick=function(){printTab(1)};elems[2].onclick=function(){printTab(2)};printTab(currentTab)}function execSearch(query,searchWords,filterCrates){function getSmallest(arrays,positions,notDuplicates){var start=null;for(var it=0;itpositions[it]&&(start===null||start>arrays[it][positions[it]].lev)&&!notDuplicates[arrays[it][positions[it]].fullPath]){start=arrays[it][positions[it]].lev}}return start}function mergeArrays(arrays){var ret=[];var positions=[];var notDuplicates={};for(var x=0;xpositions[x]&&arrays[x][positions[x]].lev===smallest&&!notDuplicates[arrays[x][positions[x]].fullPath]){ret.push(arrays[x][positions[x]]);notDuplicates[arrays[x][positions[x]].fullPath]=true;positions[x]+=1}}}return ret}var queries=query.raw.split(",");var results={"in_args":[],"returned":[],"others":[],};for(var i=0;i1){return{"in_args":mergeArrays(results.in_args),"returned":mergeArrays(results.returned),"others":mergeArrays(results.others),}}else{return{"in_args":results.in_args[0],"returned":results.returned[0],"others":results.others[0],}}}function getFilterCrates(){var elem=document.getElementById("crate-search");if(elem&&elem.value!=="All crates"&&rawSearchIndex.hasOwnProperty(elem.value)){return elem.value}return undefined}function search(e,forced){var params=getQueryStringParams();var query=getQuery(search_input.value.trim());if(e){e.preventDefault()}if(query.query.length===0){return}if(forced!==true&&query.id===currentResults){if(query.query.length>0){putBackSearch(search_input)}return}document.title="Results for "+query.query+" - Rust";if(browserSupportsHistoryApi()){if(!history.state&&!params.search){history.pushState(query,"","?search="+encodeURIComponent(query.raw))}else{history.replaceState(query,"","?search="+encodeURIComponent(query.raw))}}var filterCrates=getFilterCrates();showResults(execSearch(query,index,filterCrates),filterCrates)}function buildIndex(rawSearchIndex){searchIndex=[];var searchWords=[];var i;for(var crate in rawSearchIndex){if(!rawSearchIndex.hasOwnProperty(crate)){continue}searchWords.push(crate);searchIndex.push({crate:crate,ty:1,name:crate,path:"",desc:rawSearchIndex[crate].doc,type:null,});var items=rawSearchIndex[crate].i;var paths=rawSearchIndex[crate].p;var len=paths.length;for(i=0;i"+""+"
"+code.outerHTML+"
";list.appendChild(display)}}};if(window.pending_implementors){window.register_implementors(window.pending_implementors)}function labelForToggleButton(sectionIsCollapsed){if(sectionIsCollapsed){return"+"}return"\u2212"}function onEveryMatchingChild(elem,className,func){if(elem&&className&&func){var length=elem.childNodes.length;var nodes=elem.childNodes;for(var i=0;i"+labelForToggleButton(sectionIsCollapsed)+"
]";return toggle}var toggle=createSimpleToggle(false);var hideMethodDocs=getCurrentValue("rustdoc-auto-hide-method-docs")==="true";var pageId=getPageId();var func=function(e){var next=e.nextElementSibling;if(!next){return}if(hasClass(next,"docblock")===true||(hasClass(next,"stability")===true&&hasClass(next.nextElementSibling,"docblock")===true)){var newToggle=toggle.cloneNode(true);insertAfter(newToggle,e.childNodes[e.childNodes.length-1]);if(hideMethodDocs===true&&hasClass(e,"method")===true){collapseDocs(newToggle,"hide",pageId)}}};var funcImpl=function(e){var next=e.nextElementSibling;if(next&&hasClass(next,"docblock")){next=next.nextElementSibling}if(!next){return}if(next.getElementsByClassName("method").length>0&&hasClass(e,"impl")){insertAfter(toggle.cloneNode(true),e.childNodes[e.childNodes.length-1])}};onEachLazy(document.getElementsByClassName("method"),func);onEachLazy(document.getElementsByClassName("associatedconstant"),func);onEachLazy(document.getElementsByClassName("impl"),funcImpl);var impl_call=function(){};if(hideMethodDocs===true){impl_call=function(e,newToggle,pageId){if(e.id.match(/^impl(?:-\d+)?$/)===null){if(hasClass(e,"impl")===true){collapseDocs(newToggle,"hide",pageId)}}}}var newToggle=document.createElement("a");newToggle.href="javascript:void(0)";newToggle.className="collapse-toggle hidden-default collapsed";newToggle.innerHTML="["+labelForToggleButton(true)+"] Show hidden undocumented items";function toggleClicked(){if(hasClass(this,"collapsed")){removeClass(this,"collapsed");onEachLazy(this.parentNode.getElementsByClassName("hidden"),function(x){if(hasClass(x,"content")===false){removeClass(x,"hidden");addClass(x,"x")}},true);this.innerHTML="["+labelForToggleButton(false)+"] Hide undocumented items"}else{addClass(this,"collapsed");onEachLazy(this.parentNode.getElementsByClassName("x"),function(x){if(hasClass(x,"content")===false){addClass(x,"hidden");removeClass(x,"x")}},true);this.innerHTML="["+labelForToggleButton(true)+"] Show hidden undocumented items"}}onEachLazy(document.getElementsByClassName("impl-items"),function(e){onEachLazy(e.getElementsByClassName("associatedconstant"),func);var hiddenElems=e.getElementsByClassName("hidden");var needToggle=false;var hlength=hiddenElems.length;for(var i=0;i0){inner[0].innerHTML="+"}}if(extraClass){addClass(wrapper,extraClass)}wrapper.appendChild(mainToggle);return wrapper}var currentType=document.getElementsByClassName("type-decl")[0];var className=null;if(currentType){currentType=currentType.getElementsByClassName("rust")[0];if(currentType){currentType.classList.forEach(function(item){if(item!=="main"){className=item;return true}})}}var showItemDeclarations=getCurrentValue("rustdoc-auto-hide-"+className);if(showItemDeclarations===null){if(className==="enum"||className==="macro"){showItemDeclarations="false"}else if(className==="struct"||className==="union"||className==="trait"){showItemDeclarations="true"}else{showItemDeclarations=getCurrentValue("rustdoc-auto-hide-declarations")}}showItemDeclarations=showItemDeclarations==="false";function buildToggleWrapper(e){if(hasClass(e,"autohide")){var wrap=e.previousElementSibling;if(wrap&&hasClass(wrap,"toggle-wrapper")){var inner_toggle=wrap.childNodes[0];var extra=e.childNodes[0].tagName==="H3";e.style.display="none";addClass(wrap,"collapsed");onEachLazy(inner_toggle.getElementsByClassName("inner"),function(e){e.innerHTML=labelForToggleButton(true)});onEachLazy(inner_toggle.getElementsByClassName("toggle-label"),function(e){e.style.display="inline-block";if(extra===true){i_e.innerHTML=" Show "+e.childNodes[0].innerHTML}})}}if(e.parentNode.id==="main"){var otherMessage="";var fontSize;var extraClass;if(hasClass(e,"type-decl")){fontSize="20px";otherMessage=" Show declaration";if(showItemDeclarations===false){extraClass="collapsed"}}else if(hasClass(e,"sub-variant")){otherMessage=" Show fields"}else if(hasClass(e,"non-exhaustive")){otherMessage=" This ";if(hasClass(e,"non-exhaustive-struct")){otherMessage+="struct"}else if(hasClass(e,"non-exhaustive-enum")){otherMessage+="enum"}else if(hasClass(e,"non-exhaustive-variant")){otherMessage+="enum variant"}else if(hasClass(e,"non-exhaustive-type")){otherMessage+="type"}otherMessage+=" is marked as non-exhaustive"}else if(hasClass(e.childNodes[0],"impl-items")){extraClass="marg-left"}e.parentNode.insertBefore(createToggle(otherMessage,fontSize,extraClass,hasClass(e,"type-decl")===false||showItemDeclarations===true),e);if(hasClass(e,"type-decl")===true&&showItemDeclarations===true){collapseDocs(e.previousSibling.childNodes[0],"toggle")}if(hasClass(e,"non-exhaustive")===true){collapseDocs(e.previousSibling.childNodes[0],"toggle")}}}onEachLazy(document.getElementsByClassName("docblock"),buildToggleWrapper);onEachLazy(document.getElementsByClassName("sub-variant"),buildToggleWrapper);function createToggleWrapper(tog){var span=document.createElement("span");span.className="toggle-label";span.style.display="none";span.innerHTML=" Expand attributes";tog.appendChild(span);var wrapper=document.createElement("div");wrapper.className="toggle-wrapper toggle-attributes";wrapper.appendChild(tog);return wrapper}var itemAttributesFunc=function(){};if(getCurrentValue("rustdoc-auto-hide-attributes")!=="false"){itemAttributesFunc=function(x){collapseDocs(x.previousSibling.childNodes[0],"toggle")}}var attributesToggle=createToggleWrapper(createSimpleToggle(false));onEachLazy(main.getElementsByClassName("attributes"),function(i_e){var attr_tog=attributesToggle.cloneNode(true);if(hasClass(i_e,"top-attr")===true){addClass(attr_tog,"top-attr")}i_e.parentNode.insertBefore(attr_tog,i_e);itemAttributesFunc(i_e)});var lineNumbersFunc=function(){};if(getCurrentValue("rustdoc-line-numbers")==="true"){lineNumbersFunc=function(x){var count=x.textContent.split("\n").length;var elems=[];for(var i=0;i
✕"+"
"+content+"";document.getElementsByTagName("body")[0].appendChild(modal);document.getElementById("modal-close").onclick=hideModal;modal.onclick=hideModal}function hideModal(){var modal=document.getElementById("important");if(modal){modal.parentNode.removeChild(modal)}}onEachLazy(document.getElementsByClassName("important-traits"),function(e){e.onclick=function(){showModal(e.lastElementChild.innerHTML)}});function printTab(nb){if(nb===0||nb===1||nb===2){currentTab=nb}var nb_copy=nb;onEachLazy(document.getElementById("titles").childNodes,function(elem){if(nb_copy===0){addClass(elem,"selected")}else{removeClass(elem,"selected")}nb_copy-=1});onEachLazy(document.getElementById("results").childNodes,function(elem){if(nb===0){elem.style.display=""}else{elem.style.display="none"}nb-=1})}function putBackSearch(search_input){if(search_input.value!==""){addClass(main,"hidden");removeClass(getSearchElement(),"hidden");if(browserSupportsHistoryApi()){history.replaceState(search_input.value,"","?search="+encodeURIComponent(search_input.value))}}}if(search_input){search_input.onfocus=function(){putBackSearch(this)}}var params=getQueryStringParams();if(params&¶ms.search){addClass(main,"hidden");var search=getSearchElement();removeClass(search,"hidden");search.innerHTML="

Loading search results...

"}var sidebar_menu=document.getElementsByClassName("sidebar-menu")[0];if(sidebar_menu){sidebar_menu.onclick=function(){var sidebar=document.getElementsByClassName("sidebar")[0];if(hasClass(sidebar,"mobile")===true){hideSidebar()}else{showSidebar()}}}window.onresize=function(){hideSidebar()};autoCollapse(getPageId(),getCurrentValue("rustdoc-collapse")==="true");if(window.location.hash&&window.location.hash.length>0){expandSection(window.location.hash.replace(/^#/,""))}if(main){onEachLazy(main.getElementsByClassName("loading-content"),function(e){e.remove()});onEachLazy(main.childNodes,function(e){if(e.tagName==="H2"||e.tagName==="H3"){var nextTagName=e.nextElementSibling.tagName;if(nextTagName=="H2"||nextTagName=="H3"){e.nextElementSibling.style.display="flex"}else{e.nextElementSibling.style.display="block"}}})}function addSearchOptions(crates){var elem=document.getElementById("crate-search");if(!elem){return}var crates_text=[];if(Object.keys(crates).length>1){for(var crate in crates){if(crates.hasOwnProperty(crate)){crates_text.push(crate)}}}crates_text.sort(function(a,b){var lower_a=a.toLowerCase();var lower_b=b.toLowerCase();if(lower_alower_b){return 1}return 0});for(var i=0;i"
"+x[0]+"
"+x[1]+"
").join("");var div_shortcuts=document.createElement("div");addClass(div_shortcuts,"shortcuts");div_shortcuts.innerHTML="

Keyboard Shortcuts

"+shortcuts+"
";var infos=["Prefix searches with a type followed by a colon (e.g., fn:) to \ + restrict the search to a given type.","Accepted types are: fn, mod, struct, \ + enum, trait, type, macro, \ + and const.","Search functions by type signature (e.g., vec -> usize or \ + * -> vec)","Search multiple things at once by splitting your query with comma (e.g., \ + str,u8 or String,struct:Vec,test)","You can look for items with an exact name by putting double quotes around \ + your request: \"string\"","Look for items inside another one by searching for a path: vec::Vec",].map(x=>"

"+x+"

").join("");var div_infos=document.createElement("div");addClass(div_infos,"infos");div_infos.innerHTML="

Search Tricks

"+infos;container.appendChild(div_shortcuts);container.appendChild(div_infos);popup.appendChild(container);insertAfter(popup,getSearchElement())}onHashChange();window.onhashchange=onHashChange;buildHelperPopup()}());function focusSearchBar(){getSearchInput().focus()}function defocusSearchBar(){getSearchInput().blur()} \ No newline at end of file diff --git a/normalize.css b/normalize.css new file mode 100644 index 0000000..45b6cb2 --- /dev/null +++ b/normalize.css @@ -0,0 +1,2 @@ +/*! 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} \ No newline at end of file diff --git a/noscript.css b/noscript.css new file mode 100644 index 0000000..351b41c --- /dev/null +++ b/noscript.css @@ -0,0 +1 @@ +#main>h2+div,#main>h2+h3,#main>h3+div{display:block;}.loading-content{display:none;}#main>h2+div,#main>h3+div{display:block;}#main>h2+h3{display:flex;} \ No newline at end of file diff --git a/rocket_cors/all.html b/rocket_cors/all.html new file mode 100644 index 0000000..8d1a602 --- /dev/null +++ b/rocket_cors/all.html @@ -0,0 +1,3 @@ +List of all items in this crate

[] + + List of all items

Structs

Enums

Functions

Typedefs

\ No newline at end of file diff --git a/rocket_cors/enum.AllOrSome.html b/rocket_cors/enum.AllOrSome.html new file mode 100644 index 0000000..5a8cfb3 --- /dev/null +++ b/rocket_cors/enum.AllOrSome.html @@ -0,0 +1,41 @@ +rocket_cors::AllOrSome - Rust

[][src]Enum rocket_cors::AllOrSome

pub enum AllOrSome<T> {
+    All,
+    Some(T),
+}

An enum signifying that some of type T is allowed, or All (everything is allowed).

+

Default is implemented for this enum and is All.

+

This enum is serialized and deserialized +"Externally tagged"

+

+ Variants

+
All

Everything is allowed. Usually equivalent to the "*" value.

+
Some(T)

Only some of T is allowed

+

Methods

impl<T> AllOrSome<T>[src]

pub fn is_all(&self) -> bool[src]

Returns whether this is an All variant

+

pub fn is_some(&self) -> bool[src]

Returns whether this is a Some variant

+

pub fn unwrap(self) -> T[src]

Unwrap a Some variant and get its inner value

+

Panics

+

Panics if the variant is All

+

Trait Implementations

impl<T: Clone> Clone for AllOrSome<T>[src]

impl<T> Default for AllOrSome<T>[src]

impl<T: Eq> Eq for AllOrSome<T>[src]

impl<T: PartialEq> PartialEq<AllOrSome<T>> for AllOrSome<T>[src]

impl<T: Debug> Debug for AllOrSome<T>[src]

impl<T> StructuralPartialEq for AllOrSome<T>[src]

impl<T> StructuralEq for AllOrSome<T>[src]

impl<T> Serialize for AllOrSome<T> where
    T: Serialize
[src]

impl<'de, T> Deserialize<'de> for AllOrSome<T> where
    T: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<T> Send for AllOrSome<T> where
    T: Send

impl<T> Sync for AllOrSome<T> where
    T: Sync

impl<T> Unpin for AllOrSome<T> where
    T: Unpin

impl<T> UnwindSafe for AllOrSome<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for AllOrSome<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

\ No newline at end of file diff --git a/rocket_cors/enum.Error.html b/rocket_cors/enum.Error.html new file mode 100644 index 0000000..018bb91 --- /dev/null +++ b/rocket_cors/enum.Error.html @@ -0,0 +1,61 @@ +rocket_cors::Error - Rust

[][src]Enum rocket_cors::Error

pub enum Error {
+    MissingOrigin,
+    BadOrigin(ParseError),
+    OpaqueAllowedOrigin(Vec<String>),
+    MissingRequestMethod,
+    BadRequestMethod,
+    MissingRequestHeaders,
+    OriginNotAllowed(String),
+    MethodNotAllowed(String),
+    RegexError(Error),
+    HeadersNotAllowed,
+    CredentialsWithWildcardOrigin,
+    MissingCorsInRocketState,
+    MissingInjectedHeader,
+}

Errors during operations

+

This enum implements rocket::response::Responder which will return an appropriate status code +while printing out the error in the console. +Because these errors are usually the result of an error while trying to respond to a CORS +request, CORS headers cannot be added to the response and your applications requesting CORS +will not be able to see the status code.

+

+ Variants

+
MissingOrigin

The HTTP request header Origin is required but was not provided

+
BadOrigin(ParseError)

The HTTP request header Origin could not be parsed correctly.

+
OpaqueAllowedOrigin(Vec<String>)

The configured Allowed Origins are Opaque origins. Use a Regex instead.

+
MissingRequestMethod

The request header Access-Control-Request-Method is required but is missing

+
BadRequestMethod

The request header Access-Control-Request-Method has an invalid value

+
MissingRequestHeaders

The request header Access-Control-Request-Headers is required but is missing.

+
OriginNotAllowed(String)

Origin is not allowed to make this request

+
MethodNotAllowed(String)

Requested method is not allowed

+
RegexError(Error)

A regular expression compilation error

+
HeadersNotAllowed

One or more headers requested are not allowed

+
CredentialsWithWildcardOrigin

Credentials are allowed, but the Origin is set to "*". This is not allowed by W3C

+

This is a misconfiguration. Check the docuemntation for Cors.

+
MissingCorsInRocketState

A CORS Request Guard was used, but no CORS Options was available in Rocket's state

+

This is a misconfiguration. Use Rocket::manage to add a CORS options to managed state.

+
MissingInjectedHeader

The on_response handler of Fairing could not find the injected header from the Request. +Either some other fairing has removed it, or this is a bug.

+

Trait Implementations

impl From<ParseError> for Error[src]

impl From<Error> for Error[src]

impl Display for Error[src]

impl Debug for Error[src]

impl Error for Error[src]

impl<'r> Responder<'r> for Error[src]

Auto Trait Implementations

impl Send for Error

impl Sync for Error

impl Unpin for Error

impl UnwindSafe for Error

impl RefUnwindSafe for Error

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

\ No newline at end of file diff --git a/rocket_cors/fn.catch_all_options_routes.html b/rocket_cors/fn.catch_all_options_routes.html new file mode 100644 index 0000000..429e0ec --- /dev/null +++ b/rocket_cors/fn.catch_all_options_routes.html @@ -0,0 +1,7 @@ +rocket_cors::catch_all_options_routes - Rust

[][src]Function rocket_cors::catch_all_options_routes

pub fn catch_all_options_routes() -> Vec<Route>

Returns "catch all" OPTIONS routes that you can mount to catch all OPTIONS request. Only works +if you have put a Cors struct into Rocket's managed state.

+

This route has very high rank (and therefore low priority) of +max value +so you can define your own to override this route's behaviour.

+

See the documentation at the crate root for usage information.

+
\ No newline at end of file diff --git a/rocket_cors/headers/enum.Origin.html b/rocket_cors/headers/enum.Origin.html new file mode 100644 index 0000000..ca87f79 --- /dev/null +++ b/rocket_cors/headers/enum.Origin.html @@ -0,0 +1,47 @@ +rocket_cors::headers::Origin - Rust

[][src]Enum rocket_cors::headers::Origin

pub enum Origin {
+    Null,
+    Parsed(Origin),
+    Opaque(String),
+}

The Origin request header used in CORS

+

You can use this as a rocket Request Guard +to ensure that Origin is passed in correctly.

+

Reference: Mozilla

+

+ Variants

+
Null

A null Origin

+
Parsed(Origin)

A well-formed origin that was parsed by url::Url::origin

+
Opaque(String)

An unknown "opaque" origin that could not be parsed

+

Methods

impl Origin[src]

pub fn ascii_serialization(&self) -> String[src]

Perform an +ASCII serialization +of this origin.

+

pub fn is_tuple(&self) -> bool[src]

Returns whether the origin was parsed as non-opaque

+

Trait Implementations

impl Clone for Origin[src]

impl Eq for Origin[src]

impl PartialEq<Origin> for Origin[src]

impl Display for Origin[src]

impl Debug for Origin[src]

impl FromStr for Origin[src]

type Err = Error

The associated error which can be returned from parsing.

+

impl Hash for Origin[src]

impl StructuralPartialEq for Origin[src]

impl StructuralEq for Origin[src]

impl<'a, 'r> FromRequest<'a, 'r> for Origin[src]

type Error = Error

The associated error to be returned if derivation fails.

+

Auto Trait Implementations

impl Send for Origin

impl Sync for Origin

impl Unpin for Origin

impl UnwindSafe for Origin

impl RefUnwindSafe for Origin

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

\ No newline at end of file diff --git a/rocket_cors/headers/index.html b/rocket_cors/headers/index.html new file mode 100644 index 0000000..0089c0e --- /dev/null +++ b/rocket_cors/headers/index.html @@ -0,0 +1,10 @@ +rocket_cors::headers - Rust

[][src]Module rocket_cors::headers

CORS specific Request Headers

+

Structs

+
AccessControlRequestHeaders

The Access-Control-Request-Headers request header

+
AccessControlRequestMethod

The Access-Control-Request-Method request header

+
HeaderFieldName

A case insensitive header name

+

Enums

+
Origin

The Origin request header used in CORS

+

Type Definitions

+
HeaderFieldNamesSet

A set of case insensitive header names

+
\ No newline at end of file diff --git a/rocket_cors/headers/sidebar-items.js b/rocket_cors/headers/sidebar-items.js new file mode 100644 index 0000000..dc9cdf1 --- /dev/null +++ b/rocket_cors/headers/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"enum":[["Origin","The `Origin` request header used in CORS"]],"struct":[["AccessControlRequestHeaders","The `Access-Control-Request-Headers` request header"],["AccessControlRequestMethod","The `Access-Control-Request-Method` request header"],["HeaderFieldName","A case insensitive header name"]],"type":[["HeaderFieldNamesSet","A set of case insensitive header names"]]}); \ No newline at end of file diff --git a/rocket_cors/headers/struct.AccessControlRequestHeaders.html b/rocket_cors/headers/struct.AccessControlRequestHeaders.html new file mode 100644 index 0000000..221bb97 --- /dev/null +++ b/rocket_cors/headers/struct.AccessControlRequestHeaders.html @@ -0,0 +1,24 @@ +rocket_cors::headers::AccessControlRequestHeaders - Rust

[][src]Struct rocket_cors::headers::AccessControlRequestHeaders

pub struct AccessControlRequestHeaders(pub HeaderFieldNamesSet);

The Access-Control-Request-Headers request header

+

You can use this as a rocket Request Guard +to ensure that the header is passed in correctly.

+

Trait Implementations

impl Eq for AccessControlRequestHeaders[src]

impl PartialEq<AccessControlRequestHeaders> for AccessControlRequestHeaders[src]

impl Debug for AccessControlRequestHeaders[src]

impl FromStr for AccessControlRequestHeaders[src]

Will never fail

+

type Err = ()

The associated error which can be returned from parsing.

+

fn from_str(headers: &str) -> Result<Self, Self::Err>[src]

Will never fail

+

impl StructuralPartialEq for AccessControlRequestHeaders[src]

impl StructuralEq for AccessControlRequestHeaders[src]

impl<'a, 'r> FromRequest<'a, 'r> for AccessControlRequestHeaders[src]

type Error = Error

The associated error to be returned if derivation fails.

+

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

\ No newline at end of file diff --git a/rocket_cors/headers/struct.AccessControlRequestMethod.html b/rocket_cors/headers/struct.AccessControlRequestMethod.html new file mode 100644 index 0000000..561ccfd --- /dev/null +++ b/rocket_cors/headers/struct.AccessControlRequestMethod.html @@ -0,0 +1,20 @@ +rocket_cors::headers::AccessControlRequestMethod - Rust

[][src]Struct rocket_cors::headers::AccessControlRequestMethod

pub struct AccessControlRequestMethod(pub Method);

The Access-Control-Request-Method request header

+

You can use this as a rocket Request Guard +to ensure that the header is passed in correctly.

+

Trait Implementations

impl Debug for AccessControlRequestMethod[src]

impl FromStr for AccessControlRequestMethod[src]

type Err = ()

The associated error which can be returned from parsing.

+

impl<'a, 'r> FromRequest<'a, 'r> for AccessControlRequestMethod[src]

type Error = Error

The associated error to be returned if derivation fails.

+

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

\ No newline at end of file diff --git a/rocket_cors/headers/struct.HeaderFieldName.html b/rocket_cors/headers/struct.HeaderFieldName.html new file mode 100644 index 0000000..3fc67ce --- /dev/null +++ b/rocket_cors/headers/struct.HeaderFieldName.html @@ -0,0 +1,35 @@ +rocket_cors::headers::HeaderFieldName - Rust

[][src]Struct rocket_cors::headers::HeaderFieldName

pub struct HeaderFieldName(_);

A case insensitive header name

+

Trait Implementations

impl<'a> From<&'a str> for HeaderFieldName[src]

impl<'a> From<String> for HeaderFieldName[src]

impl Clone for HeaderFieldName[src]

impl Eq for HeaderFieldName[src]

impl PartialEq<HeaderFieldName> for HeaderFieldName[src]

impl Display for HeaderFieldName[src]

impl Debug for HeaderFieldName[src]

impl FromStr for HeaderFieldName[src]

type Err = <String as FromStr>::Err

The associated error which can be returned from parsing.

+

impl Deref for HeaderFieldName[src]

type Target = String

The resulting type after dereferencing.

+

impl Hash for HeaderFieldName[src]

impl StructuralPartialEq for HeaderFieldName[src]

impl StructuralEq for HeaderFieldName[src]

impl Serialize for HeaderFieldName[src]

impl<'de> Deserialize<'de> for HeaderFieldName[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

\ No newline at end of file diff --git a/rocket_cors/headers/type.HeaderFieldNamesSet.html b/rocket_cors/headers/type.HeaderFieldNamesSet.html new file mode 100644 index 0000000..d5bedf8 --- /dev/null +++ b/rocket_cors/headers/type.HeaderFieldNamesSet.html @@ -0,0 +1,2 @@ +rocket_cors::headers::HeaderFieldNamesSet - Rust

[][src]Type Definition rocket_cors::headers::HeaderFieldNamesSet

type HeaderFieldNamesSet = HashSet<HeaderFieldName>;

A set of case insensitive header names

+
\ No newline at end of file diff --git a/rocket_cors/index.html b/rocket_cors/index.html new file mode 100644 index 0000000..2a9baa9 --- /dev/null +++ b/rocket_cors/index.html @@ -0,0 +1,193 @@ +rocket_cors - Rust

[][src]Crate rocket_cors

Build Status +Repository +Crates.io

+ +

Cross-origin resource sharing (CORS) for Rocket applications

+

Requirements

+
    +
  • Nightly Rust
  • +
  • Rocket >= 0.4
  • +
+

If you are using Rocket 0.3, use the 0.3.0 version of this crate.

+

Nightly Rust

+

Rocket requires nightly Rust. You should probably install Rust with +rustup, then override the code directory to use nightly instead of +stable. See +installation instructions.

+

In particular, rocket_cors is currently targetted for the latest nightly. Older nightlies +might work, but they are subject to the minimum that Rocket sets.

+

Installation

+

Add the following to Cargo.toml:

+
rocket_cors = "0.5.1"
+
+

To use the latest master branch, for example:

+
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" }
+
+

Features

+

By default, a serialization feature is enabled in this crate that allows you to (de)serialize +the CorsOptions struct that is described below. If you would like to disable this, simply +change your Cargo.toml to:

+
rocket_cors = { version = "0.5.1", default-features = false }
+
+

Usage

+

Before you can add CORS responses to your application, you need to create a CorsOptions +struct that will hold the settings. Then, you need to create a Cors struct using +CorsOptions::to_cors which will validate and optimise the settings for Rocket to use.

+

Each of the examples can be run off the repository via cargo run --example xxx where xxx is

+
    +
  • fairing
  • +
  • guard
  • +
  • manual
  • +
+

CorsOptions Struct

+

The CorsOptions struct contains the settings for CORS requests to be validated +and for responses to be generated. Defaults are defined for every field in the struct, and +are documented on the CorsOptions page. You can also deserialize +the struct from some format like JSON, YAML or TOML when the default serialization feature +is enabled.

+

Cors Struct

+

The Cors struct is what will be used with Rocket. After creating or deserializing a +CorsOptions struct, use CorsOptions::to_cors to create a Cors struct.

+

Three modes of operation

+

You can add CORS to your routes via one of three ways, in descending order of ease and in +ascending order of flexibility.

+
    +
  • Fairing (should only used exclusively)
  • +
  • Request Guard
  • +
  • Truly Manual
  • +
+

Unfortunately, you cannot mix and match Fairing with any other of the methods, due to the +limitation of Rocket's fairing API. That is, the checks for Fairing will always happen first, +and if they fail, the route is never executed and so your guard or manual checks will never +get executed.

+

You can, however, mix and match guards and manual checks.

+

In summary:

+ + + + +
FairingRequest GuardManual
Must apply to all routes✔✗✗
Different settings for different routes✗✗✔
May define custom OPTIONS routes✗✔✔
+

Fairing

+

Fairing is the easiest to use and also the most inflexible. You don't have to define OPTIONS +routes for your application, and the checks are done transparently.

+

However, you can only have one set of settings that must apply to all routes. You cannot opt +any route out of CORS checks.

+

To use this, simply create a Cors from CorsOptions::to_cors and then +attach it to Rocket.

+

Refer to the example.

+

Injected Route

+

The fairing implementation will inject a route during attachment to Rocket. This route is used +to handle errors during CORS validation.

+

This is due to the limitation in Rocket's Fairing +lifecycle. Ideally, we want to validate the CORS request +during on_request, and if the validation fails, we want to stop the route from even executing +to

+
    +
  1. prevent side effects
  2. +
  3. prevent resource usage from unnecessary computation
  4. +
+

The only way to do this is to hijack the request and route it to our own injected route to +handle errors. Rocket does not allow Fairings to stop the processing of a route.

+

You can configure the behaviour of the injected route through a couple of fields in the +CorsOptions.

+

Request Guard

+

Using request guard requires you to sacrifice the convenience of Fairings for being able to +opt some routes out of CORS checks and enforcement. BUT you are still restricted to only +one set of CORS settings and you have to mount additional routes to catch and process OPTIONS +requests. The OPTIONS routes are used for CORS preflight checks.

+

You will have to do the following:

+
    +
  • Create a Cors from CorsOptions and during Rocket's ignite, add the struct to +Rocket's managed state.
  • +
  • For all the routes that you want to enforce CORS on, you can mount either some +catch all route or define your own route for the OPTIONS +verb.
  • +
  • Then in all the routes you want to enforce CORS on, add a +Request Guard for the +Guard struct in the route arguments. You should not wrap this in an +Option or Result because the guard will let non-CORS requests through and will take over +error handling in case of errors.
  • +
  • In your routes, to add CORS headers to your responses, use the appropriate functions on the +Guard for a Response or a Responder.
  • +
+

Refer to the example.

+

Truly Manual

+

This mode is the most difficult to use but offers the most amount of flexibility. +You might have to understand how the library works internally to know how to use this mode. +In exchange, you can selectively choose which routes to offer CORS protection to, and you +can mix and match CORS settings for the routes. You can combine usage of this mode with +"guard" to offer a mix of ease of use and flexibility.

+

You really do not need to use this unless you have a truly ad-hoc need to respond to CORS +differently in a route. For example, you have a ping endpoint that allows all origins but +the rest of your routes do not.

+

Handler

+

This mode requires that you pass in a closure that will be lazily evaluated once a CORS request +has been validated. If validation fails, the closure will not be run. You should put any code +that has any side effects or with an appreciable computation cost inside this handler.

+

Steps to perform:

+
    +
  • You will first need to have a Cors struct ready. This struct can be borrowed with a lifetime +at least as long as 'r which is the lifetime of a Rocket request. 'static works too. +In this case, you might as well use the Guard method above and place the Cors struct in +Rocket's state. +Alternatively, you can create a Cors struct directly in the route.
  • +
  • Your routes might need to have a 'r lifetime and return impl Responder<'r>. See below.
  • +
  • Using the Cors struct, use either the +Cors::respond_owned or +Cors::respond_borrowed function and pass in a handler +that will be executed once CORS validation is successful.
  • +
  • Your handler will be passed a Guard which you will have to use to +add CORS headers into your own response.
  • +
  • You will have to manually define your own OPTIONS routes.
  • +
+

Notes about route lifetime

+

You might have to specify a 'r lifetime in your routes and then return impl Responder<'r>. +If you are not sure what to do, you can try to leave the lifetime out and then add it in +when the compiler complains.

+

Generally, you will need to manually annotate the lifetime for the following cases where +the compiler is unable to elide +the lifetime:

+
    +
  • Your function arguments do not borrow anything.
  • +
  • Your function arguments borrow from more than one lifetime.
  • +
  • Your function arguments borrow from a lifetime that is shorter than the 'r lifetime +required.
  • +
+

You can see examples when the lifetime annotation is required (or not) in examples/manual.rs.

+

See the example.

+

Mixing Guard and Manual

+

You can mix Guard and Truly Manual modes together for your application. For example, your +application might restrict the Origins that can access it, except for one ping route that +allows all access.

+

See the example.

+

Reference

+ +

Modules

+
headers

CORS specific Request Headers

+

Structs

+
Cors

Response generator and Fairing for CORS

+
CorsOptions

Configuration options for CORS request handling.

+
Guard

A request guard to check CORS headers +before a route is run. Will not execute the route if checks fail.

+
ManualResponder

A Manual Responder used in the "truly manual" mode of operation.

+
Method

A wrapper type around rocket::http::Method to support serialization and deserialization

+
Origins

Origins that are allowed to make CORS requests.

+
Responder

A Responder which will simply wraps another +Responder with CORS headers.

+

Enums

+
AllOrSome

An enum signifying that some of type T is allowed, or All (everything is allowed).

+
Error

Errors during operations

+

Functions

+
catch_all_options_routes

Returns "catch all" OPTIONS routes that you can mount to catch all OPTIONS request. Only works +if you have put a Cors struct into Rocket's managed state.

+

Type Definitions

+
AllowedHeaders

A list of allowed headers

+
AllowedMethods

A list of allowed methods

+
AllowedOrigins

A list of allowed origins. Either Some origins are allowed, or all origins are allowed.

+
\ No newline at end of file diff --git a/rocket_cors/sidebar-items.js b/rocket_cors/sidebar-items.js new file mode 100644 index 0000000..9ca38d4 --- /dev/null +++ b/rocket_cors/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"enum":[["AllOrSome","An enum signifying that some of type T is allowed, or `All` (everything is allowed)."],["Error","Errors during operations"]],"fn":[["catch_all_options_routes","Returns \"catch all\" OPTIONS routes that you can mount to catch all OPTIONS request. Only works if you have put a `Cors` struct into Rocket's managed state."]],"mod":[["headers","CORS specific Request Headers"]],"struct":[["Cors","Response generator and Fairing for CORS"],["CorsOptions","Configuration options for CORS request handling."],["Guard","A request guard to check CORS headers before a route is run. Will not execute the route if checks fail."],["ManualResponder","A Manual Responder used in the \"truly manual\" mode of operation."],["Method","A wrapper type around `rocket::http::Method` to support serialization and deserialization"],["Origins","Origins that are allowed to make CORS requests."],["Responder","A `Responder` which will simply wraps another `Responder` with CORS headers."]],"type":[["AllowedHeaders","A list of allowed headers"],["AllowedMethods","A list of allowed methods"],["AllowedOrigins","A list of allowed origins. Either Some origins are allowed, or all origins are allowed."]]}); \ No newline at end of file diff --git a/rocket_cors/struct.Cors.html b/rocket_cors/struct.Cors.html new file mode 100644 index 0000000..b347ce4 --- /dev/null +++ b/rocket_cors/struct.Cors.html @@ -0,0 +1,45 @@ +rocket_cors::Cors - Rust

[][src]Struct rocket_cors::Cors

pub struct Cors { /* fields omitted */ }

Response generator and Fairing for CORS

+

This struct can be as Fairing or in an ad-hoc manner to generate CORS response. See the +documentation at the crate root for usage information.

+

This struct can be created by using CorsOptions::to_cors or Cors::from_options.

+

Methods

impl Cors[src]

pub fn from_options(options: &CorsOptions) -> Result<Self, Error>[src]

Create a Cors struct from a CorsOptions

+

pub fn respond_owned<'r, F, R>(
    self,
    handler: F
) -> Result<ManualResponder<'r, F, R>, Error> where
    F: FnOnce(Guard<'r>) -> R + 'r,
    R: Responder<'r>, 
[src]

Manually respond to a request with CORS checks and headers using an Owned Cors.

+

Use this variant when your Cors struct will not live at least as long as the whole 'r +lifetime of the request.

+

After the CORS checks are done, the passed in handler closure will be run to generate a +final response. You will have to merge your response with the Guard that you have been +passed in to include the CORS headers.

+

See the documentation at the crate root for usage information.

+

pub fn respond_borrowed<'r, F, R>(
    &'r self,
    handler: F
) -> Result<ManualResponder<'r, F, R>, Error> where
    F: FnOnce(Guard<'r>) -> R + 'r,
    R: Responder<'r>, 
[src]

Manually respond to a request with CORS checks and headers using a borrowed Cors.

+

Use this variant when your Cors struct will live at least as long as the whole 'r +lifetime of the request. If you are getting your Cors from Rocket's state, you will have +to use the inner function +to get a longer borrowed lifetime.

+

After the CORS checks are done, the passed in handler closure will be run to generate a +final response. You will have to merge your response with the Guard that you have been +passed in to include the CORS headers.

+

See the documentation at the crate root for usage information.

+

Trait Implementations

impl Clone for Cors[src]

impl Debug for Cors[src]

impl Fairing for Cors[src]

Auto Trait Implementations

impl Send for Cors

impl Sync for Cors

impl Unpin for Cors

impl UnwindSafe for Cors

impl !RefUnwindSafe for Cors

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

\ No newline at end of file diff --git a/rocket_cors/struct.CorsOptions.html b/rocket_cors/struct.CorsOptions.html new file mode 100644 index 0000000..21cf834 --- /dev/null +++ b/rocket_cors/struct.CorsOptions.html @@ -0,0 +1,156 @@ +rocket_cors::CorsOptions - Rust

[][src]Struct rocket_cors::CorsOptions

pub struct CorsOptions {
+    pub allowed_origins: AllowedOrigins,
+    pub allowed_methods: AllowedMethods,
+    pub allowed_headers: AllowedHeaders,
+    pub allow_credentials: bool,
+    pub expose_headers: HashSet<String>,
+    pub max_age: Option<usize>,
+    pub send_wildcard: bool,
+    pub fairing_route_base: String,
+    pub fairing_route_rank: isize,
+}

Configuration options for CORS request handling.

+

You create a new copy of this struct by defining the configurations in the fields below. +This struct can also be deserialized by serde with the serialization feature which is +enabled by default.

+

Default is implemented for this +struct. The default for each field is described in the docuementation for the field.

+

Before you can use this with Rocket, you will need to call the CorsOptions::to_cors method.

+

Examples

+

You can run an example from the repository to demonstrate the JSON serialization with +cargo run --example json.

+

Pure default

+
+let default = rocket_cors::CorsOptions::default();
+

JSON Examples

Default

+
{
+  "allowed_origins": "All",
+  "allowed_methods": [
+    "POST",
+    "PATCH",
+    "PUT",
+    "DELETE",
+    "HEAD",
+    "OPTIONS",
+    "GET"
+  ],
+  "allowed_headers": "All",
+  "allow_credentials": false,
+  "expose_headers": [],
+  "max_age": null,
+  "send_wildcard": false,
+  "fairing_route_base": "/cors",
+  "fairing_route_rank": 0
+}
+
+

Defined

+
{
+  "allowed_origins": {
+    "Some": {
+        "exact": ["https://www.acme.com"],
+        "regex": ["^https://www.example-[A-z0-9]*.com$"]
+    }
+  },
+  "allowed_methods": [
+    "POST",
+    "DELETE",
+    "GET"
+  ],
+  "allowed_headers": {
+    "Some": [
+      "Accept",
+      "Authorization"
+    ]
+  },
+  "allow_credentials": true,
+  "expose_headers": [
+    "Content-Type",
+    "X-Custom"
+  ],
+  "max_age": 42,
+  "send_wildcard": false,
+  "fairing_route_base": "/mycors"
+}
+
+
+

+ Fields

allowed_origins: AllowedOrigins

Origins that are allowed to make requests. +Will be verified against the Origin request header.

+

When All is set, and send_wildcard is set, "*" will be sent in +the Access-Control-Allow-Origin response header. Otherwise, the client's Origin request +header will be echoed back in the Access-Control-Allow-Origin response header.

+

When Some is set, the client's Origin request header will be checked in a +case-sensitive manner.

+

This is the list of origins in the +Resource Processing Model.

+

Defaults to All.

+
allowed_methods: AllowedMethods

The list of methods which the allowed origins are allowed to access for +non-simple requests.

+

This is the list of methods in the +Resource Processing Model.

+

Defaults to [GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE]

+
allowed_headers: AllowedHeaders

The list of header field names which can be used when this resource is accessed by allowed +origins.

+

If All is set, whatever is requested by the client in Access-Control-Request-Headers +will be echoed back in the Access-Control-Allow-Headers header.

+

This is the list of headers in the +Resource Processing Model.

+

Defaults to All.

+
allow_credentials: bool

Allows users to make authenticated requests. +If true, injects the Access-Control-Allow-Credentials header in responses. +This allows cookies and credentials to be submitted across domains.

+

This CANNOT be used in conjunction with allowed_origins set to All and +send_wildcard set to true. Depending on the mode of usage, this will either result +in an Error::CredentialsWithWildcardOrigin error during Rocket launch or runtime.

+

Defaults to false.

+
expose_headers: HashSet<String>

The list of headers which are safe to expose to the API of a CORS API specification. +This corresponds to the Access-Control-Expose-Headers responde header.

+

This is the list of exposed headers in the +Resource Processing Model.

+

This defaults to an empty set.

+
max_age: Option<usize>

The maximum time for which this CORS request maybe cached. This value is set as the +Access-Control-Max-Age header.

+

This defaults to None (unset).

+
send_wildcard: bool

If true, and the allowed_origins parameter is All, a wildcard +Access-Control-Allow-Origin response header is sent, rather than the request’s +Origin header.

+

This is the supports credentials flag in the +Resource Processing Model.

+

This CANNOT be used in conjunction with allowed_origins set to All and +allow_credentials set to true. Depending on the mode of usage, this will either result +in an Error::CredentialsWithWildcardOrigin error during Rocket launch or runtime.

+

Defaults to false.

+
fairing_route_base: String

When used as Fairing, Cors will need to redirect failed CORS checks to a custom route +mounted by the fairing. Specify the base of the route so that it doesn't clash with any +of your existing routes.

+

Defaults to "/cors"

+
fairing_route_rank: isize

When used as Fairing, Cors will need to redirect failed CORS checks to a custom route +mounted by the fairing. Specify the rank of the route so that it doesn't clash with any +of your existing routes. Remember that a higher ranked route has lower priority.

+

Defaults to 0

+

Methods

impl CorsOptions[src]

pub fn validate(&self) -> Result<(), Error>[src]

Validates if any of the settings are disallowed, incorrect, or illegal

+

pub fn to_cors(&self) -> Result<Cors, Error>[src]

Creates a Cors struct that can be used to respond to requests or as a Rocket Fairing

+

Trait Implementations

impl Clone for CorsOptions[src]

impl Default for CorsOptions[src]

impl Eq for CorsOptions[src]

impl PartialEq<CorsOptions> for CorsOptions[src]

impl Debug for CorsOptions[src]

impl StructuralPartialEq for CorsOptions[src]

impl StructuralEq for CorsOptions[src]

impl Serialize for CorsOptions[src]

impl<'de> Deserialize<'de> for CorsOptions[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

\ No newline at end of file diff --git a/rocket_cors/struct.Guard.html b/rocket_cors/struct.Guard.html new file mode 100644 index 0000000..75d526e --- /dev/null +++ b/rocket_cors/struct.Guard.html @@ -0,0 +1,27 @@ +rocket_cors::Guard - Rust

[][src]Struct rocket_cors::Guard

pub struct Guard<'r> { /* fields omitted */ }

A request guard to check CORS headers +before a route is run. Will not execute the route if checks fail.

+

See the documentation at the crate root for usage information.

+

You should not wrap this in an +Option or Result because the guard will let non-CORS requests through and will take over +error handling in case of errors. +In essence, this is just a wrapper around Response with a 'r borrowed lifetime so users +don't have to keep specifying the lifetimes in their routes

+

Methods

impl<'r> Guard<'r>[src]

pub fn responder<R: Responder<'r>>(self, responder: R) -> Responder<'r, R>[src]

Consumes the Guard and return a Responder that wraps a +provided rocket:response::Responder with CORS headers

+

pub fn response(&self, base: Response<'r>) -> Response<'r>[src]

Merge a rocket::Response with this CORS Guard. This is usually used in the final step +of a route to return a value for the route.

+

This will overwrite any existing CORS headers

+

Trait Implementations

impl<'a, 'r> FromRequest<'a, 'r> for Guard<'r>[src]

type Error = Error

The associated error to be returned if derivation fails.

+

Auto Trait Implementations

impl<'r> Send for Guard<'r>

impl<'r> Sync for Guard<'r>

impl<'r> Unpin for Guard<'r>

impl<'r> UnwindSafe for Guard<'r>

impl<'r> RefUnwindSafe for Guard<'r>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

\ No newline at end of file diff --git a/rocket_cors/struct.ManualResponder.html b/rocket_cors/struct.ManualResponder.html new file mode 100644 index 0000000..46eaef2 --- /dev/null +++ b/rocket_cors/struct.ManualResponder.html @@ -0,0 +1,15 @@ +rocket_cors::ManualResponder - Rust

[][src]Struct rocket_cors::ManualResponder

pub struct ManualResponder<'r, F, R> { /* fields omitted */ }

A Manual Responder used in the "truly manual" mode of operation.

+

See the documentation at the crate root for usage information.

+

Trait Implementations

impl<'r, F, R> Responder<'r> for ManualResponder<'r, F, R> where
    F: FnOnce(Guard<'r>) -> R + 'r,
    R: Responder<'r>, 
[src]

Auto Trait Implementations

impl<'r, F, R> Send for ManualResponder<'r, F, R> where
    F: Send,
    R: Send

impl<'r, F, R> Sync for ManualResponder<'r, F, R> where
    F: Sync,
    R: Sync

impl<'r, F, R> Unpin for ManualResponder<'r, F, R> where
    F: Unpin,
    R: Unpin

impl<'r, F, R> !UnwindSafe for ManualResponder<'r, F, R>

impl<'r, F, R> !RefUnwindSafe for ManualResponder<'r, F, R>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

\ No newline at end of file diff --git a/rocket_cors/struct.Method.html b/rocket_cors/struct.Method.html new file mode 100644 index 0000000..44b49ee --- /dev/null +++ b/rocket_cors/struct.Method.html @@ -0,0 +1,34 @@ +rocket_cors::Method - Rust

[][src]Struct rocket_cors::Method

pub struct Method(_);

A wrapper type around rocket::http::Method to support serialization and deserialization

+

Methods from Deref<Target = Method>

Trait Implementations

impl From<Method> for Method[src]

impl Clone for Method[src]

impl Copy for Method[src]

impl Eq for Method[src]

impl PartialEq<Method> for Method[src]

impl Display for Method[src]

impl Debug for Method[src]

impl FromStr for Method[src]

type Err = ()

The associated error which can be returned from parsing.

+

impl Deref for Method[src]

type Target = Method

The resulting type after dereferencing.

+

impl Hash for Method[src]

impl StructuralPartialEq for Method[src]

impl StructuralEq for Method[src]

impl Serialize for Method[src]

impl<'de> Deserialize<'de> for Method[src]

Auto Trait Implementations

impl Send for Method

impl Sync for Method

impl Unpin for Method

impl UnwindSafe for Method

impl RefUnwindSafe for Method

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

\ No newline at end of file diff --git a/rocket_cors/struct.Origins.html b/rocket_cors/struct.Origins.html new file mode 100644 index 0000000..70cc860 --- /dev/null +++ b/rocket_cors/struct.Origins.html @@ -0,0 +1,84 @@ +rocket_cors::Origins - Rust

[][src]Struct rocket_cors::Origins

pub struct Origins {
+    pub allow_null: bool,
+    pub exact: Option<HashSet<String>>,
+    pub regex: Option<HashSet<String>>,
+}

Origins that are allowed to make CORS requests.

+

An origin is defined according to the defined +syntax.

+

Origins can be specified as an exact match or using regex.

+

These Origins are specified as logical ORs. That is, if any of the origins match, the entire +request is considered to be valid.

+

Exact matches are matched exactly with the +ASCII Serialization +of the origin.

+

Regular expressions are tested for matches against the +ASCII Serialization +of the origin.

+

Opaque Origins

+

The specification defines an Opaque Origin +as one that cannot be recreated. You can refer to the source code for the url::Url::origin +method to see how an Opaque Origin is determined. Examples of Opaque origins might include +schemes like file:// or Browser specific schemes like "moz-extension:// or +chrome-extension://.

+

Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you +attempt to create Cors from CorsOptions, you will get an error.

+

Warning about Regex expressions

+

By default, regex expressions are +unanchored.

+

This means that if the regex does not start with ^ or \A, or end with $ or \z, +then it is permitted to match anywhere in the text. You are encouraged to use the anchors when +crafting your Regex expressions.

+

+ Fields

allow_null: bool

Whether null origins are accepted

+
exact: Option<HashSet<String>>

Origins that must be matched exactly as provided.

+

These must be valid URL strings that will be parsed and validated when +creating Cors.

+

Exact matches are matched exactly with the +ASCII Serialization +of the origin.

+

Opaque Origins

+

The specification defines an Opaque Origin +as one that cannot be recreated. You can refer to the source code for the url::Url::origin +method to see how an Opaque Origin is determined. Examples of Opaque origins might include +schemes like file:// or Browser specific schemes like "moz-extension:// or +chrome-extension://.

+

Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you +attempt to create Cors from CorsOptions, you will get an error.

+
regex: Option<HashSet<String>>

Origins that will be matched via any regex in this list.

+

These must be valid Regex that will be parsed and validated when creating Cors.

+

The regex will be matched according to the +ASCII serialization +of the incoming Origin.

+

For more information on the syntax of Regex in Rust, see the +documentation.

+

Regular expressions are tested for matches against the +ASCII Serialization +of the origin.

+

Warning about Regex expressions

+

By default, regex expressions are +unanchored.

+

Trait Implementations

impl Clone for Origins[src]

impl Default for Origins[src]

impl Eq for Origins[src]

impl PartialEq<Origins> for Origins[src]

impl Debug for Origins[src]

impl StructuralPartialEq for Origins[src]

impl StructuralEq for Origins[src]

impl Serialize for Origins[src]

impl<'de> Deserialize<'de> for Origins where
    Origins: Default
[src]

Auto Trait Implementations

impl Send for Origins

impl Sync for Origins

impl Unpin for Origins

impl UnwindSafe for Origins

impl RefUnwindSafe for Origins

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

\ No newline at end of file diff --git a/rocket_cors/struct.Responder.html b/rocket_cors/struct.Responder.html new file mode 100644 index 0000000..7254e34 --- /dev/null +++ b/rocket_cors/struct.Responder.html @@ -0,0 +1,30 @@ +rocket_cors::Responder - Rust

[][src]Struct rocket_cors::Responder

pub struct Responder<'r, R> { /* fields omitted */ }

A Responder which will simply wraps another +Responder with CORS headers.

+

The following CORS headers will be overwritten:

+
    +
  • Access-Control-Allow-Origin
  • +
  • Access-Control-Expose-Headers
  • +
  • Access-Control-Max-Age
  • +
  • Access-Control-Allow-Credentials
  • +
  • Access-Control-Allow-Methods
  • +
  • Access-Control-Allow-Headers
  • +
+

The following headers will be merged:

+
    +
  • Vary
  • +
+

See the documentation at the crate root for usage information.

+

Trait Implementations

impl<'r, R: Debug> Debug for Responder<'r, R>[src]

impl<'r, R: Responder<'r>> Responder<'r> for Responder<'r, R>[src]

Auto Trait Implementations

impl<'r, R> !Send for Responder<'r, R>

impl<'r, R> !Sync for Responder<'r, R>

impl<'r, R> !Unpin for Responder<'r, R>

impl<'r, R> !UnwindSafe for Responder<'r, R>

impl<'r, R> !RefUnwindSafe for Responder<'r, R>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

\ No newline at end of file diff --git a/rocket_cors/type.AllowedHeaders.html b/rocket_cors/type.AllowedHeaders.html new file mode 100644 index 0000000..9a21c1b --- /dev/null +++ b/rocket_cors/type.AllowedHeaders.html @@ -0,0 +1,10 @@ +rocket_cors::AllowedHeaders - Rust

[][src]Type Definition rocket_cors::AllowedHeaders

type AllowedHeaders = AllOrSome<HashSet<HeaderFieldName>>;

A list of allowed headers

+

Examples

+
+use rocket_cors::AllowedHeaders;
+
+let all_headers = AllowedHeaders::all();
+let some_headers = AllowedHeaders::some(&["Authorization", "Accept"]);
+

Methods

impl AllowedHeaders[src]

pub fn some(headers: &[&str]) -> Self[src]

Allow some headers

+

pub fn all() -> Self[src]

Allows all headers

+
\ No newline at end of file diff --git a/rocket_cors/type.AllowedMethods.html b/rocket_cors/type.AllowedMethods.html new file mode 100644 index 0000000..cf7f249 --- /dev/null +++ b/rocket_cors/type.AllowedMethods.html @@ -0,0 +1,13 @@ +rocket_cors::AllowedMethods - Rust

[][src]Type Definition rocket_cors::AllowedMethods

type AllowedMethods = HashSet<Method>;

A list of allowed methods

+

The list +of methods is whatever is supported by Rocket.

+

Example

+
+use std::str::FromStr;
+use rocket_cors::AllowedMethods;
+
+let allowed_methods: AllowedMethods = ["Get", "Post", "Delete"]
+   .iter()
+   .map(|s| FromStr::from_str(s).unwrap())
+   .collect();
+
\ No newline at end of file diff --git a/rocket_cors/type.AllowedOrigins.html b/rocket_cors/type.AllowedOrigins.html new file mode 100644 index 0000000..2818cfe --- /dev/null +++ b/rocket_cors/type.AllowedOrigins.html @@ -0,0 +1,80 @@ +rocket_cors::AllowedOrigins - Rust

[][src]Type Definition rocket_cors::AllowedOrigins

type AllowedOrigins = AllOrSome<Origins>;

A list of allowed origins. Either Some origins are allowed, or all origins are allowed.

+

Exact matches are matched exactly with the +ASCII Serialization +of the origin.

+

Regular expressions are tested for matches against the +ASCII Serialization +of the origin.

+

Opaque Origins

+

The specification defines an Opaque Origin +as one that cannot be recreated. You can refer to the source code for the url::Url::origin +method to see how an Opaque Origin is determined. Examples of Opaque origins might include +schemes like file:// or Browser specific schemes like "moz-extension:// or +chrome-extension://.

+

Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you +attempt to create Cors from CorsOptions, you will get an error.

+

Warning about Regex expressions

+

By default, regex expressions are +unanchored.

+

This means that if the regex does not start with ^ or \A, or end with $ or \z, +then it is permitted to match anywhere in the text. You are encouraged to use the anchors when +crafting your Regex expressions.

+

Examples

+
+use rocket_cors::AllowedOrigins;
+
+let exact = ["https://www.acme.com"];
+let regex = ["^https://(.+).acme.com$"];
+
+let all_origins = AllowedOrigins::all();
+let some_origins = AllowedOrigins::some_exact(&exact);
+let null_origins = AllowedOrigins::some_null();
+let regex_origins = AllowedOrigins::some_regex(&regex);
+let mixed_origins = AllowedOrigins::some(&exact, &regex);
+

Methods

impl AllowedOrigins[src]

pub fn some<'a, 'b, S1: AsRef<str>, S2: AsRef<str>>(
    exact: &'a [S1],
    regex: &'b [S2]
) -> Self
[src]

Allows some origins, with a mix of exact matches or regex matches

+

Validation is not performed at this stage, but at a later stage.

+

Exact matches are matched exactly with the +ASCII Serialization +of the origin.

+

Regular expressions are tested for matches against the +ASCII Serialization +of the origin.

+

Opaque Origins

+

The specification defines an Opaque Origin +as one that cannot be recreated. You can refer to the source code for the url::Url::origin +method to see how an Opaque Origin is determined. Examples of Opaque origins might include +schemes like file:// or Browser specific schemes like "moz-extension:// or +chrome-extension://.

+

Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you +attempt to create Cors from CorsOptions, you will get an error.

+

Warning about Regex expressions

+

By default, regex expressions are +unanchored.

+

This means that if the regex does not start with ^ or \A, or end with $ or \z, +then it is permitted to match anywhere in the text. You are encouraged to use the anchors when +crafting your Regex expressions.

+

pub fn some_exact<S: AsRef<str>>(exact: &[S]) -> Self[src]

Allows some exact origins

+

Validation is not performed at this stage, but at a later stage.

+

Exact matches are matched exactly with the +ASCII Serialization +of the origin.

+

Opaque Origins

+

The specification defines an Opaque Origin +as one that cannot be recreated. You can refer to the source code for the url::Url::origin +method to see how an Opaque Origin is determined. Examples of Opaque origins might include +schemes like file:// or Browser specific schemes like "moz-extension:// or +chrome-extension://.

+

pub fn some_regex<S: AsRef<str>>(regex: &[S]) -> Self[src]

Allow some regular expression origins

+

Validation is not performed at this stage, but at a later stage.

+

Regular expressions are tested for matches against the +ASCII Serialization +of the origin.

+

Warning about Regex expressions

+

By default, regex expressions are +unanchored.

+

This means that if the regex does not start with ^ or \A, or end with $ or \z, +then it is permitted to match anywhere in the text. You are encouraged to use the anchors when +crafting your Regex expressions.

+

pub fn some_null() -> Self[src]

Allow some null origins

+

pub fn all() -> Self[src]

Allows all origins

+
\ No newline at end of file diff --git a/rust-logo.png b/rust-logo.png new file mode 100644 index 0000000..74b4bd6 Binary files /dev/null and b/rust-logo.png differ diff --git a/rustdoc.css b/rustdoc.css new file mode 100644 index 0000000..8eff85f --- /dev/null +++ b/rustdoc.css @@ -0,0 +1 @@ + @font-face {font-family:'Fira Sans';font-style:normal;font-weight:400;src:local('Fira Sans'),url("FiraSans-Regular.woff") format('woff');}@font-face {font-family:'Fira Sans';font-style:normal;font-weight:500;src:local('Fira Sans Medium'),url("FiraSans-Medium.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:400;src:local('Source Serif Pro'),url("SourceSerifPro-Regular.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:italic;font-weight:400;src:local('Source Serif Pro Italic'),url("SourceSerifPro-It.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:700;src:local('Source Serif Pro Bold'),url("SourceSerifPro-Bold.ttf.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:400;src:url("SourceCodePro-Regular.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:600;src:url("SourceCodePro-Semibold.woff") format('woff');}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}html{content:"";}@media (prefers-color-scheme:light){html{content:"light";}}@media (prefers-color-scheme:dark){html{content:"dark";}}body{font:16px/1.4 "Source Serif Pro",serif;margin:0;position:relative;padding:10px 15px 20px 15px;-webkit-font-feature-settings:"kern","liga";-moz-font-feature-settings:"kern","liga";font-feature-settings:"kern","liga";}h1{font-size:1.5em;}h2{font-size:1.4em;}h3{font-size:1.3em;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){font-weight:500;margin:20px 0 15px 0;padding-bottom:6px;}h1.fqn{border-bottom:1px dashed;margin-top:0;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){border-bottom:1px solid;}h3.impl,h3.method,h4.method,h3.type,h4.type,h4.associatedconstant{flex-basis:100%;font-weight:600;margin-top:16px;margin-bottom:10px;position:relative;}h3.impl,h3.method,h3.type{padding-left:15px;}h1,h2,h3,h4,.sidebar,a.source,.search-input,.content table :not(code)>a,.collapse-toggle,div.item-list .out-of-band,#source-sidebar,#sidebar-toggle{font-family:"Fira Sans",sans-serif;}ol,ul{padding-left:25px;}ul ul,ol ul,ul ol,ol ol{margin-bottom:.6em;}p{margin:0 0 .6em 0;}summary{outline:none;}code,pre{font-family:"Source Code Pro",monospace;}.docblock code,.docblock-short code{border-radius:3px;padding:0 0.1em;}.docblock pre code,.docblock-short pre code,.docblock code.spotlight{padding:0;}.docblock code.spotlight :last-child{padding-bottom:0.6em;}pre{padding:14px;}.source .content pre{padding:20px;}img{max-width:100%;}li{position:relative;}.source .content{margin-top:50px;max-width:none;overflow:visible;margin-left:0px;min-width:70em;}nav.sub{font-size:16px;text-transform:uppercase;}.sidebar{width:200px;position:fixed;left:0;top:0;bottom:0;overflow:auto;}.sidebar .block>ul>li{margin-right:-10px;}.content,nav{max-width:960px;}.js-only,.hidden{display:none !important;}.logo-container{height:100px;width:100px;position:relative;margin:20px auto;display:block;margin-top:10px;}.logo-container>img{max-width:100px;max-height:100px;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:block;}.sidebar .location{border:1px solid;font-size:17px;margin:30px 10px 20px 10px;text-align:center;word-wrap:break-word;}.sidebar .version{font-size:15px;text-align:center;border-bottom:1px solid;overflow-wrap:break-word;word-wrap:break-word;word-break:break-word;}.location:empty{border:none;}.location a:first-child{font-weight:500;}.block{padding:0;margin-bottom:14px;}.block h2,.block h3{margin-top:0;margin-bottom:8px;text-align:center;}.block ul,.block li{margin:0 10px;padding:0;list-style:none;}.block a{display:block;text-overflow:ellipsis;overflow:hidden;line-height:15px;padding:7px 5px;font-size:14px;font-weight:300;transition:border 500ms ease-out;}.sidebar-title{border-top:1px solid;border-bottom:1px solid;text-align:center;font-size:17px;margin-bottom:5px;}.sidebar-links{margin-bottom:15px;}.sidebar-links>a{padding-left:10px;width:100%;}.sidebar-menu{display:none;}.content{padding:15px 0;}.source .content pre.rust{white-space:pre;overflow:auto;padding-left:0;}.rustdoc:not(.source) .example-wrap{display:inline-flex;margin-bottom:10px;}.example-wrap{width:100%;}.example-wrap>pre.line-number{overflow:initial;border:1px solid;border-top-left-radius:5px;border-bottom-left-radius:5px;padding:13px 8px;text-align:right;}.rustdoc:not(.source) .example-wrap>pre.rust{width:100%;overflow-x:auto;}.rustdoc:not(.source) .example-wrap>pre{margin:0;}#search{margin-left:230px;position:relative;}#results{position:absolute;right:0;left:0;overflow:auto;}#results>table{width:100%;table-layout:fixed;}.content pre.line-numbers{float:left;border:none;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}.line-numbers span{cursor:pointer;}.docblock-short p{display:inline;}.docblock-short.nowrap{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}.docblock-short p{overflow:hidden;text-overflow:ellipsis;margin:0;}.docblock-short code{white-space:pre-wrap;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom:1px solid;}#main>.docblock h1{font-size:1.3em;}#main>.docblock h2{font-size:1.15em;}#main>.docblock h3,#main>.docblock h4,#main>.docblock h5{font-size:1em;}#main>h2+div,#main>h2+h3,#main>h3+div{display:none;flex-wrap:wrap;}.docblock h1{font-size:1em;}.docblock h2{font-size:0.95em;}.docblock h3,.docblock h4,.docblock h5{font-size:0.9em;}.docblock{margin-left:24px;position:relative;}.content .out-of-band{float:right;font-size:23px;margin:0px;padding:0px;font-weight:normal;}h3.impl>.out-of-band{font-size:21px;}h4.method>.out-of-band{font-size:19px;}h4>code,h3>code,.invisible>code{max-width:calc(100% - 41px);display:block;}.invisible{width:100%;display:inline-block;}.content .in-band{margin:0px;padding:0px;}.in-band>code{display:inline-block;}#main{position:relative;}#main>.since{top:inherit;font-family:"Fira Sans",sans-serif;}.content table:not(.table-display){border-spacing:0 5px;}.content td{vertical-align:top;}.content td:first-child{padding-right:20px;}.content td p:first-child{margin-top:0;}.content td h1,.content td h2{margin-left:0;font-size:1.1em;}.content tr:first-child td{border-top:0;}.docblock table{margin:.5em 0;width:calc(100% - 2px);border:1px dashed;}.docblock table td{padding:.5em;border:1px dashed;}.docblock table th{padding:.5em;text-align:left;border:1px solid;}.fields+table{margin-bottom:1em;}.content .item-list{list-style-type:none;padding:0;}.content .multi-column{-moz-column-count:5;-moz-column-gap:2.5em;-webkit-column-count:5;-webkit-column-gap:2.5em;column-count:5;column-gap:2.5em;}.content .multi-column li{width:100%;display:inline-block;}.content .method{font-size:1em;position:relative;}.content .method .where,.content .fn .where,.content .where.fmt-newline{display:block;font-size:0.8em;}.content .methods>div:not(.important-traits){margin-left:40px;margin-bottom:15px;}.content .docblock>.impl-items{margin-left:20px;margin-top:-34px;}.content .docblock>.impl-items>h4{border-bottom:0;}.content .docblock>.impl-items .table-display{margin:0;}.content .docblock>.impl-items table td{padding:0;}.toggle-wrapper.marg-left>.collapse-toggle{left:-24px;}.content .docblock>.impl-items .table-display,.impl-items table td{border:none;}.content .stability code{font-size:90%;}.content .stability{position:relative;margin-left:33px;margin-top:-13px;}.sub-variant>div>.stability{margin-top:initial;}.content .stability::before{content:'˪';font-size:30px;position:absolute;top:-9px;left:-13px;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{margin-left:20px;}.content .impl-items .docblock,.content .impl-items .stability{margin-bottom:.6em;}.content .impl-items>.stability{margin-left:40px;}.methods>.stability,.content .impl-items>.stability{margin-top:-8px;}.impl-items{flex-basis:100%;}#main>.stability{margin-top:0;}nav:not(.sidebar){border-bottom:1px solid;padding-bottom:10px;margin-bottom:10px;}nav.main{padding:20px 0;text-align:center;}nav.main .current{border-top:1px solid;border-bottom:1px solid;}nav.main .separator{border:1px solid;display:inline-block;height:23px;margin:0 20px;}nav.sum{text-align:right;}nav.sub form{display:inline;}nav.sub,.content{margin-left:230px;}a{text-decoration:none;background:transparent;}.small-section-header:hover>.anchor{display:initial;}.in-band:hover>.anchor{display:inline-block;position:absolute;}.anchor{display:none;position:absolute;left:-7px;}.anchor.field{left:-5px;}.small-section-header>.anchor{left:-28px;padding-right:10px;}.anchor:before{content:'\2002\00a7\2002';}.docblock a:not(.srclink):not(.test-arrow):hover,.docblock-short a:not(.srclink):not(.test-arrow):hover,.stability a{text-decoration:underline;}.invisible>.srclink,h4>code+.srclink{position:absolute;top:0;right:0;font-size:17px;font-weight:normal;}.block a.current.crate{font-weight:500;}.search-container{position:relative;}.search-container>div{display:inline-flex;width:calc(100% - 34px);}#crate-search{margin-top:5px;padding:6px;padding-right:19px;flex:none;border:0;border-right:0;border-radius:4px 0 0 4px;outline:none;cursor:pointer;border-right:1px solid;-moz-appearance:none;-webkit-appearance:none;text-indent:0.01px;text-overflow:"";background-repeat:no-repeat;background-color:transparent;background-size:20px;background-position:calc(100% - 1px) 56%;}.search-container>.top-button{position:absolute;right:0;top:10px;}.search-input{-moz-box-sizing:border-box !important;box-sizing:border-box !important;outline:none;border:none;border-radius:1px;margin-top:5px;padding:10px 16px;font-size:17px;transition:border-color 300ms ease;transition:border-radius 300ms ease-in-out;transition:box-shadow 300ms ease-in-out;width:100%;}#crate-search+.search-input{border-radius:0 1px 1px 0;width:calc(100% - 32px);}.search-input:focus{border-radius:2px;border:0;outline:0;}.search-results .desc{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block;}.search-results a{display:block;}.content .search-results td:first-child{padding-right:0;width:50%;}.content .search-results td:first-child a{padding-right:10px;}.content .search-results td:first-child a:after{clear:both;content:"";display:block;}.content .search-results td:first-child a span{float:left;}tr.result span.primitive::after{content:' (primitive type)';font-style:italic;}tr.result span.keyword::after{content:' (keyword)';font-style:italic;}body.blur>:not(#help){filter:blur(8px);-webkit-filter:blur(8px);opacity:.7;}#help{width:100%;height:100vh;position:fixed;top:0;left:0;display:flex;justify-content:center;align-items:center;}#help>div{flex:0 0 auto;box-shadow:0 0 6px rgba(0,0,0,.2);width:550px;height:auto;border:1px solid;}#help dt{float:left;clear:left;display:block;}#help dd{margin:5px 35px;}#help .infos{padding-left:0;}#help h1,#help h2{margin-top:0;}#help>div div{width:50%;float:left;padding:20px;padding-left:17px;}.stab{display:table;border-width:1px;border-style:solid;padding:3px;margin-bottom:5px;font-size:90%;}.stab p{display:inline;}.stab summary{display:list-item;}.stab .emoji{font-size:1.5em;}.module-item .stab{border-radius:3px;display:inline-block;font-size:80%;line-height:1.2;margin-bottom:0;margin-right:.3em;padding:2px;vertical-align:text-bottom;}.module-item.unstable{opacity:0.65;}.since{font-weight:normal;font-size:initial;position:absolute;right:0;top:0;}.impl-items .since,.impl .since{flex-grow:0;padding-left:12px;padding-right:2px;position:initial;}.impl-items .srclink,.impl .srclink{flex-grow:0;font-size:17px;font-weight:normal;}.impl-items code,.impl code{flex-grow:1;}.impl-items h4,h4.impl,h3.impl{display:flex;flex-basis:100%;font-size:16px;margin-bottom:12px;justify-content:space-between;}.variants_table{width:100%;}.variants_table tbody tr td:first-child{width:1%;}td.summary-column{width:100%;}.summary{padding-right:0px;}pre.rust .question-mark{font-weight:bold;}a.test-arrow{display:inline-block;position:absolute;padding:5px 10px 5px 10px;border-radius:5px;font-size:130%;top:5px;right:5px;}a.test-arrow:hover{text-decoration:none;}.section-header:hover a:before{position:absolute;left:-25px;padding-right:10px;content:'\2002\00a7\2002';}.section-header:hover a{text-decoration:none;}.section-header a{color:inherit;}.collapse-toggle{font-weight:300;position:absolute;left:-23px;top:0;}h3>.collapse-toggle,h4>.collapse-toggle{font-size:0.8em;top:5px;}.toggle-wrapper>.collapse-toggle{left:-24px;margin-top:0px;}.toggle-wrapper{position:relative;margin-top:0;}.toggle-wrapper.collapsed{height:25px;transition:height .2s;margin-bottom:.6em;}.collapse-toggle>.inner{display:inline-block;width:1.2ch;text-align:center;}.collapse-toggle.hidden-default{position:relative;margin-left:20px;}.since+.srclink{display:table-cell;padding-left:10px;}.item-spacer{width:100%;height:12px;}.out-of-band>span.since{position:initial;font-size:20px;margin-right:5px;}.toggle-wrapper>.collapse-toggle{left:0;}.variant+.toggle-wrapper+.docblock>p{margin-top:5px;}.sub-variant,.sub-variant>h3{margin-top:1px !important;}#main>.sub-variant>h3{font-size:15px;margin-left:25px;margin-bottom:5px;}.sub-variant>div{margin-left:20px;margin-bottom:10px;}.sub-variant>div>span{display:block;position:relative;}.toggle-label{display:inline-block;margin-left:4px;margin-top:3px;}.enum>.toggle-wrapper+.docblock,.struct>.toggle-wrapper+.docblock{margin-left:30px;margin-bottom:20px;margin-top:5px;}.docblock>.section-header:first-child{margin-left:15px;margin-top:0;}.docblock>.section-header:first-child:hover>a:before{left:-10px;}.enum>.collapsed,.struct>.collapsed{margin-bottom:25px;}#main>.variant,#main>.structfield{display:block;}.attributes{display:block;margin-top:0px !important;margin-right:0px;margin-bottom:0px !important;margin-left:30px;}.toggle-attributes.collapsed{margin-bottom:0;}.impl-items>.toggle-attributes{margin-left:20px;}.impl-items .attributes{font-weight:500;}:target>code{opacity:1;}.information{position:absolute;left:-20px;margin-top:7px;z-index:1;}.tooltip{position:relative;display:inline-block;cursor:pointer;}.tooltip .tooltiptext{width:120px;display:none;text-align:center;padding:5px 3px;border-radius:6px;margin-left:5px;top:-5px;left:105%;z-index:10;}.tooltip:hover .tooltiptext{display:inline;}.tooltip .tooltiptext::after{content:" ";position:absolute;top:50%;left:11px;margin-top:-5px;border-width:5px;border-style:solid;}.important-traits .tooltip .tooltiptext{border:1px solid;}pre.rust{position:relative;tab-width:4;-moz-tab-width:4;}.search-failed{text-align:center;margin-top:20px;}.search-failed>ul{text-align:left;max-width:570px;margin-left:auto;margin-right:auto;}#titles{height:35px;}#titles>div{float:left;width:33.3%;text-align:center;font-size:18px;cursor:pointer;border-top:2px solid;}#titles>div:not(:last-child){margin-right:1px;width:calc(33.3% - 1px);}#titles>div>div.count{display:inline-block;font-size:16px;}.important-traits{cursor:pointer;z-index:2;}h4>.important-traits{position:absolute;left:-44px;top:2px;}#all-types{text-align:center;border:1px solid;margin:0 10px;margin-bottom:10px;display:block;border-radius:7px;}#all-types>p{margin:5px 0;}#sidebar-toggle{position:fixed;top:30px;left:300px;z-index:10;padding:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;cursor:pointer;font-weight:bold;transition:left .5s;font-size:1.2em;border:1px solid;border-left:0;}#source-sidebar{position:fixed;top:0;bottom:0;left:0;width:300px;z-index:1;overflow:auto;transition:left .5s;border-right:1px solid;}#source-sidebar>.title{font-size:1.5em;text-align:center;border-bottom:1px solid;margin-bottom:6px;}.theme-picker{position:absolute;left:211px;top:19px;}.theme-picker button{outline:none;}#settings-menu{position:absolute;right:0;top:10px;outline:none;}#theme-picker,#settings-menu{padding:4px;width:27px;height:29px;border:1px solid;border-radius:3px;cursor:pointer;}#theme-choices{display:none;position:absolute;left:0;top:28px;border:1px solid;border-radius:3px;z-index:1;cursor:pointer;}#theme-choices>button{border:none;width:100%;padding:4px;text-align:center;background:rgba(0,0,0,0);}#theme-choices>button:not(:first-child){border-top:1px solid;}@media (max-width:700px){body{padding-top:0px;}.rustdoc>.sidebar{height:45px;min-height:40px;margin:0;margin-left:-15px;padding:0 15px;position:static;z-index:11;}.sidebar>.location{float:right;margin:0px;margin-top:2px;padding:3px 10px 1px 10px;min-height:39px;background:inherit;text-align:left;font-size:24px;}.sidebar .location:empty{padding:0;}.sidebar .logo-container{width:35px;height:35px;margin-top:5px;margin-bottom:5px;float:left;margin-left:50px;}.sidebar .logo-container>img{max-width:35px;max-height:35px;}.sidebar-menu{position:fixed;z-index:10;font-size:2rem;cursor:pointer;width:45px;left:0;text-align:center;display:block;border-bottom:1px solid;border-right:1px solid;height:45px;}.rustdoc.source>.sidebar>.sidebar-menu{display:none;}.sidebar-elems{position:fixed;z-index:1;left:0;top:45px;bottom:0;overflow-y:auto;border-right:1px solid;display:none;}.sidebar>.block.version{border-bottom:none;margin-top:12px;}nav.sub{width:calc(100% - 32px);float:right;}.content{margin-left:0px;}#main{margin-top:45px;padding:0;}.content .in-band{width:100%;}.content h4>.out-of-band{position:inherit;}.toggle-wrapper>.collapse-toggle{left:0px;}.toggle-wrapper{height:1.5em;}#search{margin-left:0;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{display:flex;}.anchor{display:none !important;}h1.fqn{overflow:initial;}.theme-picker{left:10px;top:54px;z-index:1;}h4>.important-traits{position:absolute;left:-22px;top:24px;}#titles>div>div.count{float:left;width:100%;}#titles{height:50px;}.sidebar.mobile{position:fixed;width:100%;margin-left:0;background-color:rgba(0,0,0,0);height:100%;}.sidebar{width:calc(100% + 30px);}.show-it{display:block;width:246px;}.show-it>.block.items{margin:8px 0;}.show-it>.block.items>ul{margin:0;}.show-it>.block.items>ul>li{text-align:center;margin:2px 0;}.show-it>.block.items>ul>li>a{font-size:21px;}#sidebar-filler{position:fixed;left:45px;width:calc(100% - 45px);top:0;height:45px;z-index:-1;border-bottom:1px solid;}.collapse-toggle{left:-20px;}.impl>.collapse-toggle{left:-10px;}#all-types{margin:10px;}#sidebar-toggle{top:100px;width:30px;font-size:1.5rem;text-align:center;padding:0;}#source-sidebar{z-index:11;}#main>.line-numbers{margin-top:0;}}@media print{nav.sub,.content .out-of-band,.collapse-toggle{display:none;}}@media (max-width:416px){#titles{height:73px;}#titles>div{height:73px;}}.modal{position:fixed;width:100vw;height:100vh;z-index:10000;top:0;left:0;}.modal-content{display:block;max-width:60%;min-width:200px;padding:8px;top:40%;position:absolute;left:50%;transform:translate(-50%,-40%);border:1px solid;border-radius:4px;border-top-right-radius:0;}.modal-content>.docblock{margin:0;}h3.important{margin:0;margin-bottom:13px;font-size:19px;}.modal-content>.docblock>code.content{margin:0;padding:0;font-size:20px;}.modal-content>.close{position:absolute;font-weight:900;right:-25px;top:-1px;font-size:18px;width:25px;padding-right:2px;border-top-right-radius:5px;border-bottom-right-radius:5px;text-align:center;border:1px solid;border-right:0;cursor:pointer;}.modal-content>.whiter{height:25px;position:absolute;width:3px;right:-2px;top:0px;}#main>div.important-traits{position:absolute;left:-24px;margin-top:16px;}.content>.methods>.method>div.important-traits{position:absolute;font-weight:400;left:-42px;margin-top:2px;}kbd{display:inline-block;padding:3px 5px;font:15px monospace;line-height:10px;vertical-align:middle;border:solid 1px;border-radius:3px;box-shadow:inset 0 -1px 0;cursor:default;}.hidden-by-impl-hider,.hidden-by-usual-hider{display:none !important;}#implementations-list>h3>span.in-band{width:100%;}.table-display{width:100%;border:0;border-collapse:collapse;border-spacing:0;font-size:16px;}.table-display tr td:first-child{padding-right:0;}.table-display tr td:last-child{float:right;}.table-display .out-of-band{position:relative;font-size:19px;display:block;}#implementors-list>.impl-items .table-display .out-of-band{font-size:17px;}.table-display td:hover .anchor{display:block;top:2px;left:-5px;}#main>ul{padding-left:10px;}#main>ul>li{list-style:none;}.non-exhaustive{margin-bottom:1em;}div.children{padding-left:27px;display:none;}div.name{cursor:pointer;position:relative;margin-left:16px;}div.files>a{display:block;padding:0 3px;}div.files>a:hover,div.name:hover{background-color:#a14b4b;}div.name.expand+.children{display:block;}div.name::before{content:"\25B6";padding-left:4px;font-size:0.7em;position:absolute;left:-16px;top:4px;}div.name.expand::before{transform:rotate(90deg);left:-15px;top:2px;}.type-decl>pre>.toggle-wrapper.toggle-attributes.top-attr{margin-left:0 !important;}.type-decl>pre>.docblock.attributes.top-attr{margin-left:1.8em !important;}.type-decl>pre>.toggle-attributes{margin-left:2.2em;}.type-decl>pre>.docblock.attributes{margin-left:4em;} \ No newline at end of file diff --git a/search-index.js b/search-index.js new file mode 100644 index 0000000..166bae2 --- /dev/null +++ b/search-index.js @@ -0,0 +1,4 @@ +var N=null,E="",T="t",U="u",searchIndex={}; +var R=["When used as Fairing, Cors will need to redirect failed…","rocket_cors","result","error","manualresponder","Manually respond to a request with CORS checks and headers…","responder","response","string","smallvec","parseerr","to_owned","clone_into","try_from","try_into","borrow_mut","into_collection","as_result","equivalent","type_id","borrow","typeid","mapped","to_string","rocket_cors::headers","corsoptions","default","headerfieldname","accesscontrolrequestheaders","allorsome","origins","formatter","from_str","from_request","request","outcome","respond_to","serialize","deserialize","method","CorsOptions","AllOrSome","AccessControlRequestMethod","AccessControlRequestHeaders","AllowedOrigins","AllowedHeaders","Responder","ManualResponder","HeaderFieldName"]; +searchIndex["rocket_cors"]={"doc":"Build Status Repository Crates.io","i":[[3,"Method",R[1],"A wrapper type around `rocket::http::Method` to support…",N,N],[3,"Origins",E,"Origins that are allowed to make CORS requests.",N,N],[12,"allow_null",E,"Whether null origins are accepted",0,N],[12,"exact",E,"Origins that must be matched exactly as provided.",0,N],[12,"regex",E,"Origins that will be matched via any regex in this list.",0,N],[3,R[40],E,"Configuration options for CORS request handling.",N,N],[12,"allowed_origins",E,"Origins that are allowed to make requests. Will be…",1,N],[12,"allowed_methods",E,"The list of methods which the allowed origins are allowed…",1,N],[12,"allowed_headers",E,"The list of header field names which can be used when this…",1,N],[12,"allow_credentials",E,"Allows users to make authenticated requests. If true,…",1,N],[12,"expose_headers",E,"The list of headers which are safe to expose to the API of…",1,N],[12,"max_age",E,"The maximum time for which this CORS request maybe cached.…",1,N],[12,"send_wildcard",E,"If true, and the `allowed_origins` parameter is `All`, a…",1,N],[12,"fairing_route_base",E,R[0],1,N],[12,"fairing_route_rank",E,R[0],1,N],[3,"Cors",E,"Response generator and Fairing for CORS",N,N],[3,"Guard",E,"A request guard to check CORS headers before a route is…",N,N],[3,R[46],E,"A `Responder` which will simply wraps another `Responder`…",N,N],[3,R[47],E,"A Manual Responder used in the \"truly manual\" mode of…",N,N],[4,"Error",E,"Errors during operations",N,N],[13,"MissingOrigin",E,"The HTTP request header `Origin` is required but was not…",2,N],[13,"BadOrigin",E,"The HTTP request header `Origin` could not be parsed…",2,N],[13,"OpaqueAllowedOrigin",E,"The configured Allowed Origins are Opaque origins. Use a…",2,N],[13,"MissingRequestMethod",E,"The request header `Access-Control-Request-Method` is…",2,N],[13,"BadRequestMethod",E,"The request header `Access-Control-Request-Method` has an…",2,N],[13,"MissingRequestHeaders",E,"The request header `Access-Control-Request-Headers` is…",2,N],[13,"OriginNotAllowed",E,"Origin is not allowed to make this request",2,N],[13,"MethodNotAllowed",E,"Requested method is not allowed",2,N],[13,"RegexError",E,"A regular expression compilation error",2,N],[13,"HeadersNotAllowed",E,"One or more headers requested are not allowed",2,N],[13,"CredentialsWithWildcardOrigin",E,"Credentials are allowed, but the Origin is set to \"*\".…",2,N],[13,"MissingCorsInRocketState",E,"A CORS Request Guard was used, but no CORS Options was…",2,N],[13,"MissingInjectedHeader",E,"The `on_response` handler of Fairing could not find the…",2,N],[4,R[41],E,"An enum signifying that some of type T is allowed, or…",N,N],[13,"All",E,"Everything is allowed. Usually equivalent to the \"*\" value.",3,N],[13,"Some",E,"Only some of `T` is allowed",3,N],[5,"catch_all_options_routes",E,"Returns \"catch all\" OPTIONS routes that you can mount to…",N,[[],[["route"],["vec",["route"]]]]],[0,"headers",E,"CORS specific Request Headers",N,N],[3,R[48],R[24],"A case insensitive header name",N,N],[3,R[42],E,"The `Access-Control-Request-Method` request header",N,N],[12,"0",E,E,4,N],[3,R[43],E,"The `Access-Control-Request-Headers` request header",N,N],[12,"0",E,E,5,N],[4,"Origin",E,"The `Origin` request header used in CORS",N,N],[13,"Null",E,"A `null` Origin",6,N],[13,"Parsed",E,"A well-formed origin that was parsed by [`url::Url::origin`]",6,N],[13,"Opaque",E,"An unknown \"opaque\" origin that could not be parsed",6,N],[6,"HeaderFieldNamesSet",E,"A set of case insensitive header names",N,N],[11,"ascii_serialization",E,"Perform an ASCII serialization of this origin.",6,[[["self"]],[R[8]]]],[11,"is_tuple",E,"Returns whether the origin was parsed as non-opaque",6,[[["self"]],["bool"]]],[6,R[44],R[1],"A list of allowed origins. Either Some origins are…",N,N],[6,"AllowedMethods",E,"A list of allowed methods",N,N],[6,R[45],E,"A list of allowed headers",N,N],[11,"is_all",E,"Returns whether this is an `All` variant",3,[[["self"]],["bool"]]],[11,"is_some",E,"Returns whether this is a `Some` variant",3,[[["self"]],["bool"]]],[11,"unwrap",E,"Unwrap a `Some` variant and get its inner value",3,[[],[T]]],[11,"some",E,"Allows some origins, with a mix of exact matches or regex…",7,[[],["self"]]],[11,"some_exact",E,"Allows some exact origins",7,[[],["self"]]],[11,"some_regex",E,"Allow some regular expression origins",7,[[],["self"]]],[11,"some_null",E,"Allow some `null` origins",7,[[],["self"]]],[11,"all",E,"Allows all origins",7,[[],["self"]]],[11,"some",E,"Allow some headers",8,[[],["self"]]],[11,"all",E,"Allows all headers",8,[[],["self"]]],[11,"validate",E,"Validates if any of the settings are disallowed,…",1,[[["self"]],[[R[3]],[R[2],[R[3]]]]]],[11,"to_cors",E,"Creates a [`Cors`] struct that can be used to respond to…",1,[[["self"]],[["cors"],[R[2],["cors",R[3]]],[R[3]]]]],[11,"from_options",E,"Create a `Cors` struct from a [`CorsOptions`]",9,[[[R[25]]],[[R[3]],[R[2],[R[3]]]]]],[11,"respond_owned",E,R[5],9,[[["f"]],[[R[3]],[R[4]],[R[2],[R[4],R[3]]]]]],[11,"respond_borrowed",E,R[5],9,[[["self"],["f"]],[[R[3]],[R[4]],[R[2],[R[4],R[3]]]]]],[11,R[6],E,"Consumes the Guard and return a `Responder` that wraps a…",10,[[[R[6]]],[[R[6]],[R[6]]]]],[11,R[7],E,"Merge a `rocket::Response` with this CORS Guard. This is…",10,[[[R[7]],["self"]],[R[7]]]],[11,"into",E,E,11,[[],[U]]],[11,"from",E,E,11,[[[T]],[T]]],[11,R[11],E,E,11,[[["self"]],[T]]],[11,R[12],E,E,11,[[["self"],[T]]]],[11,R[23],E,E,11,[[["self"]],[R[8]]]],[11,R[13],E,E,11,[[[U]],[R[2]]]],[11,R[14],E,E,11,[[],[R[2]]]],[11,R[20],E,E,11,[[["self"]],[T]]],[11,R[15],E,E,11,[[["self"]],[T]]],[11,R[19],E,E,11,[[["self"]],[R[21]]]],[11,R[16],E,E,11,[[],[R[9]]]],[11,R[22],E,E,11,[[["f"]],[R[9]]]],[11,R[17],E,E,11,[[],[[R[2],[R[10]]],[R[10]]]]],[11,R[18],E,E,11,[[["k"],["self"]],["bool"]]],[11,"into",E,E,0,[[],[U]]],[11,"from",E,E,0,[[[T]],[T]]],[11,R[11],E,E,0,[[["self"]],[T]]],[11,R[12],E,E,0,[[["self"],[T]]]],[11,R[13],E,E,0,[[[U]],[R[2]]]],[11,R[14],E,E,0,[[],[R[2]]]],[11,R[20],E,E,0,[[["self"]],[T]]],[11,R[15],E,E,0,[[["self"]],[T]]],[11,R[19],E,E,0,[[["self"]],[R[21]]]],[11,R[16],E,E,0,[[],[R[9]]]],[11,R[22],E,E,0,[[["f"]],[R[9]]]],[11,R[17],E,E,0,[[],[[R[2],[R[10]]],[R[10]]]]],[11,R[18],E,E,0,[[["k"],["self"]],["bool"]]],[11,"into",E,E,1,[[],[U]]],[11,"from",E,E,1,[[[T]],[T]]],[11,R[11],E,E,1,[[["self"]],[T]]],[11,R[12],E,E,1,[[["self"],[T]]]],[11,R[13],E,E,1,[[[U]],[R[2]]]],[11,R[14],E,E,1,[[],[R[2]]]],[11,R[20],E,E,1,[[["self"]],[T]]],[11,R[15],E,E,1,[[["self"]],[T]]],[11,R[19],E,E,1,[[["self"]],[R[21]]]],[11,R[16],E,E,1,[[],[R[9]]]],[11,R[22],E,E,1,[[["f"]],[R[9]]]],[11,R[17],E,E,1,[[],[[R[2],[R[10]]],[R[10]]]]],[11,R[18],E,E,1,[[["k"],["self"]],["bool"]]],[11,"into",E,E,9,[[],[U]]],[11,"from",E,E,9,[[[T]],[T]]],[11,R[11],E,E,9,[[["self"]],[T]]],[11,R[12],E,E,9,[[["self"],[T]]]],[11,R[13],E,E,9,[[[U]],[R[2]]]],[11,R[14],E,E,9,[[],[R[2]]]],[11,R[20],E,E,9,[[["self"]],[T]]],[11,R[15],E,E,9,[[["self"]],[T]]],[11,R[19],E,E,9,[[["self"]],[R[21]]]],[11,R[16],E,E,9,[[],[R[9]]]],[11,R[22],E,E,9,[[["f"]],[R[9]]]],[11,R[17],E,E,9,[[],[[R[2],[R[10]]],[R[10]]]]],[11,"into",E,E,10,[[],[U]]],[11,"from",E,E,10,[[[T]],[T]]],[11,R[13],E,E,10,[[[U]],[R[2]]]],[11,R[14],E,E,10,[[],[R[2]]]],[11,R[20],E,E,10,[[["self"]],[T]]],[11,R[15],E,E,10,[[["self"]],[T]]],[11,R[19],E,E,10,[[["self"]],[R[21]]]],[11,R[16],E,E,10,[[],[R[9]]]],[11,R[22],E,E,10,[[["f"]],[R[9]]]],[11,R[17],E,E,10,[[],[[R[2],[R[10]]],[R[10]]]]],[11,"into",E,E,12,[[],[U]]],[11,"from",E,E,12,[[[T]],[T]]],[11,R[13],E,E,12,[[[U]],[R[2]]]],[11,R[14],E,E,12,[[],[R[2]]]],[11,R[20],E,E,12,[[["self"]],[T]]],[11,R[15],E,E,12,[[["self"]],[T]]],[11,R[19],E,E,12,[[["self"]],[R[21]]]],[11,R[16],E,E,12,[[],[R[9]]]],[11,R[22],E,E,12,[[["f"]],[R[9]]]],[11,R[17],E,E,12,[[],[[R[2],[R[10]]],[R[10]]]]],[11,"into",E,E,13,[[],[U]]],[11,"from",E,E,13,[[[T]],[T]]],[11,R[13],E,E,13,[[[U]],[R[2]]]],[11,R[14],E,E,13,[[],[R[2]]]],[11,R[20],E,E,13,[[["self"]],[T]]],[11,R[15],E,E,13,[[["self"]],[T]]],[11,R[19],E,E,13,[[["self"]],[R[21]]]],[11,R[16],E,E,13,[[],[R[9]]]],[11,R[22],E,E,13,[[["f"]],[R[9]]]],[11,R[17],E,E,13,[[],[[R[2],[R[10]]],[R[10]]]]],[11,"into",E,E,2,[[],[U]]],[11,"from",E,E,2,[[[T]],[T]]],[11,R[23],E,E,2,[[["self"]],[R[8]]]],[11,R[13],E,E,2,[[[U]],[R[2]]]],[11,R[14],E,E,2,[[],[R[2]]]],[11,R[20],E,E,2,[[["self"]],[T]]],[11,R[15],E,E,2,[[["self"]],[T]]],[11,R[19],E,E,2,[[["self"]],[R[21]]]],[11,R[16],E,E,2,[[],[R[9]]]],[11,R[22],E,E,2,[[["f"]],[R[9]]]],[11,R[17],E,E,2,[[],[[R[2],[R[10]]],[R[10]]]]],[11,"into",E,E,3,[[],[U]]],[11,"from",E,E,3,[[[T]],[T]]],[11,R[11],E,E,3,[[["self"]],[T]]],[11,R[12],E,E,3,[[["self"],[T]]]],[11,R[13],E,E,3,[[[U]],[R[2]]]],[11,R[14],E,E,3,[[],[R[2]]]],[11,R[20],E,E,3,[[["self"]],[T]]],[11,R[15],E,E,3,[[["self"]],[T]]],[11,R[19],E,E,3,[[["self"]],[R[21]]]],[11,R[16],E,E,3,[[],[R[9]]]],[11,R[22],E,E,3,[[["f"]],[R[9]]]],[11,R[17],E,E,3,[[],[[R[2],[R[10]]],[R[10]]]]],[11,R[18],E,E,3,[[["k"],["self"]],["bool"]]],[11,"into",R[24],E,14,[[],[U]]],[11,"from",E,E,14,[[[T]],[T]]],[11,R[11],E,E,14,[[["self"]],[T]]],[11,R[12],E,E,14,[[["self"],[T]]]],[11,R[23],E,E,14,[[["self"]],[R[8]]]],[11,R[13],E,E,14,[[[U]],[R[2]]]],[11,R[14],E,E,14,[[],[R[2]]]],[11,R[20],E,E,14,[[["self"]],[T]]],[11,R[15],E,E,14,[[["self"]],[T]]],[11,R[19],E,E,14,[[["self"]],[R[21]]]],[11,R[16],E,E,14,[[],[R[9]]]],[11,R[22],E,E,14,[[["f"]],[R[9]]]],[11,R[17],E,E,14,[[],[[R[2],[R[10]]],[R[10]]]]],[11,R[18],E,E,14,[[["k"],["self"]],["bool"]]],[11,"into",E,E,4,[[],[U]]],[11,"from",E,E,4,[[[T]],[T]]],[11,R[13],E,E,4,[[[U]],[R[2]]]],[11,R[14],E,E,4,[[],[R[2]]]],[11,R[20],E,E,4,[[["self"]],[T]]],[11,R[15],E,E,4,[[["self"]],[T]]],[11,R[19],E,E,4,[[["self"]],[R[21]]]],[11,R[16],E,E,4,[[],[R[9]]]],[11,R[22],E,E,4,[[["f"]],[R[9]]]],[11,R[17],E,E,4,[[],[[R[2],[R[10]]],[R[10]]]]],[11,"into",E,E,5,[[],[U]]],[11,"from",E,E,5,[[[T]],[T]]],[11,R[13],E,E,5,[[[U]],[R[2]]]],[11,R[14],E,E,5,[[],[R[2]]]],[11,R[20],E,E,5,[[["self"]],[T]]],[11,R[15],E,E,5,[[["self"]],[T]]],[11,R[19],E,E,5,[[["self"]],[R[21]]]],[11,R[16],E,E,5,[[],[R[9]]]],[11,R[22],E,E,5,[[["f"]],[R[9]]]],[11,R[17],E,E,5,[[],[[R[2],[R[10]]],[R[10]]]]],[11,R[18],E,E,5,[[["k"],["self"]],["bool"]]],[11,"into",E,E,6,[[],[U]]],[11,"from",E,E,6,[[[T]],[T]]],[11,R[11],E,E,6,[[["self"]],[T]]],[11,R[12],E,E,6,[[["self"],[T]]]],[11,R[23],E,E,6,[[["self"]],[R[8]]]],[11,R[13],E,E,6,[[[U]],[R[2]]]],[11,R[14],E,E,6,[[],[R[2]]]],[11,R[20],E,E,6,[[["self"]],[T]]],[11,R[15],E,E,6,[[["self"]],[T]]],[11,R[19],E,E,6,[[["self"]],[R[21]]]],[11,R[16],E,E,6,[[],[R[9]]]],[11,R[22],E,E,6,[[["f"]],[R[9]]]],[11,R[17],E,E,6,[[],[[R[2],[R[10]]],[R[10]]]]],[11,R[18],E,E,6,[[["k"],["self"]],["bool"]]],[11,"from",E,E,14,[[["str"]],["self"]]],[11,"from",E,E,14,[[[R[8]]],["self"]]],[11,"from",R[1],E,2,[[["parseerror"]],["self"]]],[11,"from",E,E,2,[[[R[3]]],["self"]]],[11,"from",E,E,11,[[[R[39]]],["self"]]],[11,"clone",R[24],E,14,[[["self"]],[R[27]]]],[11,"clone",E,E,6,[[["self"]],["origin"]]],[11,"clone",R[1],E,3,[[["self"]],[R[29]]]],[11,"clone",E,E,11,[[["self"]],[R[39]]]],[11,"clone",E,E,0,[[["self"]],[R[30]]]],[11,"clone",E,E,1,[[["self"]],[R[25]]]],[11,"clone",E,E,9,[[["self"]],["cors"]]],[11,R[26],E,E,3,[[],["self"]]],[11,R[26],E,E,0,[[],[R[30]]]],[11,R[26],E,E,1,[[],["self"]]],[11,"eq",R[24],E,14,[[["self"],[R[27]]],["bool"]]],[11,"ne",E,E,14,[[["self"],[R[27]]],["bool"]]],[11,"eq",E,E,6,[[["self"],["origin"]],["bool"]]],[11,"ne",E,E,6,[[["self"],["origin"]],["bool"]]],[11,"eq",E,E,5,[[["self"],[R[28]]],["bool"]]],[11,"ne",E,E,5,[[["self"],[R[28]]],["bool"]]],[11,"eq",R[1],E,3,[[["self"],[R[29]]],["bool"]]],[11,"ne",E,E,3,[[["self"],[R[29]]],["bool"]]],[11,"eq",E,E,11,[[[R[39]],["self"]],["bool"]]],[11,"ne",E,E,11,[[[R[39]],["self"]],["bool"]]],[11,"eq",E,E,0,[[["self"],[R[30]]],["bool"]]],[11,"ne",E,E,0,[[["self"],[R[30]]],["bool"]]],[11,"eq",E,E,1,[[["self"],[R[25]]],["bool"]]],[11,"ne",E,E,1,[[["self"],[R[25]]],["bool"]]],[11,"fmt",R[24],E,14,[[[R[31]],["self"]],[R[2]]]],[11,"fmt",E,E,6,[[[R[31]],["self"]],[R[2]]]],[11,"fmt",R[1],E,2,[[[R[31]],["self"]],[R[2]]]],[11,"fmt",E,E,11,[[[R[31]],["self"]],[R[2]]]],[11,"fmt",R[24],E,14,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,6,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,4,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,5,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",R[1],E,2,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,3,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,11,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,0,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,1,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,9,[[["self"],[R[31]]],[R[2]]]],[11,"fmt",E,E,12,[[["self"],[R[31]]],[R[2]]]],[11,R[32],R[24],E,14,[[["str"]],[R[2]]]],[11,R[32],E,E,6,[[["str"]],[R[2]]]],[11,R[32],E,E,4,[[["str"]],[R[2]]]],[11,R[32],E,"Will never fail",5,[[["str"]],[R[2]]]],[11,R[32],R[1],E,11,[[["str"]],[R[2]]]],[11,"deref",R[24],E,14,[[["self"]]]],[11,"deref",R[1],E,11,[[["self"]]]],[11,"hash",R[24],E,14,[[["self"],["__h"]]]],[11,"hash",E,E,6,[[["self"],["__h"]]]],[11,"hash",R[1],E,11,[[["self"],["__h"]]]],[11,"cause",E,E,2,[[["self"]],[["option",[R[3]]],[R[3]]]]],[11,R[33],R[24],E,6,[[[R[34]]],[[R[3]],[R[35],[R[3]]]]]],[11,R[33],E,E,4,[[[R[34]]],[[R[3]],[R[35],[R[3]]]]]],[11,R[33],E,E,5,[[[R[34]]],[[R[3]],[R[35],[R[3]]]]]],[11,R[33],R[1],E,10,[[[R[34]]],[R[35]]]],[11,R[36],E,E,2,[[[R[34]]],[[R[7]],["status"],[R[2],[R[7],"status"]]]]],[11,R[36],E,E,12,[[[R[34]]],[R[2]]]],[11,R[36],E,E,13,[[[R[34]]],[R[2]]]],[11,R[37],R[24],E,14,[[["self"],["__s"]],[R[2]]]],[11,R[37],R[1],E,3,[[["self"],["__s"]],[R[2]]]],[11,R[37],E,E,11,[[["s"],["self"]],[R[2]]]],[11,R[37],E,E,0,[[["self"],["__s"]],[R[2]]]],[11,R[37],E,E,1,[[["self"],["__s"]],[R[2]]]],[11,R[38],R[24],E,14,[[["__d"]],[R[2]]]],[11,R[38],R[1],E,3,[[["__d"]],[R[2]]]],[11,R[38],E,E,11,[[["d"]],[[R[2],[R[39]]],[R[39]]]]],[11,R[38],E,E,0,[[["__d"]],[R[2]]]],[11,R[38],E,E,1,[[["__d"]],[R[2]]]],[11,"info",E,E,9,[[["self"]],["info"]]],[11,"on_attach",E,E,9,[[["rocket"],["self"]],[[R[2],["rocket","rocket"]],["rocket"]]]],[11,"on_request",E,E,9,[[["data"],["self"],[R[34]]]]],[11,"on_response",E,E,9,[[[R[7]],["self"],[R[34]]]]]],"p":[[3,"Origins"],[3,R[40]],[4,"Error"],[4,R[41]],[3,R[42]],[3,R[43]],[4,"Origin"],[6,R[44]],[6,R[45]],[3,"Cors"],[3,"Guard"],[3,"Method"],[3,R[46]],[3,R[47]],[3,R[48]]]}; +initSearch(searchIndex);addSearchOptions(searchIndex); \ No newline at end of file diff --git a/settings.css b/settings.css new file mode 100644 index 0000000..6ce7665 --- /dev/null +++ b/settings.css @@ -0,0 +1 @@ +.setting-line{padding:5px;position:relative;}.setting-line>div{max-width:calc(100% - 74px);display:inline-block;vertical-align:top;font-size:17px;padding-top:2px;}.setting-line>.title{font-size:19px;width:100%;max-width:none;border-bottom:1px solid;}.toggle{position:relative;display:inline-block;width:45px;height:27px;margin-right:20px;}.toggle input{display:none;}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.3s;transition:.3s;}.slider:before{position:absolute;content:"";height:19px;width:19px;left:4px;bottom:4px;background-color:white;-webkit-transition:.3s;transition:.3s;}input:checked+.slider{background-color:#2196F3;}input:focus+.slider{box-shadow:0 0 1px #2196F3;}input:checked+.slider:before{-webkit-transform:translateX(19px);-ms-transform:translateX(19px);transform:translateX(19px);}.setting-line>.sub-settings{padding-left:42px;width:100%;display:block;} \ No newline at end of file diff --git a/settings.html b/settings.html new file mode 100644 index 0000000..efe8d72 --- /dev/null +++ b/settings.html @@ -0,0 +1,2 @@ +Rustdoc settings

Rustdoc settings

Auto-hide item declarations
Auto-hide structs declaration
Auto-hide enums declaration
Auto-hide unions declaration
Auto-hide traits declaration
Auto-hide macros declaration
+
Auto-hide item attributes.
Auto-hide item methods' documentation
Auto-hide trait implementations documentation
Directly go to item in search if there is only one result
Show line numbers on code examples
Disable keyboard shortcuts
\ No newline at end of file diff --git a/settings.js b/settings.js new file mode 100644 index 0000000..9930309 --- /dev/null +++ b/settings.js @@ -0,0 +1 @@ +(function(){function changeSetting(settingName,isEnabled){updateLocalStorage('rustdoc-'+settingName,isEnabled)}function getSettingValue(settingName){return getCurrentValue('rustdoc-'+settingName)}function setEvents(){var elems=document.getElementsByClassName("slider");if(!elems||elems.length===0){return}for(var i=0;i"){sidebar.style.left="";this.style.left="";child.innerText="<";updateLocalStorage("rustdoc-source-sidebar-show","true")}else{sidebar.style.left="-300px";this.style.left="0";child.innerText=">";updateLocalStorage("rustdoc-source-sidebar-show","false")}}function createSidebarToggle(){var sidebarToggle=document.createElement("div");sidebarToggle.id="sidebar-toggle";sidebarToggle.onclick=toggleSidebar;var inner1=document.createElement("div");inner1.style.position="relative";var inner2=document.createElement("div");inner2.style.paddingTop="3px";if(getCurrentValue("rustdoc-source-sidebar-show")==="true"){inner2.innerText="<"}else{inner2.innerText=">";sidebarToggle.style.left="0"}inner1.appendChild(inner2);sidebarToggle.appendChild(inner1);return sidebarToggle}function createSourceSidebar(){if(window.rootPath.endsWith("/")===false){window.rootPath+="/"}var main=document.getElementById("main");var sidebarToggle=createSidebarToggle();main.insertBefore(sidebarToggle,main.firstChild);var sidebar=document.createElement("div");sidebar.id="source-sidebar";if(getCurrentValue("rustdoc-source-sidebar-show")!=="true"){sidebar.style.left="-300px"}var currentFile=getCurrentFilePath();var hasFoundFile=false;var title=document.createElement("div");title.className="title";title.innerText="Files";sidebar.appendChild(title);Object.keys(sourcesIndex).forEach(function(key){sourcesIndex[key].name=key;hasFoundFile=createDirEntry(sourcesIndex[key],sidebar,"",currentFile,hasFoundFile)});main.insertBefore(sidebar,main.firstChild)} \ No newline at end of file diff --git a/src/rocket_cors/fairing.rs.html b/src/rocket_cors/fairing.rs.html new file mode 100644 index 0000000..5cc4815 --- /dev/null +++ b/src/rocket_cors/fairing.rs.html @@ -0,0 +1,385 @@ +fairing.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+
+//! Fairing implementation
+
+use ::log::{error, info, log};
+use rocket::http::{self, uri::Origin, Status};
+use rocket::{self, error_, info_, log_, Outcome, Request};
+
+use crate::{
+    actual_request_response, origin, preflight_response, request_headers, validate, Cors, Error,
+};
+
+/// Request Local State to store CORS validation results
+enum CorsValidation {
+    Success,
+    Failure,
+}
+
+/// Route for Fairing error handling
+pub(crate) fn fairing_error_route<'r>(
+    request: &'r Request<'_>,
+    _: rocket::Data,
+) -> rocket::handler::Outcome<'r> {
+    let status = request
+        .get_param::<u16>(0)
+        .unwrap_or(Ok(0))
+        .unwrap_or_else(|e| {
+            error_!("Fairing Error Handling Route error: {:?}", e);
+            500
+        });
+    let status = Status::from_code(status).unwrap_or_else(|| Status::InternalServerError);
+    Outcome::Failure(status)
+}
+
+/// Create a new `Route` for Fairing handling
+fn fairing_route(rank: isize) -> rocket::Route {
+    rocket::Route::ranked(rank, http::Method::Get, "/<status>", fairing_error_route)
+}
+
+/// Modifies a `Request` to route to Fairing error handler
+fn route_to_fairing_error_handler(options: &Cors, status: u16, request: &mut Request<'_>) {
+    let origin = Origin::parse_owned(format!("{}/{}", options.fairing_route_base, status)).unwrap();
+
+    request.set_method(http::Method::Get);
+    request.set_uri(origin);
+}
+
+fn on_response_wrapper(
+    options: &Cors,
+    request: &Request<'_>,
+    response: &mut rocket::Response<'_>,
+) -> Result<(), Error> {
+    let origin = match origin(request)? {
+        None => {
+            // Not a CORS request
+            return Ok(());
+        }
+        Some(origin) => origin,
+    };
+
+    let result = request.local_cache(|| unreachable!("This should not be executed so late"));
+
+    if let CorsValidation::Failure = *result {
+        // Nothing else for us to do
+        return Ok(());
+    }
+
+    let origin = origin.to_string();
+    let cors_response = if request.method() == http::Method::Options {
+        let headers = request_headers(request)?;
+        preflight_response(options, &origin, headers.as_ref())
+    } else {
+        actual_request_response(options, &origin)
+    };
+
+    cors_response.merge(response);
+
+    // If this was an OPTIONS request and no route can be found, we should turn this
+    // into a HTTP 204 with no content body.
+    // This allows the user to not have to specify an OPTIONS route for everything.
+    //
+    // TODO: Is there anyway we can make this smarter? Only modify status codes for
+    // requests where an actual route exist?
+    if request.method() == http::Method::Options && request.route().is_none() {
+        info_!(
+            "CORS Fairing: Turned missing route {} into an OPTIONS pre-flight request",
+            request
+        );
+        response.set_status(Status::NoContent);
+        let _ = response.take_body();
+    }
+    Ok(())
+}
+
+impl rocket::fairing::Fairing for Cors {
+    fn info(&self) -> rocket::fairing::Info {
+        rocket::fairing::Info {
+            name: "CORS",
+            kind: rocket::fairing::Kind::Attach
+                | rocket::fairing::Kind::Request
+                | rocket::fairing::Kind::Response,
+        }
+    }
+
+    fn on_attach(&self, rocket: rocket::Rocket) -> Result<rocket::Rocket, rocket::Rocket> {
+        Ok(rocket.mount(
+            &self.fairing_route_base,
+            vec![fairing_route(self.fairing_route_rank)],
+        ))
+    }
+
+    fn on_request(&self, request: &mut Request<'_>, _: &rocket::Data) {
+        let result = match validate(self, request) {
+            Ok(_) => CorsValidation::Success,
+            Err(err) => {
+                error_!("CORS Error: {}", err);
+                let status = err.status();
+                route_to_fairing_error_handler(self, status.code, request);
+                CorsValidation::Failure
+            }
+        };
+
+        let _ = request.local_cache(|| result);
+    }
+
+    fn on_response(&self, request: &Request<'_>, response: &mut rocket::Response<'_>) {
+        if let Err(err) = on_response_wrapper(self, request, response) {
+            error_!("Fairings on_response error: {}\nMost likely a bug", err);
+            response.set_status(Status::InternalServerError);
+            let _ = response.take_body();
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use rocket::http::{Method, Status};
+    use rocket::local::Client;
+    use rocket::Rocket;
+
+    use crate::{AllowedHeaders, AllowedOrigins, Cors, CorsOptions};
+
+    const CORS_ROOT: &str = "/my_cors";
+
+    fn make_cors_options() -> Cors {
+        let allowed_origins = AllowedOrigins::some_exact(&["https://www.acme.com"]);
+
+        CorsOptions {
+            allowed_origins,
+            allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(),
+            allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]),
+            allow_credentials: true,
+            fairing_route_base: CORS_ROOT.to_string(),
+
+            ..Default::default()
+        }
+        .to_cors()
+        .expect("Not to fail")
+    }
+
+    fn rocket(fairing: Cors) -> Rocket {
+        Rocket::ignite().attach(fairing)
+    }
+
+    #[test]
+    fn fairing_error_route_returns_passed_in_status() {
+        let client = Client::new(rocket(make_cors_options())).expect("to not fail");
+        let request = client.get(format!("{}/403", CORS_ROOT));
+        let response = request.dispatch();
+        assert_eq!(Status::Forbidden, response.status());
+    }
+
+    #[test]
+    fn fairing_error_route_returns_500_for_unknown_status() {
+        let client = Client::new(rocket(make_cors_options())).expect("to not fail");
+        let request = client.get(format!("{}/999", CORS_ROOT));
+        let response = request.dispatch();
+        assert_eq!(Status::InternalServerError, response.status());
+    }
+
+    #[test]
+    fn error_route_is_mounted_on_attach() {
+        let rocket = rocket(make_cors_options());
+
+        let expected_uri = format!("{}/<status>", CORS_ROOT);
+        let error_route = rocket
+            .routes()
+            .find(|r| r.method == Method::Get && r.uri.to_string() == expected_uri);
+        assert!(error_route.is_some());
+    }
+
+    // Rest of the things can only be tested in integration tests
+}
+
+
\ No newline at end of file diff --git a/src/rocket_cors/headers.rs.html b/src/rocket_cors/headers.rs.html new file mode 100644 index 0000000..f7b614a --- /dev/null +++ b/src/rocket_cors/headers.rs.html @@ -0,0 +1,719 @@ +headers.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+
+//! CORS specific Request Headers
+
+use std::collections::HashSet;
+use std::fmt;
+use std::ops::Deref;
+use std::str::FromStr;
+
+use rocket::http::Status;
+use rocket::request::{self, FromRequest};
+use rocket::{self, Outcome};
+#[cfg(feature = "serialization")]
+use serde_derive::{Deserialize, Serialize};
+use unicase::UniCase;
+
+#[cfg(feature = "serialization")]
+use unicase_serde;
+
+/// A case insensitive header name
+#[derive(Eq, PartialEq, Clone, Debug, Hash)]
+#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
+pub struct HeaderFieldName(
+    #[cfg_attr(feature = "serialization", serde(with = "unicase_serde::unicase"))] UniCase<String>,
+);
+
+impl Deref for HeaderFieldName {
+    type Target = String;
+
+    fn deref(&self) -> &Self::Target {
+        self.0.deref()
+    }
+}
+
+impl fmt::Display for HeaderFieldName {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        self.0.fmt(f)
+    }
+}
+
+impl<'a> From<&'a str> for HeaderFieldName {
+    fn from(s: &'a str) -> Self {
+        HeaderFieldName(From::from(s))
+    }
+}
+
+impl<'a> From<String> for HeaderFieldName {
+    fn from(s: String) -> Self {
+        HeaderFieldName(From::from(s))
+    }
+}
+
+impl FromStr for HeaderFieldName {
+    type Err = <String as FromStr>::Err;
+
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
+        Ok(HeaderFieldName(FromStr::from_str(s)?))
+    }
+}
+
+/// A set of case insensitive header names
+pub type HeaderFieldNamesSet = HashSet<HeaderFieldName>;
+
+/// The `Origin` request header used in CORS
+///
+/// You can use this as a rocket [Request Guard](https://rocket.rs/guide/requests/#request-guards)
+/// to ensure that `Origin` is passed in correctly.
+///
+/// Reference: [Mozilla](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin)
+#[derive(Eq, PartialEq, Clone, Hash, Debug)]
+pub enum Origin {
+    /// A `null` Origin
+    Null,
+    /// A well-formed origin that was parsed by [`url::Url::origin`]
+    Parsed(url::Origin),
+    /// An unknown "opaque" origin that could not be parsed
+    Opaque(String),
+}
+
+impl Origin {
+    /// Perform an
+    /// [ASCII serialization](https://html.spec.whatwg.org/multipage/#ascii-serialisation-of-an-origin)
+    /// of this origin.
+    pub fn ascii_serialization(&self) -> String {
+        self.to_string()
+    }
+
+    /// Returns whether the origin was parsed as non-opaque
+    pub fn is_tuple(&self) -> bool {
+        match self {
+            Origin::Null => false,
+            Origin::Parsed(ref parsed) => parsed.is_tuple(),
+            Origin::Opaque(_) => false,
+        }
+    }
+}
+
+impl FromStr for Origin {
+    type Err = crate::Error;
+
+    fn from_str(input: &str) -> Result<Self, Self::Err> {
+        if input.to_lowercase() == "null" {
+            Ok(Origin::Null)
+        } else {
+            match crate::to_origin(input)? {
+                url::Origin::Opaque(_) => Ok(Origin::Opaque(input.to_string())),
+                parsed @ url::Origin::Tuple(..) => Ok(Origin::Parsed(parsed)),
+            }
+        }
+    }
+}
+
+impl fmt::Display for Origin {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match self {
+            Origin::Null => write!(f, "null"),
+            Origin::Parsed(ref parsed) => write!(f, "{}", parsed.ascii_serialization()),
+            Origin::Opaque(ref opaque) => write!(f, "{}", opaque),
+        }
+    }
+}
+
+impl<'a, 'r> FromRequest<'a, 'r> for Origin {
+    type Error = crate::Error;
+
+    fn from_request(request: &'a rocket::Request<'r>) -> request::Outcome<Self, crate::Error> {
+        match request.headers().get_one("Origin") {
+            Some(origin) => match Self::from_str(origin) {
+                Ok(origin) => Outcome::Success(origin),
+                Err(e) => Outcome::Failure((Status::BadRequest, e)),
+            },
+            None => Outcome::Forward(()),
+        }
+    }
+}
+/// The `Access-Control-Request-Method` request header
+///
+/// You can use this as a rocket [Request Guard](https://rocket.rs/guide/requests/#request-guards)
+/// to ensure that the header is passed in correctly.
+#[derive(Debug)]
+pub struct AccessControlRequestMethod(pub crate::Method);
+
+impl FromStr for AccessControlRequestMethod {
+    type Err = ();
+
+    fn from_str(method: &str) -> Result<Self, Self::Err> {
+        Ok(AccessControlRequestMethod(crate::Method::from_str(method)?))
+    }
+}
+
+impl<'a, 'r> FromRequest<'a, 'r> for AccessControlRequestMethod {
+    type Error = crate::Error;
+
+    fn from_request(request: &'a rocket::Request<'r>) -> request::Outcome<Self, crate::Error> {
+        match request.headers().get_one("Access-Control-Request-Method") {
+            Some(request_method) => match Self::from_str(request_method) {
+                Ok(request_method) => Outcome::Success(request_method),
+                Err(_) => Outcome::Failure((Status::BadRequest, crate::Error::BadRequestMethod)),
+            },
+            None => Outcome::Forward(()),
+        }
+    }
+}
+
+/// The `Access-Control-Request-Headers` request header
+///
+/// You can use this as a rocket [Request Guard](https://rocket.rs/guide/requests/#request-guards)
+/// to ensure that the header is passed in correctly.
+#[derive(Eq, PartialEq, Debug)]
+pub struct AccessControlRequestHeaders(pub HeaderFieldNamesSet);
+
+/// Will never fail
+impl FromStr for AccessControlRequestHeaders {
+    type Err = ();
+
+    /// Will never fail
+    fn from_str(headers: &str) -> Result<Self, Self::Err> {
+        if headers.trim().is_empty() {
+            return Ok(AccessControlRequestHeaders(HashSet::new()));
+        }
+
+        let set: HeaderFieldNamesSet = headers
+            .split(',')
+            .map(|header| From::from(header.trim().to_string()))
+            .collect();
+        Ok(AccessControlRequestHeaders(set))
+    }
+}
+
+impl<'a, 'r> FromRequest<'a, 'r> for AccessControlRequestHeaders {
+    type Error = crate::Error;
+
+    fn from_request(request: &'a rocket::Request<'r>) -> request::Outcome<Self, crate::Error> {
+        match request.headers().get_one("Access-Control-Request-Headers") {
+            Some(request_headers) => match Self::from_str(request_headers) {
+                Ok(request_headers) => Outcome::Success(request_headers),
+                Err(()) => {
+                    unreachable!("`AccessControlRequestHeaders::from_str` should never fail")
+                }
+            },
+            None => Outcome::Forward(()),
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::str::FromStr;
+
+    use hyper;
+    use rocket;
+    use rocket::local::Client;
+
+    use super::*;
+
+    /// Make a client with no routes for unit testing
+    fn make_client() -> Client {
+        let rocket = rocket::ignite();
+        Client::new(rocket).expect("valid rocket instance")
+    }
+
+    // `Origin::from_str` tests
+
+    #[test]
+    fn origin_is_parsed_properly() {
+        let url = "https://foo.bar.xyz";
+        let parsed = not_err!(Origin::from_str(url));
+        assert_eq!(parsed.ascii_serialization(), url);
+    }
+
+    #[test]
+    fn origin_parsing_strips_paths() {
+        // this should never really be sent by a compliant user agent
+        let url = "https://foo.bar.xyz/path/somewhere";
+        let parsed = not_err!(Origin::from_str(url));
+        let expected = "https://foo.bar.xyz";
+        assert_eq!(parsed.ascii_serialization(), expected);
+    }
+
+    #[test]
+    #[should_panic(expected = "BadOrigin")]
+    fn origin_parsing_disallows_invalid_origins() {
+        let url = "invalid_url";
+        let _ = Origin::from_str(url).unwrap();
+    }
+
+    #[test]
+    fn origin_parses_opaque_origins() {
+        let url = "blob://foobar";
+        let parsed = not_err!(Origin::from_str(url));
+
+        assert!(!parsed.is_tuple());
+    }
+
+    // The following tests check that CORS Request headers are parsed correctly
+
+    #[test]
+    fn origin_header_conversion() {
+        let url = "https://foo.bar.xyz";
+        let parsed = not_err!(Origin::from_str(url));
+        assert_eq!(parsed.ascii_serialization(), url);
+
+        let url = "https://foo.bar.xyz:1234";
+        let parsed = not_err!(Origin::from_str(url));
+        assert_eq!(parsed.ascii_serialization(), url);
+
+        // this should never really be sent by a compliant user agent
+        let url = "https://foo.bar.xyz/path/somewhere";
+        let parsed = not_err!(Origin::from_str(url));
+        let expected = "https://foo.bar.xyz";
+        assert_eq!(parsed.ascii_serialization(), expected);
+
+        let url = "invalid_url";
+        let _ = is_err!(Origin::from_str(url));
+    }
+
+    #[test]
+    fn origin_header_parsing() {
+        let client = make_client();
+        let mut request = client.get("/");
+
+        let origin = hyper::header::Origin::new("https", "www.example.com", None);
+        request.add_header(origin);
+
+        let outcome: request::Outcome<Origin, crate::Error> =
+            FromRequest::from_request(request.inner());
+        let parsed_header = assert_matches!(outcome, Outcome::Success(s), s);
+        assert_eq!(
+            "https://www.example.com",
+            parsed_header.ascii_serialization()
+        );
+    }
+
+    #[test]
+    fn request_method_conversion() {
+        let method = "POST";
+        let parsed_method = not_err!(AccessControlRequestMethod::from_str(method));
+        assert_matches!(
+            parsed_method,
+            AccessControlRequestMethod(crate::Method(rocket::http::Method::Post))
+        );
+
+        let method = "options";
+        let parsed_method = not_err!(AccessControlRequestMethod::from_str(method));
+        assert_matches!(
+            parsed_method,
+            AccessControlRequestMethod(crate::Method(rocket::http::Method::Options))
+        );
+
+        let method = "INVALID";
+        is_err!(AccessControlRequestMethod::from_str(method));
+    }
+
+    #[test]
+    fn request_method_parsing() {
+        let client = make_client();
+        let mut request = client.get("/");
+        let method = hyper::header::AccessControlRequestMethod(hyper::method::Method::Get);
+        request.add_header(method);
+        let outcome: request::Outcome<AccessControlRequestMethod, crate::Error> =
+            FromRequest::from_request(request.inner());
+
+        let parsed_header = assert_matches!(outcome, Outcome::Success(s), s);
+        let AccessControlRequestMethod(parsed_method) = parsed_header;
+        assert_eq!("GET", parsed_method.as_str());
+    }
+
+    #[test]
+    fn request_headers_conversion() {
+        let headers = ["foo", "bar", "baz"];
+        let parsed_headers = not_err!(AccessControlRequestHeaders::from_str(&headers.join(", ")));
+        let expected_headers: HeaderFieldNamesSet =
+            headers.iter().map(|s| (*s).to_string().into()).collect();
+        let AccessControlRequestHeaders(actual_headers) = parsed_headers;
+        assert_eq!(actual_headers, expected_headers);
+    }
+
+    #[test]
+    fn request_headers_parsing() {
+        let client = make_client();
+        let mut request = client.get("/");
+        let headers = hyper::header::AccessControlRequestHeaders(vec![
+            FromStr::from_str("accept-language").unwrap(),
+            FromStr::from_str("date").unwrap(),
+        ]);
+        request.add_header(headers);
+        let outcome: request::Outcome<AccessControlRequestHeaders, crate::Error> =
+            FromRequest::from_request(request.inner());
+
+        let parsed_header = assert_matches!(outcome, Outcome::Success(s), s);
+        let AccessControlRequestHeaders(parsed_headers) = parsed_header;
+        let mut parsed_headers: Vec<String> =
+            parsed_headers.iter().map(ToString::to_string).collect();
+        parsed_headers.sort();
+        assert_eq!(
+            vec!["accept-language".to_string(), "date".to_string()],
+            parsed_headers
+        );
+    }
+}
+
+
\ No newline at end of file diff --git a/src/rocket_cors/lib.rs.html b/src/rocket_cors/lib.rs.html new file mode 100644 index 0000000..401515d --- /dev/null +++ b/src/rocket_cors/lib.rs.html @@ -0,0 +1,5823 @@ +lib.rs.html -- source
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022
+2023
+2024
+2025
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
+2046
+2047
+2048
+2049
+2050
+2051
+2052
+2053
+2054
+2055
+2056
+2057
+2058
+2059
+2060
+2061
+2062
+2063
+2064
+2065
+2066
+2067
+2068
+2069
+2070
+2071
+2072
+2073
+2074
+2075
+2076
+2077
+2078
+2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088
+2089
+2090
+2091
+2092
+2093
+2094
+2095
+2096
+2097
+2098
+2099
+2100
+2101
+2102
+2103
+2104
+2105
+2106
+2107
+2108
+2109
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
+2127
+2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139
+2140
+2141
+2142
+2143
+2144
+2145
+2146
+2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160
+2161
+2162
+2163
+2164
+2165
+2166
+2167
+2168
+2169
+2170
+2171
+2172
+2173
+2174
+2175
+2176
+2177
+2178
+2179
+2180
+2181
+2182
+2183
+2184
+2185
+2186
+2187
+2188
+2189
+2190
+2191
+2192
+2193
+2194
+2195
+2196
+2197
+2198
+2199
+2200
+2201
+2202
+2203
+2204
+2205
+2206
+2207
+2208
+2209
+2210
+2211
+2212
+2213
+2214
+2215
+2216
+2217
+2218
+2219
+2220
+2221
+2222
+2223
+2224
+2225
+2226
+2227
+2228
+2229
+2230
+2231
+2232
+2233
+2234
+2235
+2236
+2237
+2238
+2239
+2240
+2241
+2242
+2243
+2244
+2245
+2246
+2247
+2248
+2249
+2250
+2251
+2252
+2253
+2254
+2255
+2256
+2257
+2258
+2259
+2260
+2261
+2262
+2263
+2264
+2265
+2266
+2267
+2268
+2269
+2270
+2271
+2272
+2273
+2274
+2275
+2276
+2277
+2278
+2279
+2280
+2281
+2282
+2283
+2284
+2285
+2286
+2287
+2288
+2289
+2290
+2291
+2292
+2293
+2294
+2295
+2296
+2297
+2298
+2299
+2300
+2301
+2302
+2303
+2304
+2305
+2306
+2307
+2308
+2309
+2310
+2311
+2312
+2313
+2314
+2315
+2316
+2317
+2318
+2319
+2320
+2321
+2322
+2323
+2324
+2325
+2326
+2327
+2328
+2329
+2330
+2331
+2332
+2333
+2334
+2335
+2336
+2337
+2338
+2339
+2340
+2341
+2342
+2343
+2344
+2345
+2346
+2347
+2348
+2349
+2350
+2351
+2352
+2353
+2354
+2355
+2356
+2357
+2358
+2359
+2360
+2361
+2362
+2363
+2364
+2365
+2366
+2367
+2368
+2369
+2370
+2371
+2372
+2373
+2374
+2375
+2376
+2377
+2378
+2379
+2380
+2381
+2382
+2383
+2384
+2385
+2386
+2387
+2388
+2389
+2390
+2391
+2392
+2393
+2394
+2395
+2396
+2397
+2398
+2399
+2400
+2401
+2402
+2403
+2404
+2405
+2406
+2407
+2408
+2409
+2410
+2411
+2412
+2413
+2414
+2415
+2416
+2417
+2418
+2419
+2420
+2421
+2422
+2423
+2424
+2425
+2426
+2427
+2428
+2429
+2430
+2431
+2432
+2433
+2434
+2435
+2436
+2437
+2438
+2439
+2440
+2441
+2442
+2443
+2444
+2445
+2446
+2447
+2448
+2449
+2450
+2451
+2452
+2453
+2454
+2455
+2456
+2457
+2458
+2459
+2460
+2461
+2462
+2463
+2464
+2465
+2466
+2467
+2468
+2469
+2470
+2471
+2472
+2473
+2474
+2475
+2476
+2477
+2478
+2479
+2480
+2481
+2482
+2483
+2484
+2485
+2486
+2487
+2488
+2489
+2490
+2491
+2492
+2493
+2494
+2495
+2496
+2497
+2498
+2499
+2500
+2501
+2502
+2503
+2504
+2505
+2506
+2507
+2508
+2509
+2510
+2511
+2512
+2513
+2514
+2515
+2516
+2517
+2518
+2519
+2520
+2521
+2522
+2523
+2524
+2525
+2526
+2527
+2528
+2529
+2530
+2531
+2532
+2533
+2534
+2535
+2536
+2537
+2538
+2539
+2540
+2541
+2542
+2543
+2544
+2545
+2546
+2547
+2548
+2549
+2550
+2551
+2552
+2553
+2554
+2555
+2556
+2557
+2558
+2559
+2560
+2561
+2562
+2563
+2564
+2565
+2566
+2567
+2568
+2569
+2570
+2571
+2572
+2573
+2574
+2575
+2576
+2577
+2578
+2579
+2580
+2581
+2582
+2583
+2584
+2585
+2586
+2587
+2588
+2589
+2590
+2591
+2592
+2593
+2594
+2595
+2596
+2597
+2598
+2599
+2600
+2601
+2602
+2603
+2604
+2605
+2606
+2607
+2608
+2609
+2610
+2611
+2612
+2613
+2614
+2615
+2616
+2617
+2618
+2619
+2620
+2621
+2622
+2623
+2624
+2625
+2626
+2627
+2628
+2629
+2630
+2631
+2632
+2633
+2634
+2635
+2636
+2637
+2638
+2639
+2640
+2641
+2642
+2643
+2644
+2645
+2646
+2647
+2648
+2649
+2650
+2651
+2652
+2653
+2654
+2655
+2656
+2657
+2658
+2659
+2660
+2661
+2662
+2663
+2664
+2665
+2666
+2667
+2668
+2669
+2670
+2671
+2672
+2673
+2674
+2675
+2676
+2677
+2678
+2679
+2680
+2681
+2682
+2683
+2684
+2685
+2686
+2687
+2688
+2689
+2690
+2691
+2692
+2693
+2694
+2695
+2696
+2697
+2698
+2699
+2700
+2701
+2702
+2703
+2704
+2705
+2706
+2707
+2708
+2709
+2710
+2711
+2712
+2713
+2714
+2715
+2716
+2717
+2718
+2719
+2720
+2721
+2722
+2723
+2724
+2725
+2726
+2727
+2728
+2729
+2730
+2731
+2732
+2733
+2734
+2735
+2736
+2737
+2738
+2739
+2740
+2741
+2742
+2743
+2744
+2745
+2746
+2747
+2748
+2749
+2750
+2751
+2752
+2753
+2754
+2755
+2756
+2757
+2758
+2759
+2760
+2761
+2762
+2763
+2764
+2765
+2766
+2767
+2768
+2769
+2770
+2771
+2772
+2773
+2774
+2775
+2776
+2777
+2778
+2779
+2780
+2781
+2782
+2783
+2784
+2785
+2786
+2787
+2788
+2789
+2790
+2791
+2792
+2793
+2794
+2795
+2796
+2797
+2798
+2799
+2800
+2801
+2802
+2803
+2804
+2805
+2806
+2807
+2808
+2809
+2810
+2811
+2812
+2813
+2814
+2815
+2816
+2817
+2818
+2819
+2820
+2821
+2822
+2823
+2824
+2825
+2826
+2827
+2828
+2829
+2830
+2831
+2832
+2833
+2834
+2835
+2836
+2837
+2838
+2839
+2840
+2841
+2842
+2843
+2844
+2845
+2846
+2847
+2848
+2849
+2850
+2851
+2852
+2853
+2854
+2855
+2856
+2857
+2858
+2859
+2860
+2861
+2862
+2863
+2864
+2865
+2866
+2867
+2868
+2869
+2870
+2871
+2872
+2873
+2874
+2875
+2876
+2877
+2878
+2879
+2880
+2881
+2882
+2883
+2884
+2885
+2886
+2887
+2888
+2889
+2890
+2891
+2892
+2893
+2894
+2895
+2896
+2897
+2898
+2899
+2900
+2901
+2902
+2903
+2904
+2905
+2906
+2907
+2908
+2909
+2910
+
+/*!
+[![Build Status](https://travis-ci.org/lawliet89/rocket_cors.svg)](https://travis-ci.org/lawliet89/rocket_cors)
+[![Repository](https://img.shields.io/github/tag/lawliet89/rocket_cors.svg)](https://github.com/lawliet89/rocket_cors)
+[![Crates.io](https://img.shields.io/crates/v/rocket_cors.svg)](https://crates.io/crates/rocket_cors)
+
+- Documentation: [master branch](https://lawliet89.github.io/rocket_cors) | [stable](https://docs.rs/rocket_cors)
+
+Cross-origin resource sharing (CORS) for [Rocket](https://rocket.rs/) applications
+
+## Requirements
+
+- Nightly Rust
+- Rocket >= 0.4
+
+If you are using Rocket 0.3, use the `0.3.0` version of this crate.
+
+### Nightly Rust
+
+Rocket requires nightly Rust. You should probably install Rust with
+[rustup](https://www.rustup.rs/), then override the code directory to use nightly instead of
+stable. See
+[installation instructions](https://rocket.rs/guide/getting-started/#installing-rust).
+
+In particular, `rocket_cors` is currently targetted for the latest `nightly`. Older nightlies
+might work, but they are subject to the minimum that Rocket sets.
+
+## Installation
+
+Add the following to Cargo.toml:
+
+```toml
+rocket_cors = "0.5.1"
+```
+
+To use the latest `master` branch, for example:
+
+```toml
+rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" }
+```
+
+## Features
+
+By default, a `serialization` feature is enabled in this crate that allows you to (de)serialize
+the [`CorsOptions`] struct that is described below. If you would like to disable this, simply
+change your `Cargo.toml` to:
+
+```toml
+rocket_cors = { version = "0.5.1", default-features = false }
+```
+
+## Usage
+
+Before you can add CORS responses to your application, you need to create a [`CorsOptions`]
+struct that will hold the settings. Then, you need to create a [`Cors`] struct using
+[`CorsOptions::to_cors`] which will validate and optimise the settings for Rocket to use.
+
+Each of the examples can be run off the repository via `cargo run --example xxx` where `xxx` is
+
+- `fairing`
+- `guard`
+- `manual`
+
+### `CorsOptions` Struct
+
+The [`CorsOptions`] struct contains the settings for CORS requests to be validated
+and for responses to be generated. Defaults are defined for every field in the struct, and
+are documented on the [`CorsOptions`] page. You can also deserialize
+the struct from some format like JSON, YAML or TOML when the default `serialization` feature
+is enabled.
+
+### `Cors` Struct
+
+The [`Cors`] struct is what will be used with Rocket. After creating or deserializing a
+[`CorsOptions`] struct, use [`CorsOptions::to_cors`] to create a [`Cors`] struct.
+
+### Three modes of operation
+
+You can add CORS to your routes via one of three ways, in descending order of ease and in
+ascending order of flexibility.
+
+- Fairing (should only used exclusively)
+- Request Guard
+- Truly Manual
+
+Unfortunately, you cannot mix and match Fairing with any other of the methods, due to the
+limitation of Rocket's fairing API. That is, the checks for Fairing will always happen first,
+and if they fail, the route is never executed and so your guard or manual checks will never
+get executed.
+
+You can, however, mix and match guards and manual checks.
+
+In summary:
+
+|                                         | Fairing | Request Guard | Manual |
+|:---------------------------------------:|:-------:|:-------------:|:------:|
+|         Must apply to all routes        |    ✔    |       ✗       |    ✗   |
+| Different settings for different routes |    ✗    |       ✗       |    ✔   |
+|     May define custom OPTIONS routes    |    ✗    |       ✔       |    ✔   |
+
+### Fairing
+
+Fairing is the easiest to use and also the most inflexible. You don't have to define `OPTIONS`
+routes for your application, and the checks are done transparently.
+
+However, you can only have one set of settings that must apply to all routes. You cannot opt
+any route out of CORS checks.
+
+To use this, simply create a [`Cors`] from [`CorsOptions::to_cors`] and then
+[`attach`](https://api.rocket.rs/rocket/struct.Rocket.html#method.attach) it to Rocket.
+
+Refer to the [example](https://github.com/lawliet89/rocket_cors/blob/master/examples/fairing.rs).
+
+#### Injected Route
+
+The fairing implementation will inject a route during attachment to Rocket. This route is used
+to handle errors during CORS validation.
+
+This is due to the limitation in Rocket's Fairing
+[lifecycle](https://rocket.rs/guide/fairings/). Ideally, we want to validate the CORS request
+during `on_request`, and if the validation fails, we want to stop the route from even executing
+to
+
+1) prevent side effects
+1) prevent resource usage from unnecessary computation
+
+The only way to do this is to hijack the request and route it to our own injected route to
+handle errors. Rocket does not allow Fairings to stop the processing of a route.
+
+You can configure the behaviour of the injected route through a couple of fields in the
+[`CorsOptions`].
+
+### Request Guard
+
+Using request guard requires you to sacrifice the convenience of Fairings for being able to
+opt some routes out of CORS checks and enforcement. _BUT_ you are still restricted to only
+one set of CORS settings and you have to mount additional routes to catch and process OPTIONS
+requests. The `OPTIONS` routes are used for CORS preflight checks.
+
+You will have to do the following:
+
+- Create a [`Cors`] from [`CorsOptions`] and during Rocket's ignite, add the struct to
+Rocket's [managed state](https://rocket.rs/guide/state/#managed-state).
+- For all the routes that you want to enforce CORS on, you can mount either some
+[catch all route](catch_all_options_routes) or define your own route for the OPTIONS
+verb.
+- Then in all the routes you want to enforce CORS on, add a
+[Request Guard](https://rocket.rs/guide/requests/#request-guards) for the
+[`Guard`](Guard) struct in the route arguments. You should not wrap this in an
+`Option` or `Result` because the guard will let non-CORS requests through and will take over
+error handling in case of errors.
+- In your routes, to add CORS headers to your responses, use the appropriate functions on the
+[`Guard`](Guard) for a `Response` or a `Responder`.
+
+Refer to the [example](https://github.com/lawliet89/rocket_cors/blob/master/examples/guard.rs).
+
+## Truly Manual
+
+This mode is the most difficult to use but offers the most amount of flexibility.
+You might have to understand how the library works internally to know how to use this mode.
+In exchange, you can selectively choose which routes to offer CORS protection to, and you
+can mix and match CORS settings for the routes. You can combine usage of this mode with
+"guard" to offer a mix of ease of use and flexibility.
+
+You really do not need to use this unless you have a truly ad-hoc need to respond to CORS
+differently in a route. For example, you have a `ping` endpoint that allows all origins but
+the rest of your routes do not.
+
+### Handler
+
+This mode requires that you pass in a closure that will be lazily evaluated once a CORS request
+has been validated. If validation fails, the closure will not be run. You should put any code
+that has any side effects or with an appreciable computation cost inside this handler.
+
+### Steps to perform:
+- You will first need to have a [`Cors`] struct ready. This struct can be borrowed with a lifetime
+at least as long as `'r` which is the lifetime of a Rocket request. `'static` works too.
+In this case, you might as well use the `Guard` method above and place the `Cors` struct in
+Rocket's [state](https://rocket.rs/guide/state/).
+Alternatively, you can create a [`Cors`] struct directly in the route.
+- Your routes _might_ need to have a `'r` lifetime and return `impl Responder<'r>`. See below.
+- Using the [`Cors`] struct, use either the
+[`Cors::respond_owned`] or
+[`Cors::respond_borrowed`] function and pass in a handler
+that will be executed once CORS validation is successful.
+- Your handler will be passed a [`Guard`] which you will have to use to
+add CORS headers into your own response.
+- You will have to manually define your own `OPTIONS` routes.
+
+### Notes about route lifetime
+You might have to specify a `'r` lifetime in your routes and then return `impl Responder<'r>`.
+If you are not sure what to do, you can try to leave the lifetime out and then add it in
+when the compiler complains.
+
+Generally, you will need to manually annotate the lifetime for the following cases where
+the compiler is unable to [elide](https://doc.rust-lang.org/beta/nomicon/lifetime-elision.html)
+the lifetime:
+
+- Your function arguments do not borrow anything.
+- Your function arguments borrow from more than one lifetime.
+- Your function arguments borrow from a lifetime that is shorter than the `'r` lifetime
+required.
+
+You can see examples when the lifetime annotation is required (or not) in `examples/manual.rs`.
+
+See the [example](https://github.com/lawliet89/rocket_cors/blob/master/examples/manual.rs).
+
+## Mixing Guard and Manual
+
+You can mix `Guard` and `Truly Manual` modes together for your application. For example, your
+application might restrict the Origins that can access it, except for one `ping` route that
+allows all access.
+
+See the [example](https://github.com/lawliet89/rocket_cors/blob/master/examples/guard.rs).
+
+## Reference
+- [Fetch CORS Specification](https://fetch.spec.whatwg.org/#cors-protocol)
+- [Supplanted W3C CORS Specification](https://www.w3.org/TR/cors/)
+- [Resource Advice](https://w3c.github.io/webappsec-cors-for-developers/#resources)
+*/
+
+#![deny(
+    const_err,
+    dead_code,
+    deprecated,
+    exceeding_bitshifts,
+    improper_ctypes,
+    missing_docs,
+    mutable_transmutes,
+    no_mangle_const_items,
+    non_camel_case_types,
+    non_shorthand_field_patterns,
+    non_upper_case_globals,
+    overflowing_literals,
+    path_statements,
+    plugin_as_library,
+    stable_features,
+    trivial_casts,
+    trivial_numeric_casts,
+    unconditional_recursion,
+    unknown_crate_types,
+    unreachable_code,
+    unused_allocation,
+    unused_assignments,
+    unused_attributes,
+    unused_comparisons,
+    unused_extern_crates,
+    unused_features,
+    unused_imports,
+    unused_import_braces,
+    unused_qualifications,
+    unused_must_use,
+    unused_mut,
+    unused_parens,
+    unused_results,
+    unused_unsafe,
+    variant_size_differences,
+    warnings,
+    while_true
+)]
+#![allow(
+    missing_copy_implementations,
+    missing_debug_implementations,
+    unknown_lints,
+    unsafe_code,
+    intra_doc_link_resolution_failure
+)]
+#![doc(test(attr(allow(unused_variables), deny(warnings))))]
+
+#[cfg(test)]
+#[macro_use]
+mod test_macros;
+mod fairing;
+
+pub mod headers;
+
+use std::borrow::Cow;
+use std::collections::HashSet;
+use std::error;
+use std::fmt;
+use std::marker::PhantomData;
+use std::ops::Deref;
+use std::str::FromStr;
+
+use ::log::{debug, error, info, log};
+use regex::RegexSet;
+use rocket::http::{self, Status};
+use rocket::request::{FromRequest, Request};
+use rocket::response;
+use rocket::{debug_, error_, info_, log_, Outcome, State};
+#[cfg(feature = "serialization")]
+use serde_derive::{Deserialize, Serialize};
+
+use crate::headers::{
+    AccessControlRequestHeaders, AccessControlRequestMethod, HeaderFieldName, HeaderFieldNamesSet,
+    Origin,
+};
+
+/// Errors during operations
+///
+/// This enum implements `rocket::response::Responder` which will return an appropriate status code
+/// while printing out the error in the console.
+/// Because these errors are usually the result of an error while trying to respond to a CORS
+/// request, CORS headers cannot be added to the response and your applications requesting CORS
+/// will not be able to see the status code.
+#[derive(Debug)]
+pub enum Error {
+    /// The HTTP request header `Origin` is required but was not provided
+    MissingOrigin,
+    /// The HTTP request header `Origin` could not be parsed correctly.
+    BadOrigin(url::ParseError),
+    /// The configured Allowed Origins are Opaque origins. Use a Regex instead.
+    OpaqueAllowedOrigin(Vec<String>),
+    /// The request header `Access-Control-Request-Method` is required but is missing
+    MissingRequestMethod,
+    /// The request header `Access-Control-Request-Method` has an invalid value
+    BadRequestMethod,
+    /// The request header `Access-Control-Request-Headers`  is required but is missing.
+    MissingRequestHeaders,
+    /// Origin is not allowed to make this request
+    OriginNotAllowed(String),
+    /// Requested method is not allowed
+    MethodNotAllowed(String),
+    /// A regular expression compilation error
+    RegexError(regex::Error),
+    /// One or more headers requested are not allowed
+    HeadersNotAllowed,
+    /// Credentials are allowed, but the Origin is set to "*". This is not allowed by W3C
+    ///
+    /// This is a misconfiguration. Check the docuemntation for `Cors`.
+    CredentialsWithWildcardOrigin,
+    /// A CORS Request Guard was used, but no CORS Options was available in Rocket's state
+    ///
+    /// This is a misconfiguration. Use `Rocket::manage` to add a CORS options to managed state.
+    MissingCorsInRocketState,
+    /// The `on_response` handler of Fairing could not find the injected header from the Request.
+    /// Either some other fairing has removed it, or this is a bug.
+    MissingInjectedHeader,
+}
+
+impl Error {
+    fn status(&self) -> Status {
+        match *self {
+            Error::MissingOrigin
+            | Error::OriginNotAllowed(_)
+            | Error::MethodNotAllowed(_)
+            | Error::HeadersNotAllowed => Status::Forbidden,
+            Error::CredentialsWithWildcardOrigin
+            | Error::MissingCorsInRocketState
+            | Error::MissingInjectedHeader => Status::InternalServerError,
+            _ => Status::BadRequest,
+        }
+    }
+}
+
+impl fmt::Display for Error {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match self {
+            Error::MissingOrigin => write!(
+                f,
+                "The request header `Origin` is \
+                 required but is missing"
+            ),
+            Error::BadOrigin(_) => write!(f, "The request header `Origin` contains an invalid URL"),
+            Error::MissingRequestMethod => write!(
+                f,
+                "The request header `Access-Control-Request-Method` \
+                 is required but is missing"
+            ),
+            Error::BadRequestMethod => write!(
+                f,
+                "The request header `Access-Control-Request-Method` has an invalid value"
+            ),
+            Error::MissingRequestHeaders => write!(
+                f,
+                "The request header `Access-Control-Request-Headers` \
+                 is required but is missing"
+            ),
+            Error::OriginNotAllowed(origin) => write!(
+                f,
+                "Origin '{}' is \
+                 not allowed to request",
+                origin
+            ),
+            Error::MethodNotAllowed(method) => write!(f, "Method '{}' is not allowed", &method),
+            Error::HeadersNotAllowed => write!(f, "Headers are not allowed"),
+            Error::CredentialsWithWildcardOrigin => write!(
+                f,
+                "Credentials are allowed, but the Origin is set to \"*\". \
+                 This is not allowed by W3C"
+            ),
+            Error::MissingCorsInRocketState => write!(
+                f,
+                "A CORS Request Guard was used, but no CORS Options \
+                 was available in Rocket's state"
+            ),
+            Error::MissingInjectedHeader => {
+                write!(f,
+                "The `on_response` handler of Fairing could not find the injected header from the \
+                 Request. Either some other fairing has removed it, or this is a bug.")
+            }
+            Error::OpaqueAllowedOrigin(ref origins) => write!(
+                f,
+                "The configured Origins '{}' are Opaque Origins. \
+                 Use regex instead.",
+                origins.join("; ")
+            ),
+            Error::RegexError(ref e) => write!(f, "{}", e),
+        }
+    }
+}
+
+impl error::Error for Error {
+    fn cause(&self) -> Option<&dyn error::Error> {
+        match *self {
+            Error::BadOrigin(ref e) => Some(e),
+            _ => Some(self),
+        }
+    }
+}
+
+impl<'r> response::Responder<'r> for Error {
+    fn respond_to(self, _: &Request<'_>) -> Result<response::Response<'r>, Status> {
+        error_!("CORS Error: {}", self);
+        Err(self.status())
+    }
+}
+
+impl From<url::ParseError> for Error {
+    fn from(error: url::ParseError) -> Self {
+        Error::BadOrigin(error)
+    }
+}
+
+impl From<regex::Error> for Error {
+    fn from(error: regex::Error) -> Self {
+        Error::RegexError(error)
+    }
+}
+
+/// An enum signifying that some of type T is allowed, or `All` (everything is allowed).
+///
+/// `Default` is implemented for this enum and is `All`.
+///
+/// This enum is serialized and deserialized
+/// ["Externally tagged"](https://serde.rs/enum-representations.html)
+#[derive(Clone, Debug, Eq, PartialEq)]
+#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
+pub enum AllOrSome<T> {
+    /// Everything is allowed. Usually equivalent to the "*" value.
+    All,
+    /// Only some of `T` is allowed
+    Some(T),
+}
+
+impl<T> Default for AllOrSome<T> {
+    fn default() -> Self {
+        AllOrSome::All
+    }
+}
+
+impl<T> AllOrSome<T> {
+    /// Returns whether this is an `All` variant
+    pub fn is_all(&self) -> bool {
+        match self {
+            AllOrSome::All => true,
+            AllOrSome::Some(_) => false,
+        }
+    }
+
+    /// Returns whether this is a `Some` variant
+    pub fn is_some(&self) -> bool {
+        !self.is_all()
+    }
+
+    /// Unwrap a `Some` variant and get its inner value
+    ///
+    /// # Panics
+    /// Panics if the variant is `All`
+    pub fn unwrap(self) -> T {
+        match self {
+            AllOrSome::All => panic!("Attempting to unwrap an `All`"),
+            AllOrSome::Some(inner) => inner,
+        }
+    }
+}
+
+/// A wrapper type around `rocket::http::Method` to support serialization and deserialization
+#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
+pub struct Method(http::Method);
+
+impl FromStr for Method {
+    type Err = ();
+
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
+        let method = http::Method::from_str(s)?;
+        Ok(Method(method))
+    }
+}
+
+impl Deref for Method {
+    type Target = http::Method;
+
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+impl From<http::Method> for Method {
+    fn from(method: http::Method) -> Self {
+        Method(method)
+    }
+}
+
+impl fmt::Display for Method {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        fmt::Display::fmt(&self.0, f)
+    }
+}
+
+#[cfg(feature = "serialization")]
+mod method_serde {
+    use std::fmt;
+    use std::str::FromStr;
+
+    use serde::{self, Deserialize, Serialize};
+
+    use crate::Method;
+
+    impl Serialize for Method {
+        fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where
+            S: serde::Serializer,
+        {
+            serializer.serialize_str(self.as_str())
+        }
+    }
+
+    impl<'de> Deserialize<'de> for Method {
+        fn deserialize<D>(deserializer: D) -> Result<Method, D::Error>
+        where
+            D: serde::Deserializer<'de>,
+        {
+            use serde::de::{self, Visitor};
+
+            struct MethodVisitor;
+            impl<'de> Visitor<'de> for MethodVisitor {
+                type Value = Method;
+
+                fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
+                    formatter.write_str("a string containing a HTTP Verb")
+                }
+
+                fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
+                where
+                    E: de::Error,
+                {
+                    match Self::Value::from_str(s) {
+                        Ok(value) => Ok(value),
+                        Err(e) => Err(de::Error::custom(format!("{:?}", e))),
+                    }
+                }
+            }
+
+            deserializer.deserialize_string(MethodVisitor)
+        }
+    }
+}
+
+/// A list of allowed origins. Either Some origins are allowed, or all origins are allowed.
+///
+/// Exact matches are matched exactly with the
+/// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+/// of the origin.
+///
+/// Regular expressions are tested for matches against the
+/// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+/// of the origin.
+///
+/// # Opaque Origins
+/// The [specification](https://html.spec.whatwg.org/multipage/origin.html) defines an Opaque Origin
+/// as one that cannot be recreated. You can refer to the source code for the [`url::Url::origin`]
+/// method to see how an Opaque Origin is determined. Examples of Opaque origins might include
+/// schemes like `file://` or Browser specific schemes like `"moz-extension://` or
+/// `chrome-extension://`.
+///
+/// Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you
+/// attempt to create [`Cors`] from [`CorsOptions`], you will get an error.
+/// # Warning about Regex expressions
+/// By default, regex expressions are
+/// [unanchored](https://docs.rs/regex/1.1.2/regex/struct.RegexSet.html#method.is_match).
+///
+/// This means that if the regex does not start with `^` or `\A`, or end with `$` or `\z`,
+/// then it is permitted to match anywhere in the text. You are encouraged to use the anchors when
+/// crafting your Regex expressions.
+///
+/// # Examples
+/// ```rust
+/// use rocket_cors::AllowedOrigins;
+///
+/// let exact = ["https://www.acme.com"];
+/// let regex = ["^https://(.+).acme.com$"];
+///
+/// let all_origins = AllowedOrigins::all();
+/// let some_origins = AllowedOrigins::some_exact(&exact);
+/// let null_origins = AllowedOrigins::some_null();
+/// let regex_origins = AllowedOrigins::some_regex(&regex);
+/// let mixed_origins = AllowedOrigins::some(&exact, &regex);
+/// ```
+///
+pub type AllowedOrigins = AllOrSome<Origins>;
+
+impl AllowedOrigins {
+    /// Allows some origins, with a mix of exact matches or regex matches
+    ///
+    /// Validation is not performed at this stage, but at a later stage.
+    ///
+    /// Exact matches are matched exactly with the
+    /// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+    /// of the origin.
+    ///
+    /// Regular expressions are tested for matches against the
+    /// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+    /// of the origin.
+    ///
+    /// # Opaque Origins
+    /// The [specification](https://html.spec.whatwg.org/multipage/origin.html) defines an Opaque Origin
+    /// as one that cannot be recreated. You can refer to the source code for the [`url::Url::origin`]
+    /// method to see how an Opaque Origin is determined. Examples of Opaque origins might include
+    /// schemes like `file://` or Browser specific schemes like `"moz-extension://` or
+    /// `chrome-extension://`.
+    ///
+    /// Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you
+    /// attempt to create [`Cors`] from [`CorsOptions`], you will get an error.
+    /// # Warning about Regex expressions
+    /// By default, regex expressions are
+    /// [unanchored](https://docs.rs/regex/1.1.2/regex/struct.RegexSet.html#method.is_match).
+    ///
+    /// This means that if the regex does not start with `^` or `\A`, or end with `$` or `\z`,
+    /// then it is permitted to match anywhere in the text. You are encouraged to use the anchors when
+    /// crafting your Regex expressions.
+    #[allow(clippy::needless_lifetimes)]
+    pub fn some<'a, 'b, S1: AsRef<str>, S2: AsRef<str>>(exact: &'a [S1], regex: &'b [S2]) -> Self {
+        AllOrSome::Some(Origins {
+            exact: Some(exact.iter().map(|s| s.as_ref().to_string()).collect()),
+            regex: Some(regex.iter().map(|s| s.as_ref().to_string()).collect()),
+            ..Default::default()
+        })
+    }
+
+    /// Allows some _exact_ origins
+    ///
+    /// Validation is not performed at this stage, but at a later stage.
+    ///
+    /// Exact matches are matched exactly with the
+    /// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+    /// of the origin.
+    /// # Opaque Origins
+    /// The [specification](https://html.spec.whatwg.org/multipage/origin.html) defines an Opaque Origin
+    /// as one that cannot be recreated. You can refer to the source code for the [`url::Url::origin`]
+    /// method to see how an Opaque Origin is determined. Examples of Opaque origins might include
+    /// schemes like `file://` or Browser specific schemes like `"moz-extension://` or
+    /// `chrome-extension://`.
+    pub fn some_exact<S: AsRef<str>>(exact: &[S]) -> Self {
+        AllOrSome::Some(Origins {
+            exact: Some(exact.iter().map(|s| s.as_ref().to_string()).collect()),
+            ..Default::default()
+        })
+    }
+
+    /// Allow some regular expression origins
+    ///
+    /// Validation is not performed at this stage, but at a later stage.
+    ///
+    /// Regular expressions are tested for matches against the
+    /// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+    /// of the origin.
+    ///
+    /// # Warning about Regex expressions
+    /// By default, regex expressions are
+    /// [unanchored](https://docs.rs/regex/1.1.2/regex/struct.RegexSet.html#method.is_match).
+    ///
+    /// This means that if the regex does not start with `^` or `\A`, or end with `$` or `\z`,
+    /// then it is permitted to match anywhere in the text. You are encouraged to use the anchors when
+    /// crafting your Regex expressions.
+    pub fn some_regex<S: AsRef<str>>(regex: &[S]) -> Self {
+        AllOrSome::Some(Origins {
+            regex: Some(regex.iter().map(|s| s.as_ref().to_string()).collect()),
+            ..Default::default()
+        })
+    }
+
+    /// Allow some `null` origins
+    pub fn some_null() -> Self {
+        AllOrSome::Some(Origins {
+            allow_null: true,
+            ..Default::default()
+        })
+    }
+
+    /// Allows all origins
+    pub fn all() -> Self {
+        AllOrSome::All
+    }
+}
+
+/// Origins that are allowed to make CORS requests.
+///
+/// An origin is defined according to the defined
+/// [syntax](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin).
+///
+/// Origins can be specified as an exact match or using regex.
+///
+/// These Origins are specified as logical `ORs`. That is, if any of the origins match, the entire
+/// request is considered to be valid.
+///
+/// Exact matches are matched exactly with the
+/// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+/// of the origin.
+///
+/// Regular expressions are tested for matches against the
+/// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+/// of the origin.
+///
+/// # Opaque Origins
+/// The [specification](https://html.spec.whatwg.org/multipage/origin.html) defines an Opaque Origin
+/// as one that cannot be recreated. You can refer to the source code for the [`url::Url::origin`]
+/// method to see how an Opaque Origin is determined. Examples of Opaque origins might include
+/// schemes like `file://` or Browser specific schemes like `"moz-extension://` or
+/// `chrome-extension://`.
+///
+/// Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you
+/// attempt to create [`Cors`] from [`CorsOptions`], you will get an error.
+///
+/// # Warning about Regex expressions
+/// By default, regex expressions are
+/// [unanchored](https://docs.rs/regex/1.1.2/regex/struct.RegexSet.html#method.is_match).
+///
+/// This means that if the regex does not start with `^` or `\A`, or end with `$` or `\z`,
+/// then it is permitted to match anywhere in the text. You are encouraged to use the anchors when
+/// crafting your Regex expressions.
+#[derive(Clone, PartialEq, Eq, Debug, Default)]
+#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "serialization", serde(default))]
+pub struct Origins {
+    /// Whether null origins are accepted
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub allow_null: bool,
+    /// Origins that must be matched exactly as provided.
+    ///
+    /// These __must__ be valid URL strings that will be parsed and validated when
+    /// creating [`Cors`].
+    ///
+    /// Exact matches are matched exactly with the
+    /// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+    /// of the origin.
+    ///
+    /// # Opaque Origins
+    /// The [specification](https://html.spec.whatwg.org/multipage/origin.html) defines an Opaque Origin
+    /// as one that cannot be recreated. You can refer to the source code for the [`url::Url::origin`]
+    /// method to see how an Opaque Origin is determined. Examples of Opaque origins might include
+    /// schemes like `file://` or Browser specific schemes like `"moz-extension://` or
+    /// `chrome-extension://`.
+    ///
+    /// Opaque Origins cannot be matched exactly. You must use Regex to match Opaque Origins. If you
+    /// attempt to create [`Cors`] from [`CorsOptions`], you will get an error.
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub exact: Option<HashSet<String>>,
+    /// Origins that will be matched via __any__ regex in this list.
+    ///
+    /// These __must__ be valid Regex that will be parsed and validated when creating [`Cors`].
+    ///
+    /// The regex will be matched according to the
+    /// [ASCII serialization](https://html.spec.whatwg.org/multipage/#ascii-serialisation-of-an-origin)
+    /// of the incoming Origin.
+    ///
+    /// For more information on the syntax of Regex in Rust, see the
+    /// [documentation](https://docs.rs/regex).
+    ///
+    /// Regular expressions are tested for matches against the
+    /// [ASCII Serialization](https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin)
+    /// of the origin.
+    ///
+    /// # Warning about Regex expressions
+    /// By default, regex expressions are
+    /// [unanchored](https://docs.rs/regex/1.1.2/regex/struct.RegexSet.html#method.is_match).
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub regex: Option<HashSet<String>>,
+}
+
+/// Parsed set of configured allowed origins
+#[derive(Clone, Debug)]
+pub(crate) struct ParsedAllowedOrigins {
+    pub allow_null: bool,
+    pub exact: HashSet<url::Origin>,
+    pub regex: Option<RegexSet>,
+}
+
+impl ParsedAllowedOrigins {
+    fn parse(origins: &Origins) -> Result<Self, Error> {
+        let exact: Result<Vec<(&str, url::Origin)>, Error> = match &origins.exact {
+            Some(exact) => exact
+                .iter()
+                .map(|url| Ok((url.as_str(), to_origin(url.as_str())?)))
+                .collect(),
+            None => Ok(Default::default()),
+        };
+        let exact = exact?;
+
+        // Let's check if they are Opaque
+        let (tuple, opaque): (Vec<_>, Vec<_>) =
+            exact.into_iter().partition(|(_, url)| url.is_tuple());
+
+        if !opaque.is_empty() {
+            return Err(Error::OpaqueAllowedOrigin(
+                opaque
+                    .into_iter()
+                    .map(|(original, _)| original.to_string())
+                    .collect(),
+            ));
+        }
+
+        let exact = tuple.into_iter().map(|(_, url)| url).collect();
+
+        let regex = match &origins.regex {
+            None => None,
+            Some(ref regex) => Some(RegexSet::new(regex)?),
+        };
+
+        Ok(Self {
+            allow_null: origins.allow_null,
+            exact,
+            regex,
+        })
+    }
+
+    fn verify(&self, origin: &Origin) -> bool {
+        info_!("Verifying origin: {}", origin);
+        match origin {
+            Origin::Null => {
+                info_!("Origin is null. Allowing? {}", self.allow_null);
+                self.allow_null
+            }
+            Origin::Parsed(ref parsed) => {
+                assert!(
+                    parsed.is_tuple(),
+                    "Parsed Origin is not tuple. This is a bug. Please report"
+                );
+                // Verify by exact, then regex
+                if self.exact.get(parsed).is_some() {
+                    info_!("Origin has an exact match");
+                    return true;
+                }
+                if let Some(regex_set) = &self.regex {
+                    let regex_match = regex_set.is_match(&parsed.ascii_serialization());
+                    debug_!("Matching against regex set {:#?}", regex_set);
+                    info_!("Origin has a regex match? {}", regex_match);
+                    return regex_match;
+                }
+
+                info!("Origin does not match anything");
+                false
+            }
+            Origin::Opaque(ref opaque) => {
+                if let Some(regex_set) = &self.regex {
+                    let regex_match = regex_set.is_match(opaque);
+                    debug_!("Matching against regex set {:#?}", regex_set);
+                    info_!("Origin has a regex match? {}", regex_match);
+                    return regex_match;
+                }
+
+                info!("Origin does not match anything");
+                false
+            }
+        }
+    }
+}
+
+/// A list of allowed methods
+///
+/// The [list](https://api.rocket.rs/rocket/http/enum.Method.html)
+/// of methods is whatever is supported by Rocket.
+///
+/// # Example
+/// ```rust
+/// use std::str::FromStr;
+/// use rocket_cors::AllowedMethods;
+///
+/// let allowed_methods: AllowedMethods = ["Get", "Post", "Delete"]
+///    .iter()
+///    .map(|s| FromStr::from_str(s).unwrap())
+///    .collect();
+/// ```
+pub type AllowedMethods = HashSet<Method>;
+
+/// A list of allowed headers
+///
+/// # Examples
+/// ```rust
+/// use rocket_cors::AllowedHeaders;
+///
+/// let all_headers = AllowedHeaders::all();
+/// let some_headers = AllowedHeaders::some(&["Authorization", "Accept"]);
+/// ```
+pub type AllowedHeaders = AllOrSome<HashSet<HeaderFieldName>>;
+
+impl AllowedHeaders {
+    /// Allow some headers
+    pub fn some(headers: &[&str]) -> Self {
+        AllOrSome::Some(headers.iter().map(|s| (*s).to_string().into()).collect())
+    }
+
+    /// Allows all headers
+    pub fn all() -> Self {
+        AllOrSome::All
+    }
+}
+
+/// Configuration options for CORS request handling.
+///
+/// You create a new copy of this struct by defining the configurations in the fields below.
+/// This struct can also be deserialized by serde with the `serialization` feature which is
+/// enabled by default.
+///
+/// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html) is implemented for this
+/// struct. The default for each field is described in the docuementation for the field.
+///
+/// Before you can use this with Rocket, you will need to call the [`CorsOptions::to_cors`] method.
+///
+/// # Examples
+///
+/// You can run an example from the repository to demonstrate the JSON serialization with
+/// `cargo run --example json`.
+///
+/// ## Pure default
+/// ```rust
+/// let default = rocket_cors::CorsOptions::default();
+/// ```
+///
+/// ## JSON Examples
+/// ### Default
+///
+/// ```json
+/// {
+///   "allowed_origins": "All",
+///   "allowed_methods": [
+///     "POST",
+///     "PATCH",
+///     "PUT",
+///     "DELETE",
+///     "HEAD",
+///     "OPTIONS",
+///     "GET"
+///   ],
+///   "allowed_headers": "All",
+///   "allow_credentials": false,
+///   "expose_headers": [],
+///   "max_age": null,
+///   "send_wildcard": false,
+///   "fairing_route_base": "/cors",
+///   "fairing_route_rank": 0
+/// }
+/// ```
+/// ### Defined
+/// ```json
+/// {
+///   "allowed_origins": {
+///     "Some": {
+///         "exact": ["https://www.acme.com"],
+///         "regex": ["^https://www.example-[A-z0-9]*.com$"]
+///     }
+///   },
+///   "allowed_methods": [
+///     "POST",
+///     "DELETE",
+///     "GET"
+///   ],
+///   "allowed_headers": {
+///     "Some": [
+///       "Accept",
+///       "Authorization"
+///     ]
+///   },
+///   "allow_credentials": true,
+///   "expose_headers": [
+///     "Content-Type",
+///     "X-Custom"
+///   ],
+///   "max_age": 42,
+///   "send_wildcard": false,
+///   "fairing_route_base": "/mycors"
+/// }
+///
+/// ```
+#[derive(Eq, PartialEq, Clone, Debug)]
+#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
+pub struct CorsOptions {
+    /// Origins that are allowed to make requests.
+    /// Will be verified against the `Origin` request header.
+    ///
+    /// When `All` is set, and `send_wildcard` is set, "*" will be sent in
+    /// the `Access-Control-Allow-Origin` response header. Otherwise, the client's `Origin` request
+    /// header will be echoed back in the `Access-Control-Allow-Origin` response header.
+    ///
+    /// When `Some` is set, the client's `Origin` request header will be checked in a
+    /// case-sensitive manner.
+    ///
+    /// This is the `list of origins` in the
+    /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
+    ///
+    /// Defaults to `All`.
+    ///
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub allowed_origins: AllowedOrigins,
+    /// The list of methods which the allowed origins are allowed to access for
+    /// non-simple requests.
+    ///
+    /// This is the `list of methods` in the
+    /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
+    ///
+    /// Defaults to `[GET, HEAD, POST, OPTIONS, PUT, PATCH, DELETE]`
+    #[cfg_attr(
+        feature = "serialization",
+        serde(default = "CorsOptions::default_allowed_methods")
+    )]
+    pub allowed_methods: AllowedMethods,
+    /// The list of header field names which can be used when this resource is accessed by allowed
+    /// origins.
+    ///
+    /// If `All` is set, whatever is requested by the client in `Access-Control-Request-Headers`
+    /// will be echoed back in the `Access-Control-Allow-Headers` header.
+    ///
+    /// This is the `list of headers` in the
+    /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
+    ///
+    /// Defaults to `All`.
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub allowed_headers: AllowedHeaders,
+    /// Allows users to make authenticated requests.
+    /// If true, injects the `Access-Control-Allow-Credentials` header in responses.
+    /// This allows cookies and credentials to be submitted across domains.
+    ///
+    /// This **CANNOT** be used in conjunction with `allowed_origins` set to `All` and
+    /// `send_wildcard` set to `true`. Depending on the mode of usage, this will either result
+    /// in an `Error::CredentialsWithWildcardOrigin` error during Rocket launch or runtime.
+    ///
+    /// Defaults to `false`.
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub allow_credentials: bool,
+    /// The list of headers which are safe to expose to the API of a CORS API specification.
+    /// This corresponds to the `Access-Control-Expose-Headers` responde header.
+    ///
+    /// This is the `list of exposed headers` in the
+    /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
+    ///
+    /// This defaults to an empty set.
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub expose_headers: HashSet<String>,
+    /// The maximum time for which this CORS request maybe cached. This value is set as the
+    /// `Access-Control-Max-Age` header.
+    ///
+    /// This defaults to `None` (unset).
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub max_age: Option<usize>,
+    /// If true, and the `allowed_origins` parameter is `All`, a wildcard
+    /// `Access-Control-Allow-Origin` response header is sent, rather than the request’s
+    /// `Origin` header.
+    ///
+    /// This is the `supports credentials flag` in the
+    /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
+    ///
+    /// This **CANNOT** be used in conjunction with `allowed_origins` set to `All` and
+    /// `allow_credentials` set to `true`. Depending on the mode of usage, this will either result
+    /// in an `Error::CredentialsWithWildcardOrigin` error during Rocket launch or runtime.
+    ///
+    /// Defaults to `false`.
+    #[cfg_attr(feature = "serialization", serde(default))]
+    pub send_wildcard: bool,
+    /// When used as Fairing, Cors will need to redirect failed CORS checks to a custom route
+    /// mounted by the fairing. Specify the base of the route so that it doesn't clash with any
+    /// of your existing routes.
+    ///
+    /// Defaults to "/cors"
+    #[cfg_attr(
+        feature = "serialization",
+        serde(default = "CorsOptions::default_fairing_route_base")
+    )]
+    pub fairing_route_base: String,
+    /// When used as Fairing, Cors will need to redirect failed CORS checks to a custom route
+    /// mounted by the fairing. Specify the rank of the route so that it doesn't clash with any
+    /// of your existing routes. Remember that a higher ranked route has lower priority.
+    ///
+    /// Defaults to 0
+    #[cfg_attr(
+        feature = "serialization",
+        serde(default = "CorsOptions::default_fairing_route_rank")
+    )]
+    pub fairing_route_rank: isize,
+}
+
+impl Default for CorsOptions {
+    fn default() -> Self {
+        Self {
+            allowed_origins: Default::default(),
+            allowed_methods: Self::default_allowed_methods(),
+            allowed_headers: Default::default(),
+            allow_credentials: Default::default(),
+            expose_headers: Default::default(),
+            max_age: Default::default(),
+            send_wildcard: Default::default(),
+            fairing_route_base: Self::default_fairing_route_base(),
+            fairing_route_rank: Self::default_fairing_route_rank(),
+        }
+    }
+}
+
+impl CorsOptions {
+    fn default_allowed_methods() -> HashSet<Method> {
+        use rocket::http::Method;
+
+        vec![
+            Method::Get,
+            Method::Head,
+            Method::Post,
+            Method::Options,
+            Method::Put,
+            Method::Patch,
+            Method::Delete,
+        ]
+        .into_iter()
+        .map(From::from)
+        .collect()
+    }
+
+    fn default_fairing_route_base() -> String {
+        "/cors".to_string()
+    }
+
+    fn default_fairing_route_rank() -> isize {
+        0
+    }
+
+    /// Validates if any of the settings are disallowed, incorrect, or illegal
+    pub fn validate(&self) -> Result<(), Error> {
+        if self.allowed_origins.is_all() && self.send_wildcard && self.allow_credentials {
+            return Err(Error::CredentialsWithWildcardOrigin);
+        }
+
+        Ok(())
+    }
+
+    /// Creates a [`Cors`] struct that can be used to respond to requests or as a Rocket Fairing
+    pub fn to_cors(&self) -> Result<Cors, Error> {
+        Cors::from_options(self)
+    }
+}
+
+/// Response generator and [Fairing](https://rocket.rs/guide/fairings/) for CORS
+///
+/// This struct can be as Fairing or in an ad-hoc manner to generate CORS response. See the
+/// documentation at the [crate root](index.html) for usage information.
+///
+/// This struct can be created by using [`CorsOptions::to_cors`] or [`Cors::from_options`].
+#[derive(Clone, Debug)]
+pub struct Cors {
+    pub(crate) allowed_origins: AllOrSome<ParsedAllowedOrigins>,
+    pub(crate) allowed_methods: AllowedMethods,
+    pub(crate) allowed_headers: AllOrSome<HashSet<HeaderFieldName>>,
+    pub(crate) allow_credentials: bool,
+    pub(crate) expose_headers: HashSet<String>,
+    pub(crate) max_age: Option<usize>,
+    pub(crate) send_wildcard: bool,
+    pub(crate) fairing_route_base: String,
+    pub(crate) fairing_route_rank: isize,
+}
+
+impl Cors {
+    /// Create a `Cors` struct from a [`CorsOptions`]
+    pub fn from_options(options: &CorsOptions) -> Result<Self, Error> {
+        options.validate()?;
+
+        let allowed_origins = parse_allowed_origins(&options.allowed_origins)?;
+
+        Ok(Cors {
+            allowed_origins,
+            allowed_methods: options.allowed_methods.clone(),
+            allowed_headers: options.allowed_headers.clone(),
+            allow_credentials: options.allow_credentials,
+            expose_headers: options.expose_headers.clone(),
+            max_age: options.max_age,
+            send_wildcard: options.send_wildcard,
+            fairing_route_base: options.fairing_route_base.clone(),
+            fairing_route_rank: options.fairing_route_rank,
+        })
+    }
+
+    /// Manually respond to a request with CORS checks and headers using an Owned `Cors`.
+    ///
+    /// Use this variant when your `Cors` struct will not live at least as long as the whole `'r`
+    /// lifetime of the request.
+    ///
+    /// After the CORS checks are done, the passed in handler closure will be run to generate a
+    /// final response. You will have to merge your response with the `Guard` that you have been
+    /// passed in to include the CORS headers.
+    ///
+    /// See the documentation at the [crate root](index.html) for usage information.
+    pub fn respond_owned<'r, F, R>(self, handler: F) -> Result<ManualResponder<'r, F, R>, Error>
+    where
+        F: FnOnce(Guard<'r>) -> R + 'r,
+        R: response::Responder<'r>,
+    {
+        Ok(ManualResponder::new(Cow::Owned(self), handler))
+    }
+
+    /// Manually respond to a request with CORS checks and headers using a borrowed `Cors`.
+    ///
+    /// Use this variant when your `Cors` struct will live at least as long as the whole `'r`
+    /// lifetime of the request. If you are getting your `Cors` from Rocket's state, you will have
+    /// to use the [`inner` function](https://api.rocket.rs/rocket/struct.State.html#method.inner)
+    /// to get a longer borrowed lifetime.
+    ///
+    /// After the CORS checks are done, the passed in handler closure will be run to generate a
+    /// final response. You will have to merge your response with the `Guard` that you have been
+    /// passed in to include the CORS headers.
+    ///
+    /// See the documentation at the [crate root](index.html) for usage information.
+    pub fn respond_borrowed<'r, F, R>(
+        &'r self,
+        handler: F,
+    ) -> Result<ManualResponder<'r, F, R>, Error>
+    where
+        F: FnOnce(Guard<'r>) -> R + 'r,
+        R: response::Responder<'r>,
+    {
+        Ok(ManualResponder::new(Cow::Borrowed(self), handler))
+    }
+}
+
+/// A CORS Response which provides the following CORS headers:
+///
+/// - `Access-Control-Allow-Origin`
+/// - `Access-Control-Expose-Headers`
+/// - `Access-Control-Max-Age`
+/// - `Access-Control-Allow-Credentials`
+/// - `Access-Control-Allow-Methods`
+/// - `Access-Control-Allow-Headers`
+///
+/// The following headers will be merged:
+/// - `Vary`
+///
+/// You can get this struct by using `Cors::validate_request` in an ad-hoc manner.
+#[derive(Eq, PartialEq, Debug)]
+pub(crate) struct Response {
+    allow_origin: Option<AllOrSome<String>>,
+    allow_methods: HashSet<Method>,
+    allow_headers: HeaderFieldNamesSet,
+    allow_credentials: bool,
+    expose_headers: HeaderFieldNamesSet,
+    max_age: Option<usize>,
+    vary_origin: bool,
+}
+
+impl Response {
+    /// Create an empty `Response`
+    fn new() -> Self {
+        Self {
+            allow_origin: None,
+            allow_headers: HashSet::new(),
+            allow_methods: HashSet::new(),
+            allow_credentials: false,
+            expose_headers: HashSet::new(),
+            max_age: None,
+            vary_origin: false,
+        }
+    }
+
+    /// Consumes the `Response` and return an altered response with origin and `vary_origin` set
+    fn origin(mut self, origin: &str, vary_origin: bool) -> Self {
+        self.allow_origin = Some(AllOrSome::Some(origin.to_string()));
+        self.vary_origin = vary_origin;
+        self
+    }
+
+    /// Consumes the `Response` and return an altered response with origin set to "*"
+    fn any(mut self) -> Self {
+        self.allow_origin = Some(AllOrSome::All);
+        self
+    }
+
+    /// Consumes the Response and set credentials
+    fn credentials(mut self, value: bool) -> Self {
+        self.allow_credentials = value;
+        self
+    }
+
+    /// Consumes the CORS, set expose_headers to
+    /// passed headers and returns changed CORS
+    fn exposed_headers(mut self, headers: &[&str]) -> Self {
+        self.expose_headers = headers.iter().map(|s| (*s).to_string().into()).collect();
+        self
+    }
+
+    /// Consumes the CORS, set max_age to
+    /// passed value and returns changed CORS
+    fn max_age(mut self, value: Option<usize>) -> Self {
+        self.max_age = value;
+        self
+    }
+
+    /// Consumes the CORS, set allow_methods to
+    /// passed methods and returns changed CORS
+    fn methods(mut self, methods: &HashSet<Method>) -> Self {
+        self.allow_methods = methods.clone();
+        self
+    }
+
+    /// Consumes the CORS, set allow_headers to
+    /// passed headers and returns changed CORS
+    fn headers(mut self, headers: &[&str]) -> Self {
+        self.allow_headers = headers.iter().map(|s| (*s).to_string().into()).collect();
+        self
+    }
+
+    /// Consumes the `Response` and return  a `Responder` that wraps a
+    /// provided `rocket:response::Responder` with CORS headers
+    pub fn responder<'r, R: response::Responder<'r>>(self, responder: R) -> Responder<'r, R> {
+        Responder::new(responder, self)
+    }
+
+    /// Merge a `rocket::Response` with this CORS response. This is usually used in the final step
+    /// of a route to return a value for the route.
+    ///
+    /// This will overwrite any existing CORS headers
+    pub fn response<'r>(&self, base: response::Response<'r>) -> response::Response<'r> {
+        let mut response = response::Response::build_from(base).finalize();
+        self.merge(&mut response);
+        response
+    }
+
+    /// Merge CORS headers with an existing `rocket::Response`.
+    ///
+    /// This will overwrite any existing CORS headers
+    fn merge(&self, response: &mut response::Response<'_>) {
+        // TODO: We should be able to remove this
+        let origin = match self.allow_origin {
+            None => {
+                // This is not a CORS response
+                return;
+            }
+            Some(ref origin) => origin,
+        };
+
+        let origin = match *origin {
+            AllOrSome::All => "*".to_string(),
+            AllOrSome::Some(ref origin) => origin.to_string(),
+        };
+
+        let _ = response.set_raw_header("Access-Control-Allow-Origin", origin);
+
+        if self.allow_credentials {
+            let _ = response.set_raw_header("Access-Control-Allow-Credentials", "true");
+        } else {
+            response.remove_header("Access-Control-Allow-Credentials");
+        }
+
+        if !self.expose_headers.is_empty() {
+            let headers: Vec<String> = self
+                .expose_headers
+                .iter()
+                .map(|s| s.deref().to_string())
+                .collect();
+            let headers = headers.join(", ");
+
+            let _ = response.set_raw_header("Access-Control-Expose-Headers", headers);
+        } else {
+            response.remove_header("Access-Control-Expose-Headers");
+        }
+
+        if !self.allow_headers.is_empty() {
+            let headers: Vec<String> = self
+                .allow_headers
+                .iter()
+                .map(|s| s.deref().to_string())
+                .collect();
+            let headers = headers.join(", ");
+
+            let _ = response.set_raw_header("Access-Control-Allow-Headers", headers);
+        } else {
+            response.remove_header("Access-Control-Allow-Headers");
+        }
+
+        if !self.allow_methods.is_empty() {
+            let methods: Vec<_> = self.allow_methods.iter().map(|m| m.as_str()).collect();
+            let methods = methods.join(", ");
+
+            let _ = response.set_raw_header("Access-Control-Allow-Methods", methods);
+        } else {
+            response.remove_header("Access-Control-Allow-Methods");
+        }
+
+        if self.max_age.is_some() {
+            let max_age = self.max_age.unwrap();
+            let _ = response.set_raw_header("Access-Control-Max-Age", max_age.to_string());
+        } else {
+            response.remove_header("Access-Control-Max-Age");
+        }
+
+        if self.vary_origin {
+            response.adjoin_raw_header("Vary", "Origin");
+        }
+    }
+
+    /// Validate and create a new CORS Response from a request and settings
+    pub fn validate_and_build<'a, 'r>(
+        options: &'a Cors,
+        request: &'a Request<'r>,
+    ) -> Result<Self, Error> {
+        validate_and_build(options, request)
+    }
+}
+
+/// A [request guard](https://rocket.rs/guide/requests/#request-guards) to check CORS headers
+/// before a route is run. Will not execute the route if checks fail.
+///
+/// See the documentation at the [crate root](index.html) for usage information.
+///
+/// You should not wrap this in an
+/// `Option` or `Result` because the guard will let non-CORS requests through and will take over
+/// error handling in case of errors.
+/// In essence, this is just a wrapper around `Response` with a `'r` borrowed lifetime so users
+/// don't have to keep specifying the lifetimes in their routes
+pub struct Guard<'r> {
+    response: Response,
+    marker: PhantomData<&'r Response>,
+}
+
+impl<'r> Guard<'r> {
+    fn new(response: Response) -> Self {
+        Self {
+            response,
+            marker: PhantomData,
+        }
+    }
+
+    /// Consumes the Guard and return  a `Responder` that wraps a
+    /// provided `rocket:response::Responder` with CORS headers
+    pub fn responder<R: response::Responder<'r>>(self, responder: R) -> Responder<'r, R> {
+        self.response.responder(responder)
+    }
+
+    /// Merge a `rocket::Response` with this CORS Guard. This is usually used in the final step
+    /// of a route to return a value for the route.
+    ///
+    /// This will overwrite any existing CORS headers
+    pub fn response(&self, base: response::Response<'r>) -> response::Response<'r> {
+        self.response.response(base)
+    }
+}
+
+impl<'a, 'r> FromRequest<'a, 'r> for Guard<'r> {
+    type Error = Error;
+
+    fn from_request(request: &'a Request<'r>) -> rocket::request::Outcome<Self, Self::Error> {
+        let options = match request.guard::<State<'_, Cors>>() {
+            Outcome::Success(options) => options,
+            _ => {
+                let error = Error::MissingCorsInRocketState;
+                return Outcome::Failure((error.status(), error));
+            }
+        };
+
+        match Response::validate_and_build(&options, request) {
+            Ok(response) => Outcome::Success(Self::new(response)),
+            Err(error) => Outcome::Failure((error.status(), error)),
+        }
+    }
+}
+
+/// A [`Responder`](https://rocket.rs/guide/responses/#responder) which will simply wraps another
+/// `Responder` with CORS headers.
+///
+/// The following CORS headers will be overwritten:
+///
+/// - `Access-Control-Allow-Origin`
+/// - `Access-Control-Expose-Headers`
+/// - `Access-Control-Max-Age`
+/// - `Access-Control-Allow-Credentials`
+/// - `Access-Control-Allow-Methods`
+/// - `Access-Control-Allow-Headers`
+///
+/// The following headers will be merged:
+/// - `Vary`
+///
+/// See the documentation at the [crate root](index.html) for usage information.
+#[derive(Debug)]
+pub struct Responder<'r, R> {
+    responder: R,
+    cors_response: Response,
+    marker: PhantomData<dyn response::Responder<'r>>,
+}
+
+impl<'r, R: response::Responder<'r>> Responder<'r, R> {
+    fn new(responder: R, cors_response: Response) -> Self {
+        Self {
+            responder,
+            cors_response,
+            marker: PhantomData,
+        }
+    }
+
+    /// Respond to a request
+    fn respond(self, request: &Request<'_>) -> response::Result<'r> {
+        let mut response = self.responder.respond_to(request)?; // handle status errors?
+        self.cors_response.merge(&mut response);
+        Ok(response)
+    }
+}
+
+impl<'r, R: response::Responder<'r>> response::Responder<'r> for Responder<'r, R> {
+    fn respond_to(self, request: &Request<'_>) -> response::Result<'r> {
+        self.respond(request)
+    }
+}
+
+/// A Manual Responder used in the "truly manual" mode of operation.
+///
+/// See the documentation at the [crate root](index.html) for usage information.
+pub struct ManualResponder<'r, F, R> {
+    options: Cow<'r, Cors>,
+    handler: F,
+    marker: PhantomData<R>,
+}
+
+impl<'r, F, R> ManualResponder<'r, F, R>
+where
+    F: FnOnce(Guard<'r>) -> R + 'r,
+    R: response::Responder<'r>,
+{
+    /// Create a new manual responder by passing in either a borrowed or owned `Cors` option.
+    ///
+    /// A borrowed `Cors` option must live for the entirety of the `'r` lifetime which is the
+    /// lifetime of the entire Rocket request.
+    fn new(options: Cow<'r, Cors>, handler: F) -> Self {
+        let marker = PhantomData;
+        Self {
+            options,
+            handler,
+            marker,
+        }
+    }
+
+    fn build_guard(&self, request: &Request<'_>) -> Result<Guard<'r>, Error> {
+        let response = Response::validate_and_build(&self.options, request)?;
+        Ok(Guard::new(response))
+    }
+}
+
+impl<'r, F, R> response::Responder<'r> for ManualResponder<'r, F, R>
+where
+    F: FnOnce(Guard<'r>) -> R + 'r,
+    R: response::Responder<'r>,
+{
+    fn respond_to(self, request: &Request<'_>) -> response::Result<'r> {
+        let guard = match self.build_guard(request) {
+            Ok(guard) => guard,
+            Err(err) => {
+                error_!("CORS error: {}", err);
+                return Err(err.status());
+            }
+        };
+        (self.handler)(guard).respond_to(request)
+    }
+}
+
+/// Result of CORS validation.
+///
+/// The variants hold enough information to build a response to the validation result
+#[derive(Debug, Eq, PartialEq)]
+#[allow(variant_size_differences)]
+enum ValidationResult {
+    /// Not a CORS request
+    None,
+    /// Successful preflight request
+    Preflight {
+        origin: String,
+        headers: Option<AccessControlRequestHeaders>,
+    },
+    /// Successful actual request
+    Request { origin: String },
+}
+
+/// Convert a str to a URL Origin
+fn to_origin<S: AsRef<str>>(origin: S) -> Result<url::Origin, Error> {
+    Ok(url::Url::parse(origin.as_ref())?.origin())
+}
+
+/// Parse and process allowed origins
+fn parse_allowed_origins(
+    origins: &AllowedOrigins,
+) -> Result<AllOrSome<ParsedAllowedOrigins>, Error> {
+    match origins {
+        AllOrSome::All => Ok(AllOrSome::All),
+        AllOrSome::Some(origins) => {
+            let parsed = ParsedAllowedOrigins::parse(origins)?;
+            Ok(AllOrSome::Some(parsed))
+        }
+    }
+}
+
+/// Validates a request for CORS and returns a CORS Response
+fn validate_and_build(options: &Cors, request: &Request<'_>) -> Result<Response, Error> {
+    let result = validate(options, request)?;
+
+    Ok(match result {
+        ValidationResult::None => Response::new(),
+        ValidationResult::Preflight { origin, headers } => {
+            preflight_response(options, &origin, headers.as_ref())
+        }
+        ValidationResult::Request { origin } => actual_request_response(options, &origin),
+    })
+}
+
+/// Validate a CORS request
+fn validate(options: &Cors, request: &Request<'_>) -> Result<ValidationResult, Error> {
+    // 1. If the Origin header is not present terminate this set of steps.
+    // The request is outside the scope of this specification.
+    let origin = origin(request)?;
+    let origin = match origin {
+        None => {
+            // Not a CORS request
+            return Ok(ValidationResult::None);
+        }
+        Some(origin) => origin,
+    };
+
+    // Check if the request verb is an OPTION or something else
+    match request.method() {
+        http::Method::Options => {
+            let method = request_method(request)?;
+            let headers = request_headers(request)?;
+            preflight_validate(options, &origin, &method, &headers)?;
+            Ok(ValidationResult::Preflight {
+                origin: origin.to_string(),
+                headers,
+            })
+        }
+        _ => {
+            actual_request_validate(options, &origin)?;
+            Ok(ValidationResult::Request {
+                origin: origin.to_string(),
+            })
+        }
+    }
+}
+
+/// Consumes the responder and based on the provided list of allowed origins,
+/// check if the requested origin is allowed.
+/// Useful for pre-flight and during requests
+fn validate_origin(
+    origin: &Origin,
+    allowed_origins: &AllOrSome<ParsedAllowedOrigins>,
+) -> Result<(), Error> {
+    match *allowed_origins {
+        // Always matching is acceptable since the list of origins can be unbounded.
+        AllOrSome::All => Ok(()),
+        AllOrSome::Some(ref allowed_origins) => {
+            if allowed_origins.verify(origin) {
+                Ok(())
+            } else {
+                Err(Error::OriginNotAllowed(origin.to_string()))
+            }
+        }
+    }
+}
+
+/// Validate allowed methods
+fn validate_allowed_method(
+    method: &AccessControlRequestMethod,
+    allowed_methods: &AllowedMethods,
+) -> Result<(), Error> {
+    let &AccessControlRequestMethod(ref request_method) = method;
+    if !allowed_methods.iter().any(|m| m == request_method) {
+        return Err(Error::MethodNotAllowed(method.0.to_string()));
+    }
+
+    // TODO: Subset to route? Or just the method requested for?
+    Ok(())
+}
+
+/// Validate allowed headers
+fn validate_allowed_headers(
+    headers: &AccessControlRequestHeaders,
+    allowed_headers: &AllowedHeaders,
+) -> Result<(), Error> {
+    let &AccessControlRequestHeaders(ref headers) = headers;
+
+    match *allowed_headers {
+        AllOrSome::All => Ok(()),
+        AllOrSome::Some(ref allowed_headers) => {
+            if !headers.is_empty() && !headers.is_subset(allowed_headers) {
+                return Err(Error::HeadersNotAllowed);
+            }
+            Ok(())
+        }
+    }
+}
+
+/// Gets the `Origin` request header from the request
+fn origin(request: &Request<'_>) -> Result<Option<Origin>, Error> {
+    match Origin::from_request(request) {
+        Outcome::Forward(()) => Ok(None),
+        Outcome::Success(origin) => Ok(Some(origin)),
+        Outcome::Failure((_, err)) => Err(err),
+    }
+}
+
+/// Gets the `Access-Control-Request-Method` request header from the request
+fn request_method(request: &Request<'_>) -> Result<Option<AccessControlRequestMethod>, Error> {
+    match AccessControlRequestMethod::from_request(request) {
+        Outcome::Forward(()) => Ok(None),
+        Outcome::Success(method) => Ok(Some(method)),
+        Outcome::Failure((_, err)) => Err(err),
+    }
+}
+
+/// Gets the `Access-Control-Request-Headers` request header from the request
+fn request_headers(request: &Request<'_>) -> Result<Option<AccessControlRequestHeaders>, Error> {
+    match AccessControlRequestHeaders::from_request(request) {
+        Outcome::Forward(()) => Ok(None),
+        Outcome::Success(geaders) => Ok(Some(geaders)),
+        Outcome::Failure((_, err)) => Err(err),
+    }
+}
+
+/// Do pre-flight validation checks
+///
+/// This implementation references the
+/// [W3C recommendation](https://www.w3.org/TR/cors/#resource-preflight-requests)
+/// and [Fetch specification](https://fetch.spec.whatwg.org/#cors-preflight-fetch)
+fn preflight_validate(
+    options: &Cors,
+    origin: &Origin,
+    method: &Option<AccessControlRequestMethod>,
+    headers: &Option<AccessControlRequestHeaders>,
+) -> Result<(), Error> {
+    // Note: All header parse failures are dealt with in the `FromRequest` trait implementation
+
+    // 2. If the value of the Origin header is not a case-sensitive match for any of the values
+    // in list of origins do not set any additional headers and terminate this set of steps.
+    validate_origin(origin, &options.allowed_origins)?;
+
+    // 3. Let `method` be the value as result of parsing the Access-Control-Request-Method
+    // header.
+    // If there is no Access-Control-Request-Method header or if parsing failed,
+    // do not set any additional headers and terminate this set of steps.
+    // The request is outside the scope of this specification.
+
+    let method = method.as_ref().ok_or_else(|| Error::MissingRequestMethod)?;
+
+    // 4. Let header field-names be the values as result of parsing the
+    // Access-Control-Request-Headers headers.
+    // If there are no Access-Control-Request-Headers headers
+    // let header field-names be the empty list.
+    // If parsing failed do not set any additional headers and terminate this set of steps.
+    // The request is outside the scope of this specification.
+
+    // 5. If method is not a case-sensitive match for any of the values in list of methods
+    // do not set any additional headers and terminate this set of steps.
+
+    validate_allowed_method(method, &options.allowed_methods)?;
+
+    // 6. If any of the header field-names is not a ASCII case-insensitive match for any of the
+    // values in list of headers do not set any additional headers and terminate this set of
+    // steps.
+
+    if let Some(ref headers) = *headers {
+        validate_allowed_headers(headers, &options.allowed_headers)?;
+    }
+
+    Ok(())
+}
+
+/// Build a response for pre-flight checks
+///
+/// This implementation references the
+/// [W3C recommendation](https://www.w3.org/TR/cors/#resource-preflight-requests)
+/// and [Fetch specification](https://fetch.spec.whatwg.org/#cors-preflight-fetch).
+fn preflight_response(
+    options: &Cors,
+    origin: &str,
+    headers: Option<&AccessControlRequestHeaders>,
+) -> Response {
+    let response = Response::new();
+
+    // 7. If the resource supports credentials add a single Access-Control-Allow-Origin header,
+    // with the value of the Origin header as value, and add a
+    // single Access-Control-Allow-Credentials header with the case-sensitive string "true" as
+    // value.
+    // Otherwise, add a single Access-Control-Allow-Origin header,
+    // with either the value of the Origin header or the string "*" as value.
+    // Note: The string "*" cannot be used for a resource that supports credentials.
+
+    // Validation has been done in options.validate
+    let response = match options.allowed_origins {
+        AllOrSome::All => {
+            if options.send_wildcard {
+                response.any()
+            } else {
+                response.origin(origin, true)
+            }
+        }
+        AllOrSome::Some(_) => response.origin(origin, false),
+    };
+    let response = response.credentials(options.allow_credentials);
+
+    // 8. Optionally add a single Access-Control-Max-Age header
+    // with as value the amount of seconds the user agent is allowed to cache the result of the
+    // request.
+    let response = response.max_age(options.max_age);
+
+    // 9. If method is a simple method this step may be skipped.
+    // Add one or more Access-Control-Allow-Methods headers consisting of
+    // (a subset of) the list of methods.
+    // If a method is a simple method it does not need to be listed, but this is not prohibited.
+    // Since the list of methods can be unbounded,
+    // simply returning the method indicated by Access-Control-Request-Method
+    // (if supported) can be enough.
+
+    let response = response.methods(&options.allowed_methods);
+
+    // 10. If each of the header field-names is a simple header and none is Content-Type,
+    // this step may be skipped.
+    // Add one or more Access-Control-Allow-Headers headers consisting of (a subset of)
+    // the list of headers.
+    // If a header field name is a simple header and is not Content-Type,
+    // it is not required to be listed. Content-Type is to be listed as only a
+    // subset of its values makes it qualify as simple header.
+    // Since the list of headers can be unbounded, simply returning supported headers
+    // from Access-Control-Allow-Headers can be enough.
+
+    // We do not do anything special with simple headers
+    if let Some(headers) = headers {
+        let &AccessControlRequestHeaders(ref headers) = headers;
+        response.headers(
+            headers
+                .iter()
+                .map(|s| &**s.deref())
+                .collect::<Vec<&str>>()
+                .as_slice(),
+        )
+    } else {
+        response
+    }
+}
+
+/// Do checks for an actual request
+///
+/// This implementation references the
+/// [W3C recommendation](https://www.w3.org/TR/cors/#resource-requests)
+/// and [Fetch specification](https://fetch.spec.whatwg.org/#cors-preflight-fetch).
+fn actual_request_validate(options: &Cors, origin: &Origin) -> Result<(), Error> {
+    // Note: All header parse failures are dealt with in the `FromRequest` trait implementation
+
+    // 2. If the value of the Origin header is not a case-sensitive match for any of the values
+    // in list of origins, do not set any additional headers and terminate this set of steps.
+    // Always matching is acceptable since the list of origins can be unbounded.
+
+    validate_origin(origin, &options.allowed_origins)?;
+
+    Ok(())
+}
+
+/// Build the response for an actual request
+///
+/// This implementation references the
+/// [W3C recommendation](https://www.w3.org/TR/cors/#resource-requests)
+/// and [Fetch specification](https://fetch.spec.whatwg.org/#cors-preflight-fetch)
+fn actual_request_response(options: &Cors, origin: &str) -> Response {
+    let response = Response::new();
+
+    // 3. If the resource supports credentials add a single Access-Control-Allow-Origin header,
+    // with the value of the Origin header as value, and add a
+    // single Access-Control-Allow-Credentials header with the case-sensitive string "true" as
+    // value.
+    // Otherwise, add a single Access-Control-Allow-Origin header,
+    // with either the value of the Origin header or the string "*" as value.
+    // Note: The string "*" cannot be used for a resource that supports credentials.
+
+    // Validation has been done in options.validate
+
+    let response = match options.allowed_origins {
+        AllOrSome::All => {
+            if options.send_wildcard {
+                response.any()
+            } else {
+                response.origin(origin, true)
+            }
+        }
+        AllOrSome::Some(_) => response.origin(origin, false),
+    };
+
+    let response = response.credentials(options.allow_credentials);
+
+    // 4. If the list of exposed headers is not empty add one or more
+    // Access-Control-Expose-Headers headers, with as values the header field names given in
+    // the list of exposed headers.
+    // By not adding the appropriate headers resource can also clear the preflight result cache
+    // of all entries where origin is a case-sensitive match for the value of the Origin header
+    // and url is a case-sensitive match for the URL of the resource.
+
+    response.exposed_headers(
+        options
+            .expose_headers
+            .iter()
+            .map(|s| &**s)
+            .collect::<Vec<&str>>()
+            .as_slice(),
+    )
+}
+
+/// Returns "catch all" OPTIONS routes that you can mount to catch all OPTIONS request. Only works
+/// if you have put a `Cors` struct into Rocket's managed state.
+///
+/// This route has very high rank (and therefore low priority) of
+/// [max value](https://doc.rust-lang.org/nightly/std/primitive.isize.html#method.max_value)
+/// so you can define your own to override this route's behaviour.
+///
+/// See the documentation at the [crate root](index.html) for usage information.
+pub fn catch_all_options_routes() -> Vec<rocket::Route> {
+    vec![
+        rocket::Route::ranked(
+            isize::max_value(),
+            http::Method::Options,
+            "/",
+            catch_all_options_route_handler,
+        ),
+        rocket::Route::ranked(
+            isize::max_value(),
+            http::Method::Options,
+            "/<catch_all_options_route..>",
+            catch_all_options_route_handler,
+        ),
+    ]
+}
+
+/// Handler for the "catch all options route"
+fn catch_all_options_route_handler<'r>(
+    request: &'r Request<'_>,
+    _: rocket::Data,
+) -> rocket::handler::Outcome<'r> {
+    let guard: Guard<'_> = match request.guard() {
+        Outcome::Success(guard) => guard,
+        Outcome::Failure((status, _)) => return rocket::handler::Outcome::failure(status),
+        Outcome::Forward(()) => unreachable!("Should not be reachable"),
+    };
+
+    info_!(
+        "\"Catch all\" handling of CORS `OPTIONS` preflight for request {}",
+        request
+    );
+
+    rocket::handler::Outcome::from(request, guard.responder(()))
+}
+
+#[cfg(test)]
+mod tests {
+    use std::str::FromStr;
+
+    use rocket::http::Header;
+    use rocket::local::Client;
+    #[cfg(feature = "serialization")]
+    use serde_json;
+
+    use super::*;
+    use crate::http::Method;
+
+    fn to_parsed_origin<S: AsRef<str>>(origin: S) -> Result<Origin, Error> {
+        Origin::from_str(origin.as_ref())
+    }
+
+    fn make_cors_options() -> CorsOptions {
+        let allowed_origins = AllowedOrigins::some_exact(&["https://www.acme.com"]);
+
+        CorsOptions {
+            allowed_origins,
+            allowed_methods: vec![http::Method::Get]
+                .into_iter()
+                .map(From::from)
+                .collect(),
+            allowed_headers: AllowedHeaders::some(&[&"Authorization", "Accept"]),
+            allow_credentials: true,
+            expose_headers: ["Content-Type", "X-Custom"]
+                .iter()
+                .map(|s| (*s).to_string())
+                .collect(),
+            ..Default::default()
+        }
+    }
+
+    fn make_invalid_options() -> CorsOptions {
+        let mut cors = make_cors_options();
+        cors.allow_credentials = true;
+        cors.allowed_origins = AllOrSome::All;
+        cors.send_wildcard = true;
+        cors
+    }
+
+    /// Make a client with no routes for unit testing
+    fn make_client() -> Client {
+        let rocket = rocket::ignite();
+        Client::new(rocket).expect("valid rocket instance")
+    }
+
+    // CORS options test
+
+    #[test]
+    fn cors_is_validated() {
+        assert!(make_cors_options().validate().is_ok())
+    }
+
+    #[test]
+    #[should_panic(expected = "CredentialsWithWildcardOrigin")]
+    fn cors_validates_illegal_allow_credentials() {
+        let cors = make_invalid_options();
+
+        cors.validate().unwrap();
+    }
+
+    /// Check that the the default deserialization matches the one returned by `Default::default`
+    #[cfg(feature = "serialization")]
+    #[test]
+    fn cors_default_deserialization_is_correct() {
+        let deserialized: CorsOptions = serde_json::from_str("{}").expect("To not fail");
+        assert_eq!(deserialized, CorsOptions::default());
+
+        let expected_json = r#"
+{
+  "allowed_origins": "All",
+  "allowed_methods": [
+    "POST",
+    "PATCH",
+    "PUT",
+    "DELETE",
+    "HEAD",
+    "OPTIONS",
+    "GET"
+  ],
+  "allowed_headers": "All",
+  "allow_credentials": false,
+  "expose_headers": [],
+  "max_age": null,
+  "send_wildcard": false,
+  "fairing_route_base": "/cors",
+  "fairing_route_rank": 0
+}
+"#;
+        let actual: CorsOptions = serde_json::from_str(expected_json).expect("to not fail");
+        assert_eq!(actual, CorsOptions::default());
+    }
+
+    /// Checks that the example provided can actually be deserialized
+    #[cfg(feature = "serialization")]
+    #[test]
+    fn cors_options_example_can_be_deserialized() {
+        let json = r#"{
+  "allowed_origins": {
+    "Some": {
+        "exact": ["https://www.acme.com"],
+        "regex": ["^https://www.example-[A-z0-9]*.com$"]
+    }
+  },
+  "allowed_methods": [
+    "POST",
+    "DELETE",
+    "GET"
+  ],
+  "allowed_headers": {
+    "Some": [
+      "Accept",
+      "Authorization"
+    ]
+  },
+  "allow_credentials": true,
+  "expose_headers": [
+    "Content-Type",
+    "X-Custom"
+  ],
+  "max_age": 42,
+  "send_wildcard": false,
+  "fairing_route_base": "/mycors"
+}"#;
+        let _: CorsOptions = serde_json::from_str(json).expect("to not fail");
+    }
+
+    #[test]
+    fn allowed_some_origins_allows_different_lifetimes() {
+        let static_exact = ["http://www.example.com"];
+
+        let random_allocation = vec![1, 2, 3];
+        let port: *const Vec<i32> = &random_allocation;
+        let port = port as u16;
+
+        let random_regex = vec![format!("https://(.+):{}", port)];
+
+        // Should compile
+        let _ = AllowedOrigins::some(&static_exact, &random_regex);
+    }
+
+    // `ParsedAllowedOrigins::parse` tests
+    #[test]
+    fn allowed_origins_are_parsed_correctly() {
+        let allowed_origins = not_err!(parse_allowed_origins(&AllowedOrigins::some(
+            &["https://www.acme.com"],
+            &["^https://www.example-[A-z0-9]+.com$"]
+        )));
+        assert!(allowed_origins.is_some());
+
+        let expected_exact: HashSet<url::Origin> = [url::Url::from_str("https://www.acme.com")
+            .expect("not to fail")
+            .origin()]
+        .iter()
+        .map(Clone::clone)
+        .collect();
+        let expected_regex = ["^https://www.example-[A-z0-9]+.com$"];
+
+        let actual = allowed_origins.unwrap();
+        assert_eq!(expected_exact, actual.exact);
+        assert_eq!(expected_regex, actual.regex.expect("to be some").patterns());
+    }
+
+    #[test]
+    fn allowed_origins_errors_on_opaque_exact() {
+        let error = parse_allowed_origins(&AllowedOrigins::some::<_, &str>(
+            &[
+                "chrome-extension://something",
+                "moz-extension://something",
+                "https://valid.com",
+            ],
+            &[],
+        ))
+        .unwrap_err();
+
+        match error {
+            Error::OpaqueAllowedOrigin(mut origins) => {
+                origins.sort();
+                assert_eq!(
+                    origins,
+                    ["chrome-extension://something", "moz-extension://something"]
+                );
+            }
+            others => {
+                panic!("Unexpected error: {:#?}", others);
+            }
+        };
+    }
+
+    // The following tests check validation
+
+    #[test]
+    fn validate_origin_allows_all_origins() {
+        let url = "https://www.example.com";
+        let origin = not_err!(to_parsed_origin(&url));
+        let allowed_origins = AllOrSome::All;
+
+        not_err!(validate_origin(&origin, &allowed_origins));
+    }
+
+    #[test]
+    fn validate_origin_allows_origin() {
+        let url = "https://www.example.com";
+        let origin = not_err!(to_parsed_origin(&url));
+        let allowed_origins = not_err!(parse_allowed_origins(&AllowedOrigins::some_exact(&[
+            "https://www.example.com"
+        ])));
+
+        not_err!(validate_origin(&origin, &allowed_origins));
+    }
+
+    #[test]
+    fn validate_origin_handles_punycode_properly() {
+        // Test a variety of scenarios where the Origin and settings are in punycode, or not
+        let cases = vec![
+            ("https://аpple.com", "https://аpple.com"),
+            ("https://аpple.com", "https://xn--pple-43d.com"),
+            ("https://xn--pple-43d.com", "https://аpple.com"),
+            ("https://xn--pple-43d.com", "https://xn--pple-43d.com"),
+        ];
+
+        for (url, allowed_origin) in cases {
+            let origin = not_err!(to_parsed_origin(&url));
+            let allowed_origins = not_err!(parse_allowed_origins(&AllowedOrigins::some_exact(&[
+                allowed_origin
+            ])));
+
+            not_err!(validate_origin(&origin, &allowed_origins));
+        }
+    }
+
+    #[test]
+    fn validate_origin_validates_regex() {
+        let allowed_origins = not_err!(parse_allowed_origins(&AllowedOrigins::some_regex(&[
+            "^https://www.example-[A-z0-9]+.com$",
+            "^https://(.+).acme.com$",
+        ])));
+
+        let url = "https://www.example-something.com";
+        let origin = not_err!(to_parsed_origin(&url));
+        not_err!(validate_origin(&origin, &allowed_origins));
+
+        let url = "https://subdomain.acme.com";
+        let origin = not_err!(to_parsed_origin(&url));
+        not_err!(validate_origin(&origin, &allowed_origins));
+    }
+
+    #[test]
+    fn validate_origin_validates_opaque_origins() {
+        let url = "moz-extension://8c7c4444-e29f-…cb8-1ade813dbd12/js/content.js:505";
+        let origin = not_err!(to_parsed_origin(&url));
+        let allowed_origins = not_err!(parse_allowed_origins(&AllowedOrigins::some_regex(&[
+            "moz-extension://.*"
+        ])));
+
+        not_err!(validate_origin(&origin, &allowed_origins));
+    }
+
+    #[test]
+    fn validate_origin_validates_mixed_settings() {
+        let allowed_origins = not_err!(parse_allowed_origins(&AllowedOrigins::some(
+            &["https://www.acme.com"],
+            &["^https://www.example-[A-z0-9]+.com$"]
+        )));
+
+        let url = "https://www.example-something123.com";
+        let origin = not_err!(to_parsed_origin(&url));
+        not_err!(validate_origin(&origin, &allowed_origins));
+
+        let url = "https://www.acme.com";
+        let origin = not_err!(to_parsed_origin(&url));
+        not_err!(validate_origin(&origin, &allowed_origins));
+    }
+
+    #[test]
+    #[should_panic(expected = "OriginNotAllowed")]
+    fn validate_origin_rejects_invalid_origin() {
+        let url = "https://www.acme.com";
+        let origin = not_err!(to_parsed_origin(&url));
+        let allowed_origins = not_err!(parse_allowed_origins(&AllowedOrigins::some_exact(&[
+            "https://www.example.com"
+        ])));
+
+        validate_origin(&origin, &allowed_origins).unwrap();
+    }
+
+    #[test]
+    fn response_sets_allow_origin_without_vary_correctly() {
+        let response = Response::new();
+        let response = response.origin("https://www.example.com", false);
+
+        // Build response and check built response header
+        let expected_header = vec!["https://www.example.com"];
+        let response = response.response(response::Response::new());
+        let actual_header: Vec<_> = response
+            .headers()
+            .get("Access-Control-Allow-Origin")
+            .collect();
+        assert_eq!(expected_header, actual_header);
+
+        assert!(response.headers().get("Vary").next().is_none());
+    }
+
+    #[test]
+    fn response_sets_allow_origin_with_vary_correctly() {
+        let response = Response::new();
+        let response = response.origin("https://www.example.com", true);
+
+        // Build response and check built response header
+        let expected_header = vec!["https://www.example.com"];
+        let response = response.response(response::Response::new());
+        let actual_header: Vec<_> = response
+            .headers()
+            .get("Access-Control-Allow-Origin")
+            .collect();
+        assert_eq!(expected_header, actual_header);
+    }
+
+    #[test]
+    fn response_sets_any_origin_correctly() {
+        let response = Response::new();
+        let response = response.any();
+
+        // Build response and check built response header
+        let expected_header = vec!["*"];
+        let response = response.response(response::Response::new());
+        let actual_header: Vec<_> = response
+            .headers()
+            .get("Access-Control-Allow-Origin")
+            .collect();
+        assert_eq!(expected_header, actual_header);
+    }
+
+    #[test]
+    fn response_sets_exposed_headers_correctly() {
+        let headers = vec!["Bar", "Baz", "Foo"];
+        let response = Response::new();
+        let response = response.origin("https://www.example.com", false);
+        let response = response.exposed_headers(&headers);
+
+        // Build response and check built response header
+        let response = response.response(response::Response::new());
+        let actual_header: Vec<_> = response
+            .headers()
+            .get("Access-Control-Expose-Headers")
+            .collect();
+
+        assert_eq!(1, actual_header.len());
+        let mut actual_headers: Vec<String> = actual_header[0]
+            .split(',')
+            .map(|header| header.trim().to_string())
+            .collect();
+        actual_headers.sort();
+        assert_eq!(headers, actual_headers);
+    }
+
+    #[test]
+    fn response_sets_max_age_correctly() {
+        let response = Response::new();
+        let response = response.origin("https://www.example.com", false);
+
+        let response = response.max_age(Some(42));
+
+        // Build response and check built response header
+        let expected_header = vec!["42"];
+        let response = response.response(response::Response::new());
+        let actual_header: Vec<_> = response.headers().get("Access-Control-Max-Age").collect();
+        assert_eq!(expected_header, actual_header);
+    }
+
+    #[test]
+    fn response_does_not_set_max_age_when_none() {
+        let response = Response::new();
+        let response = response.origin("https://www.example.com", false);
+
+        let response = response.max_age(None);
+
+        // Build response and check built response header
+        let response = response.response(response::Response::new());
+        assert!(response
+            .headers()
+            .get("Access-Control-Max-Age")
+            .next()
+            .is_none())
+    }
+
+    #[test]
+    fn allowed_methods_validated_correctly() {
+        let allowed_methods = vec![Method::Get, Method::Head, Method::Post]
+            .into_iter()
+            .map(From::from)
+            .collect();
+
+        let method = "GET";
+
+        not_err!(validate_allowed_method(
+            &FromStr::from_str(method).expect("not to fail"),
+            &allowed_methods,
+        ));
+    }
+
+    #[test]
+    #[should_panic(expected = "MethodNotAllowed")]
+    fn allowed_methods_errors_on_disallowed_method() {
+        let allowed_methods = vec![Method::Get, Method::Head, Method::Post]
+            .into_iter()
+            .map(From::from)
+            .collect();
+
+        let method = "DELETE";
+
+        validate_allowed_method(
+            &FromStr::from_str(method).expect("not to fail"),
+            &allowed_methods,
+        )
+        .unwrap()
+    }
+
+    #[test]
+    fn all_allowed_headers_are_validated_correctly() {
+        let allowed_headers = AllOrSome::All;
+        let requested_headers = vec!["Bar", "Foo"];
+
+        not_err!(validate_allowed_headers(
+            &FromStr::from_str(&requested_headers.join(",")).unwrap(),
+            &allowed_headers,
+        ));
+    }
+
+    /// `Response::allowed_headers` should check that headers are allowed, and only
+    /// echoes back the list that is actually requested for and not the whole list
+    #[test]
+    fn allowed_headers_are_validated_correctly() {
+        let allowed_headers = vec!["Bar", "Baz", "Foo"];
+        let requested_headers = vec!["Bar", "Foo"];
+
+        not_err!(validate_allowed_headers(
+            &FromStr::from_str(&requested_headers.join(",")).unwrap(),
+            &AllOrSome::Some(
+                allowed_headers
+                    .iter()
+                    .map(|s| FromStr::from_str(*s).unwrap())
+                    .collect(),
+            ),
+        ));
+    }
+
+    #[test]
+    #[should_panic(expected = "HeadersNotAllowed")]
+    fn allowed_headers_errors_on_non_subset() {
+        let allowed_headers = vec!["Bar", "Baz", "Foo"];
+        let requested_headers = vec!["Bar", "Foo", "Unknown"];
+
+        validate_allowed_headers(
+            &FromStr::from_str(&requested_headers.join(",")).unwrap(),
+            &AllOrSome::Some(
+                allowed_headers
+                    .iter()
+                    .map(|s| FromStr::from_str(*s).unwrap())
+                    .collect(),
+            ),
+        )
+        .unwrap();
+    }
+
+    #[test]
+    fn response_does_not_build_if_origin_is_not_set() {
+        let response = Response::new();
+        let response = response.response(response::Response::new());
+
+        let headers: Vec<_> = response.headers().iter().collect();
+        assert_eq!(headers.len(), 0);
+    }
+
+    #[test]
+    fn response_build_removes_existing_cors_headers_and_keeps_others() {
+        use std::io::Cursor;
+
+        let original = response::Response::build()
+            .status(Status::ImATeapot)
+            .raw_header("X-Teapot-Make", "Rocket")
+            .raw_header("Access-Control-Max-Age", "42")
+            .sized_body(Cursor::new("Brewing the best coffee!"))
+            .finalize();
+
+        let response = Response::new();
+        let response = response.origin("https://www.example.com", false);
+        let response = response.response(original);
+        // Check CORS header
+        let expected_header = vec!["https://www.example.com"];
+        let actual_header: Vec<_> = response
+            .headers()
+            .get("Access-Control-Allow-Origin")
+            .collect();
+        assert_eq!(expected_header, actual_header);
+
+        // Check other header
+        let expected_header = vec!["Rocket"];
+        let actual_header: Vec<_> = response.headers().get("X-Teapot-Make").collect();
+        assert_eq!(expected_header, actual_header);
+
+        // Check that `Access-Control-Max-Age` is removed
+        assert!(response
+            .headers()
+            .get("Access-Control-Max-Age")
+            .next()
+            .is_none());
+    }
+
+    #[derive(Debug, PartialEq)]
+    #[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
+    struct MethodTest {
+        method: crate::Method,
+    }
+
+    #[cfg(feature = "serialization")]
+    #[test]
+    fn method_serde_roundtrip() {
+        use serde_test::{assert_tokens, Token};
+
+        let test = MethodTest {
+            method: From::from(http::Method::Get),
+        };
+
+        assert_tokens(
+            &test,
+            &[
+                Token::Struct {
+                    name: "MethodTest",
+                    len: 1,
+                },
+                Token::Str("method"),
+                Token::Str("GET"),
+                Token::StructEnd,
+            ],
+        );
+    }
+
+    #[test]
+    fn preflight_validated_correctly() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Get,
+        ));
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let result = validate(&cors, request.inner()).expect("to not fail");
+        let expected_result = ValidationResult::Preflight {
+            origin: "https://www.acme.com".to_string(),
+            // Checks that only a subset of allowed headers are returned
+            // -- i.e. whatever is requested for
+            headers: Some(FromStr::from_str("Authorization").unwrap()),
+        };
+
+        assert_eq!(expected_result, result);
+    }
+
+    #[test]
+    fn preflight_validation_allows_all_origin() {
+        let mut options = make_cors_options();
+        options.allowed_origins = AllOrSome::All;
+        let cors = options.to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Get,
+        ));
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let result = validate(&cors, request.inner()).expect("to not fail");
+        let expected_result = ValidationResult::Preflight {
+            origin: "https://www.example.com".to_string(),
+            headers: Some(FromStr::from_str("Authorization").unwrap()),
+        };
+
+        assert_eq!(expected_result, result);
+    }
+
+    #[test]
+    #[should_panic(expected = "OriginNotAllowed")]
+    fn preflight_validation_errors_on_invalid_origin() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Get,
+        ));
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let _ = validate(&cors, request.inner()).unwrap();
+    }
+
+    #[test]
+    #[should_panic(expected = "MissingRequestMethod")]
+    fn preflight_validation_errors_on_missing_request_method() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(request_headers);
+
+        let _ = validate(&cors, request.inner()).unwrap();
+    }
+
+    #[test]
+    #[should_panic(expected = "MethodNotAllowed")]
+    fn preflight_validation_errors_on_disallowed_method() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Post,
+        ));
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let _ = validate(&cors, request.inner()).unwrap();
+    }
+
+    #[test]
+    #[should_panic(expected = "HeadersNotAllowed")]
+    fn preflight_validation_errors_on_disallowed_headers() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Get,
+        ));
+        let request_headers = hyper::header::AccessControlRequestHeaders(vec![
+            FromStr::from_str("Authorization").unwrap(),
+            FromStr::from_str("X-NOT-ALLOWED").unwrap(),
+        ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let _ = validate(&cors, request.inner()).unwrap();
+    }
+
+    #[test]
+    fn actual_request_validated_correctly() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let request = client.get("/").header(origin_header);
+
+        let result = validate(&cors, request.inner()).expect("to not fail");
+        let expected_result = ValidationResult::Request {
+            origin: "https://www.acme.com".to_string(),
+        };
+
+        assert_eq!(expected_result, result);
+    }
+
+    #[test]
+    fn actual_request_validation_allows_all_origin() {
+        let mut options = make_cors_options();
+        options.allowed_origins = AllOrSome::All;
+        let cors = options.to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
+        let request = client.get("/").header(origin_header);
+
+        let result = validate(&cors, request.inner()).expect("to not fail");
+        let expected_result = ValidationResult::Request {
+            origin: "https://www.example.com".to_string(),
+        };
+
+        assert_eq!(expected_result, result);
+    }
+
+    #[test]
+    #[should_panic(expected = "OriginNotAllowed")]
+    fn actual_request_validation_errors_on_incorrect_origin() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
+        let request = client.get("/").header(origin_header);
+
+        let _ = validate(&cors, request.inner()).unwrap();
+    }
+
+    #[test]
+    fn non_cors_request_return_empty_response() {
+        let cors = make_cors_options().to_cors().expect("To not fail");
+        let client = make_client();
+
+        let request = client.options("/");
+        let response = validate_and_build(&cors, request.inner()).expect("to not fail");
+        let expected_response = Response::new();
+        assert_eq!(expected_response, response);
+    }
+
+    #[test]
+    fn preflight_validated_and_built_correctly() {
+        let options = make_cors_options();
+        let cors = options.to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Get,
+        ));
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let response = validate_and_build(&cors, request.inner()).expect("to not fail");
+
+        let expected_response = Response::new()
+            .origin("https://www.acme.com", false)
+            .headers(&["Authorization"])
+            .methods(&options.allowed_methods)
+            .credentials(options.allow_credentials)
+            .max_age(options.max_age);
+
+        assert_eq!(expected_response, response);
+    }
+
+    /// Tests that when All origins are allowed and send_wildcard disabled, the vary header is set
+    /// in the response and the requested origin is echoed
+    #[test]
+    fn preflight_all_origins_with_vary() {
+        let mut options = make_cors_options();
+        options.allowed_origins = AllOrSome::All;
+        options.send_wildcard = false;
+        let cors = options.to_cors().expect("To not fail");
+
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Get,
+        ));
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let response = validate_and_build(&cors, request.inner()).expect("to not fail");
+
+        let expected_response = Response::new()
+            .origin("https://www.acme.com", true)
+            .headers(&["Authorization"])
+            .methods(&options.allowed_methods)
+            .credentials(options.allow_credentials)
+            .max_age(options.max_age);
+
+        assert_eq!(expected_response, response);
+    }
+
+    /// Tests that when All origins are allowed and send_wildcard enabled, the origin is set to "*"
+    #[test]
+    fn preflight_all_origins_with_wildcard() {
+        let mut options = make_cors_options();
+        options.allowed_origins = AllOrSome::All;
+        options.send_wildcard = true;
+        options.allow_credentials = false;
+        let cors = options.to_cors().expect("To not fail");
+
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let method_header = Header::from(hyper::header::AccessControlRequestMethod(
+            hyper::method::Method::Get,
+        ));
+        let request_headers =
+            hyper::header::AccessControlRequestHeaders(vec![
+                FromStr::from_str("Authorization").unwrap()
+            ]);
+        let request_headers = Header::from(request_headers);
+
+        let request = client
+            .options("/")
+            .header(origin_header)
+            .header(method_header)
+            .header(request_headers);
+
+        let response = validate_and_build(&cors, request.inner()).expect("to not fail");
+
+        let expected_response = Response::new()
+            .any()
+            .headers(&["Authorization"])
+            .methods(&options.allowed_methods)
+            .credentials(options.allow_credentials)
+            .max_age(options.max_age);
+
+        assert_eq!(expected_response, response);
+    }
+
+    #[test]
+    fn actual_request_validated_and_built_correctly() {
+        let options = make_cors_options();
+        let cors = options.to_cors().expect("To not fail");
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let request = client.get("/").header(origin_header);
+
+        let response = validate_and_build(&cors, request.inner()).expect("to not fail");
+        let expected_response = Response::new()
+            .origin("https://www.acme.com", false)
+            .credentials(options.allow_credentials)
+            .exposed_headers(&["Content-Type", "X-Custom"]);
+
+        assert_eq!(expected_response, response);
+    }
+
+    #[test]
+    fn actual_request_all_origins_with_vary() {
+        let mut options = make_cors_options();
+        options.allowed_origins = AllOrSome::All;
+        options.send_wildcard = false;
+        options.allow_credentials = false;
+        let cors = options.to_cors().expect("To not fail");
+
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let request = client.get("/").header(origin_header);
+
+        let response = validate_and_build(&cors, request.inner()).expect("to not fail");
+        let expected_response = Response::new()
+            .origin("https://www.acme.com", true)
+            .credentials(options.allow_credentials)
+            .exposed_headers(&["Content-Type", "X-Custom"]);
+
+        assert_eq!(expected_response, response);
+    }
+
+    #[test]
+    fn actual_request_all_origins_with_wildcard() {
+        let mut options = make_cors_options();
+        options.allowed_origins = AllOrSome::All;
+        options.send_wildcard = true;
+        options.allow_credentials = false;
+        let cors = options.to_cors().expect("To not fail");
+
+        let client = make_client();
+
+        let origin_header =
+            Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
+        let request = client.get("/").header(origin_header);
+
+        let response = validate_and_build(&cors, request.inner()).expect("to not fail");
+        let expected_response = Response::new()
+            .any()
+            .credentials(options.allow_credentials)
+            .exposed_headers(&["Content-Type", "X-Custom"]);
+
+        assert_eq!(expected_response, response);
+    }
+}
+
+
\ No newline at end of file diff --git a/storage.js b/storage.js new file mode 100644 index 0000000..fdc5f96 --- /dev/null +++ b/storage.js @@ -0,0 +1 @@ +var resourcesSuffix="";var currentTheme=document.getElementById("themeStyle");var mainTheme=document.getElementById("mainThemeStyle");var savedHref=[];function hasClass(elem,className){return elem&&elem.classList&&elem.classList.contains(className)}function addClass(elem,className){if(!elem||!elem.classList){return}elem.classList.add(className)}function removeClass(elem,className){if(!elem||!elem.classList){return}elem.classList.remove(className)}function onEach(arr,func,reversed){if(arr&&arr.length>0&&func){var length=arr.length;if(reversed!==true){for(var i=0;i=0;--i){if(func(arr[i])===true){return true}}}}return false}function onEachLazy(lazyArray,func,reversed){return onEach(Array.prototype.slice.call(lazyArray),func,reversed)}function usableLocalStorage(){if(typeof Storage==="undefined"){return false}try{return window.localStorage!==null&&window.localStorage!==undefined}catch(err){return false}}function updateLocalStorage(name,value){if(usableLocalStorage()){localStorage[name]=value}else{}}function getCurrentValue(name){if(usableLocalStorage()&&localStorage[name]!==undefined){return localStorage[name]}return null}function switchTheme(styleElem,mainStyleElem,newTheme,saveTheme){var fullBasicCss="rustdoc"+resourcesSuffix+".css";var fullNewTheme=newTheme+resourcesSuffix+".css";var newHref=mainStyleElem.href.replace(fullBasicCss,fullNewTheme);if(styleElem.href===newHref){return}var found=false;if(savedHref.length===0){onEachLazy(document.getElementsByTagName("link"),function(el){savedHref.push(el.href)})}onEach(savedHref,function(el){if(el===newHref){found=true;return true}});if(found===true){styleElem.href=newHref;if(saveTheme===true){updateLocalStorage("rustdoc-theme",newTheme)}}}function getSystemValue(){var property=getComputedStyle(document.documentElement).getPropertyValue('content');return property.replace(/[\"\']/g,"")}switchTheme(currentTheme,mainTheme,getCurrentValue("rustdoc-theme")||getSystemValue()||"light",false) \ No newline at end of file diff --git a/theme.js b/theme.js new file mode 100644 index 0000000..bc5f355 --- /dev/null +++ b/theme.js @@ -0,0 +1,47 @@ +var themes = document.getElementById("theme-choices"); +var themePicker = document.getElementById("theme-picker"); + +function showThemeButtonState() { + themes.style.display = "block"; + themePicker.style.borderBottomRightRadius = "0"; + themePicker.style.borderBottomLeftRadius = "0"; +} + +function hideThemeButtonState() { + themes.style.display = "none"; + themePicker.style.borderBottomRightRadius = "3px"; + themePicker.style.borderBottomLeftRadius = "3px"; +} + +function switchThemeButtonState() { + if (themes.style.display === "block") { + hideThemeButtonState(); + } else { + showThemeButtonState(); + } +}; + +function handleThemeButtonsBlur(e) { + var active = document.activeElement; + var related = e.relatedTarget; + + if (active.id !== "themePicker" && + (!active.parentNode || active.parentNode.id !== "theme-choices") && + (!related || + (related.id !== "themePicker" && + (!related.parentNode || related.parentNode.id !== "theme-choices")))) { + hideThemeButtonState(); + } +} + +themePicker.onclick = switchThemeButtonState; +themePicker.onblur = handleThemeButtonsBlur; +["dark","light"].forEach(function(item) { + var but = document.createElement('button'); + but.innerHTML = item; + but.onclick = function(el) { + switchTheme(currentTheme, mainTheme, item, true); + }; + but.onblur = handleThemeButtonsBlur; + themes.appendChild(but); +}); \ No newline at end of file diff --git a/wheel.svg b/wheel.svg new file mode 100644 index 0000000..44381a4 --- /dev/null +++ b/wheel.svg @@ -0,0 +1 @@ + \ No newline at end of file