Compare commits

..

No commits in common. "gh-pages" and "master" have entirely different histories.

92 changed files with 6104 additions and 17338 deletions

9
.gitignore vendored
View file

@ -1,8 +1,7 @@
target/
Cargo.lock
/target
*.swp
*.swo
.DS_Store
*.o
*.a
*.pyc
.lock
__pycache__
Cargo.lock

45
.travis.yml Normal file
View file

@ -0,0 +1,45 @@
language: rust
sudo: false
dist: trusty
addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
- binutils-dev
- libiberty-dev
- gcc-multilib
matrix:
include:
- os: linux
rust: 1.34.2
- os: linux
rust: stable
- os: osx
rust: stable
- os: linux
rust: beta
- os: linux
rust: nightly
install:
- if [ "$TRAVIS_OS_NAME" = 'linux' ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi
- rustup target add i686-$OS
script:
- cargo test --no-default-features
- cargo test
- if [ "$TRAVIS_RUST_VERSION" = 'nightly' ]; then cargo test --features bench && cargo bench --features bench; fi
- cargo test --target i686-$OS
after_success:
- >
if [ "$TRAVIS_OS_NAME" = 'linux' ]; then
cargo install cargo-kcov &&
( cargo kcov --print-install-kcov-sh | bash ) &&
cargo kcov --coveralls
fi

View file

@ -1,64 +0,0 @@
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.
* Heuristica (Heuristica-Italic.woff):
Copyright 1989, 1991 Adobe Systems Incorporated. All rights reserved.
Utopia is either a registered trademark or trademark of Adobe Systems
Incorporated in the United States and/or other countries. Used under
license.
Copyright 2006 Han The Thanh, Vntopia font family, http://vntex.sf.net
Copyright (c) 2008-2012, Andrey V. Panov (panov@canopus.iacp.dvo.ru),
with Reserved Font Name Heuristica.
Licensed under the SIL Open Font License, Version 1.1.
See Heuristica-LICENSE.txt.
* jQuery (jquery-2.1.4.min.js):
Copyright 2005, 2015 jQuery Foundation, Inc.
Licensed under the MIT license (see LICENSE-MIT.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.woff, SourceSerifPro-Bold.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.

47
Cargo.toml Normal file
View file

@ -0,0 +1,47 @@
[package]
name = "qrcode"
description = "QR code encoder in Rust"
license = "MIT OR Apache-2.0"
version = "0.12.0"
edition = "2018"
authors = ["kennytm <kennytm@gmail.com>"]
keywords = ["qrcode"]
repository = "https://github.com/kennytm/qrcode-rust"
readme = "README.md"
documentation = "http://docs.rs/qrcode"
exclude = [
".travis.yml", ".gitignore", "test-data/**"
]
[badges]
travis-ci = { repository = "kennytm/qrcode-rust" }
coveralls = { repository = "kennytm/qrcode-rust" }
is-it-maintained-issue-resolution = { repository = "kennytm/qrcode-rust" }
is-it-maintained-open-issues = { repository = "kennytm/qrcode-rust" }
maintenance = { status = "passively-maintained" }
[dependencies]
image = { version = "0.23", default-features = false, optional = true }
checked_int_cast = "1"
[dev-dependencies]
image = "0.23"
[features]
default = ["image", "svg"]
bench = []
svg = []
[[bin]]
name = "qrencode"
[[example]]
name = "encode_image"
required-features = ["image"]
[[example]]
name = "encode_string"
[[example]]
name = "encode_svg"
required-features = ["svg"]

View file

@ -1,99 +0,0 @@
Copyright (c) 2014, Mozilla Foundation https://mozilla.org/
with Reserved Font Name Fira Sans.
Copyright (c) 2014, Mozilla Foundation https://mozilla.org/
with Reserved Font Name Fira Mono.
Copyright (c) 2014, Telefonica S.A.
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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,101 +0,0 @@
Copyright 1989, 1991 Adobe Systems Incorporated. All rights reserved.
Utopia is either a registered trademark or trademark of Adobe Systems
Incorporated in the United States and/or other countries. Used under
license.
Copyright 2006 Han The Thanh, Vntopia font family, http://vntex.sf.net
Copyright (c) 2008-2012, Andrey V. Panov (panov@canopus.iacp.dvo.ru),
with Reserved Font Name Heuristica.
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.

View file

@ -1,201 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
1. Definitions.
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
1. Definitions.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"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.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this 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.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"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.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"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).
"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.
"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.
"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).
"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."
"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.
"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.
"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."
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.
"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.
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.
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.
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:
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.
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
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:
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; 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
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; 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.
(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
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.
(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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
END OF TERMS AND CONDITIONS
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.
APPENDIX: How to apply the Apache License to your work.
END OF TERMS AND CONDITIONS
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.
APPENDIX: How to apply the Apache License to your work.
Copyright [yyyy] [name of copyright owner]
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.
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
Copyright [yyyy] [name of copyright owner]
http://www.apache.org/licenses/LICENSE-2.0
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
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.
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.

View file

@ -1,23 +1,19 @@
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:
Copyright (c) 2016 kennytm
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
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.
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.

147
README.md Normal file
View file

@ -0,0 +1,147 @@
qrcode-rust
===========
[![Build status](https://travis-ci.org/kennytm/qrcode-rust.svg?branch=master)](https://travis-ci.org/kennytm/qrcode-rust)
[![Coverage Status](https://coveralls.io/repos/github/kennytm/qrcode-rust/badge.svg?branch=coveralls)](https://coveralls.io/github/kennytm/qrcode-rust?branch=coveralls)
[![crates.io](https://img.shields.io/crates/v/qrcode.svg)](https://crates.io/crates/qrcode)
[![MIT OR Apache 2.0](https://img.shields.io/badge/license-MIT%20%2f%20Apache%202.0-blue.svg)](./LICENSE-APACHE.txt)
QR code and Micro QR code encoder in Rust. [Documentation](https://docs.rs/qrcode).
Cargo.toml
----------
```toml
[dependencies]
qrcode = "0.11"
```
The default settings will depend on the `image` crate. If you don't need image generation capability, disable the `default-features`:
```toml
[dependencies]
qrcode = { version = "0.11", default-features = false }
```
Example
-------
## Image generation
```rust
use qrcode::QrCode;
use image::Luma;
fn main() {
// Encode some data into bits.
let code = QrCode::new(b"01234567").unwrap();
// Render the bits into an image.
let image = code.render::<Luma<u8>>().build();
// Save the image.
image.save("/tmp/qrcode.png").unwrap();
}
```
Generates this image:
![Output](src/test_annex_i_qr_as_image.png)
## String generation
```rust
use qrcode::QrCode;
fn main() {
let code = QrCode::new(b"Hello").unwrap();
let string = code.render::<char>()
.quiet_zone(false)
.module_dimensions(2, 1)
.build();
println!("{}", string);
}
```
Generates this output:
```none
############## ######## ##############
## ## ## ## ##
## ###### ## ## ## ## ## ###### ##
## ###### ## ## ## ## ###### ##
## ###### ## #### ## ## ###### ##
## ## #### ## ## ##
############## ## ## ## ##############
## ##
## ########## ## ## ##########
## ## ######## #### ##
########## #### ## #### ######
## ## #### ########## ####
###### ########## ## ## ##
## ## ## ##
############## ## ## ## ## ####
## ## ## ## ##########
## ###### ## ## ## ## ## ##
## ###### ## #### ########## ##
## ###### ## #### ## #### ##
## ## ## ######## ######
############## #### ## ## ##
```
## SVG generation
```rust
use qrcode::{QrCode, Version, EcLevel};
use qrcode::render::svg;
fn main() {
let code = QrCode::with_version(b"01234567", Version::Micro(2), EcLevel::L).unwrap();
let image = code.render()
.min_dimensions(200, 200)
.dark_color(svg::Color("#800000"))
.light_color(svg::Color("#ffff80"))
.build();
println!("{}", image);
}
```
Generates this SVG:
[![Output](src/test_annex_i_micro_qr_as_svg.svg)](src/test_annex_i_micro_qr_as_svg.svg)
## Unicode string generation
```rust
use qrcode::QrCode;
use qrcode::render::unicode;
fn main() {
let code = QrCode::new("mow mow").unwrap();
let image = code.render::<unicode::Dense1x2>()
.dark_color(unicode::Dense1x2::Light)
.light_color(unicode::Dense1x2::Dark)
.build();
println!("{}", image);
}
```
Generates this output:
```text
█████████████████████████████
█████████████████████████████
████ ▄▄▄▄▄ █ ▀▀▀▄█ ▄▄▄▄▄ ████
████ █ █ █▀ ▀ ▀█ █ █ ████
████ █▄▄▄█ ██▄ ▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄▀ █▄▄▄▄▄▄▄████
████▄▀ ▄▀ ▄ █▄█ ▀ ▀█ █▄ ████
████▄██▄▄▀▄▄▀█▄ ██▀▀█▀▄▄▄████
█████▄▄▄█▄▄█ ▀▀▄█▀▀▀▄█▄▄████
████ ▄▄▄▄▄ █ ▄▄██▄ ▄ ▀▀████
████ █ █ █▀▄▄▀▄▄ ▄▄▄▄ ▄████
████ █▄▄▄█ █▄ █▄▀▄▀██▄█▀████
████▄▄▄▄▄▄▄█▄████▄█▄██▄██████
█████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
```

View file

@ -1,93 +0,0 @@
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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,93 +0,0 @@
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.
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.

Binary file not shown.

13
examples/encode_image.rs Normal file
View file

@ -0,0 +1,13 @@
use image::Luma;
use qrcode::QrCode;
fn main() {
// Encode some data into bits.
let code = QrCode::new(b"01234567").unwrap();
// Render the bits into an image.
let image = code.render::<Luma<u8>>().build();
// Save the image.
image.save("/tmp/qrcode.png").unwrap();
}

View file

@ -0,0 +1,7 @@
use qrcode::QrCode;
fn main() {
let code = QrCode::new(b"Hello").unwrap();
let string = code.render::<char>().quiet_zone(false).module_dimensions(2, 1).build();
println!("{}", string);
}

13
examples/encode_svg.rs Normal file
View file

@ -0,0 +1,13 @@
use qrcode::render::svg;
use qrcode::{EcLevel, QrCode, Version};
fn main() {
let code = QrCode::with_version(b"01234567", Version::Micro(2), EcLevel::L).unwrap();
let image = code
.render()
.min_dimensions(200, 200)
.dark_color(svg::Color("#800000"))
.light_color(svg::Color("#ffff80"))
.build();
println!("{}", image);
}

View file

@ -1,5 +0,0 @@
<!DOCTYPE html>
<title>qrcode</title>
<meta http-equiv=Refresh content="0; url=qrcode/index.html">
<a href="qrcode/index.html">Read the qrcode API documentation</a>

4
jquery.js vendored

File diff suppressed because one or more lines are too long

132
main.css
View file

@ -1,132 +0,0 @@
/**
* Copyright 2015 The Rust Project Developers. See the COPYRIGHT
* file at the top-level directory of this distribution and at
* http://rust-lang.org/COPYRIGHT.
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
* option. This file may not be copied, modified, or distributed
* except according to those terms.
*/
/* General structure and fonts */
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, code {
background-color: white;
}
div.stability > em > code {
background-color: initial;
}
.docblock code {
background-color: #F5F5F5;
}
pre {
background-color: #F5F5F5;
}
.sidebar .location {
background: #e1e1e1;
color: #333;
}
.block a:hover {
background: #F5F5F5;
}
.line-numbers span { color: #c67e2d; }
.line-numbers .line-highlighted {
background-color: #f6fdb0 !important;
}
:target { background: #FDFFD3; }
.content .highlighted {
color: #000 !important;
background-color: #ccc;
}
.content .highlighted a, .content .highlighted span { color: #000 !important; }
.content .highlighted.trait { background-color: #fece7e; }
.content .highlighted.mod { background-color: #afc6e4; }
.content .highlighted.enum { background-color: #b4d1b9; }
.content .highlighted.struct { background-color: #e7b1a0; }
.content .highlighted.fn { background-color: #c6afb3; }
.content .highlighted.method { background-color: #c6afb3; }
.content .highlighted.tymethod { background-color: #c6afb3; }
.content .highlighted.type { background-color: #c6afb3; }
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
border-bottom-color: #DDD;
}
.docblock table {
border-color: #ddd;
}
.docblock table td {
border-top-color: #ddd;
border-bottom-color: #ddd;
}
.docblock table th {
border-top-color: #ddd;
border-bottom-color: #ddd;
}
.content a.primitive { color: #39a7bf; }
.content span.externcrate, span.mod, .content a.mod, block a.current.mod { color: #4d76ae; }
.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: #8c6067; }
pre.rust .comment { color: #8E908C; }
pre.rust .doccomment { color: #4D4D4C; }
nav {
border-bottom-color: #e0e0e0;
}
nav.main .current {
border-top-color: #000;
border-bottom-color: #000;
}
nav.main .separator {
border-color: 1px solid #000;
}
a {
color: #000;
}
.docblock a, .stability a {
color: #3873AD;
}
a.test-arrow {
color: #f5f5f5;
}
.content span.trait, .content a.trait, .block a.current.trait { color: #7c5af3; }
.search-input {
color: #555;
box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent;
background-color: white;
}
em.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
em.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }

1040
main.js

File diff suppressed because it is too large Load diff

1
normalize.css vendored
View file

@ -1 +0,0 @@
/*! 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}

View file

@ -1,56 +0,0 @@
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/*jslint browser: true, es5: true */
/*globals $: true, rootPath: true */
document.addEventListener('DOMContentLoaded', function() {
'use strict';
if (!window.playgroundUrl) {
return;
}
var featureRegexp = new RegExp('^\s*#!\\[feature\\(\.*?\\)\\]');
var elements = document.querySelectorAll('pre.rust-example-rendered');
Array.prototype.forEach.call(elements, function(el) {
el.onmouseover = function(e) {
if (el.contains(e.relatedTarget)) {
return;
}
var a = document.createElement('a');
a.setAttribute('class', 'test-arrow');
a.textContent = 'Run';
var code = el.previousElementSibling.textContent;
var channel = '';
if (featureRegexp.test(code)) {
channel = '&version=nightly';
}
a.setAttribute('href', window.playgroundUrl + '?code=' +
encodeURIComponent(code) + channel);
a.setAttribute('target', '_blank');
el.appendChild(a);
};
el.onmouseout = function(e) {
if (el.contains(e.relatedTarget)) {
return;
}
el.removeChild(el.querySelectorAll('a.test-arrow')[0]);
};
});
});

View file

@ -1,134 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `ExtendedMode` enum in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, ExtendedMode">
<title>qrcode::bits::ExtendedMode - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>bits</a></p><script>window.sidebarCurrent = {name: 'ExtendedMode', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content enum">
<h1 class='fqn'><span class='in-band'>Enum <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>bits</a>::<wbr><a class='enum' href=''>ExtendedMode</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-234' class='srclink' href='../../src/qrcode/src/bits.rs.html#151-166' title='goto source code'>[src]</a></span></h1>
<pre class='rust enum'>pub enum ExtendedMode {
Eci,
Data(<a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a>),
Fnc1First,
Fnc1Second,
StructuredAppend,
}</pre><div class='docblock'><p>An &quot;extended&quot; mode indicator, includes all indicators supported by QR code
beyond those bearing data.</p>
</div><h2 class='variants'>Variants</h2>
<span id='variant.Eci' class='variant'><code>Eci</code></span><div class='docblock'><p>ECI mode indicator, to introduce an ECI designator.</p>
</div><span id='variant.Data' class='variant'><code>Data(<a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a>)</code></span><div class='docblock'><p>The normal mode to introduce data.</p>
</div><span id='variant.Fnc1First' class='variant'><code>Fnc1First</code></span><div class='docblock'><p>FNC-1 mode in the first position.</p>
</div><span id='variant.Fnc1Second' class='variant'><code>Fnc1Second</code></span><div class='docblock'><p>FNC-1 mode in the second position.</p>
</div><span id='variant.StructuredAppend' class='variant'><code>StructuredAppend</code></span><div class='docblock'><p>Structured append.</p>
</div><h2 id='implementations'>Trait Implementations</h2><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../../qrcode/bits/enum.ExtendedMode.html' title='qrcode::bits::ExtendedMode'>ExtendedMode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-241' class='srclink' href='../../src/qrcode/src/bits.rs.html#150' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/bits/enum.ExtendedMode.html' title='qrcode::bits::ExtendedMode'>ExtendedMode</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../../qrcode/bits/enum.ExtendedMode.html' title='qrcode::bits::ExtendedMode'>ExtendedMode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-245' class='srclink' href='../../src/qrcode/src/bits.rs.html#150' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,118 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `encode_auto` fn in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, encode_auto">
<title>qrcode::bits::encode_auto - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>bits</a></p><script>window.sidebarCurrent = {name: 'encode_auto', ty: 'fn', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content fn">
<h1 class='fqn'><span class='in-band'>Function <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>bits</a>::<wbr><a class='fn' href=''>encode_auto</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-354' class='srclink' href='../../src/qrcode/src/bits.rs.html#824-840' title='goto source code'>[src]</a></span></h1>
<pre class='rust fn'>pub fn encode_auto(data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>, ec_level: <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a>&gt;</pre><div class='docblock'><p>Automatically determines the minimum version to store the data, and encode
the result.</p>
<p>This method will not consider any Micro QR code versions.</p>
</div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,141 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `bits` mod in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, bits">
<title>qrcode::bits - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a></p><script>window.sidebarCurrent = {name: 'bits', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>qrcode</a>::<wbr><a class='mod' href=''>bits</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-196' class='srclink' href='../../src/qrcode/src/bits.rs.html#1-892' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>The <code>bits</code> module encodes binary data into raw bits used in a QR code.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class='struct' href='struct.Bits.html'
title='qrcode::bits::Bits'>Bits</a></td>
<td class='docblock short'>
<p>The <code>Bits</code> structure stores the encoded data for a QR code.</p>
</td>
</tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
<tr class=' module-item'>
<td><a class='enum' href='enum.ExtendedMode.html'
title='qrcode::bits::ExtendedMode'>ExtendedMode</a></td>
<td class='docblock short'>
<p>An &quot;extended&quot; mode indicator, includes all indicators supported by QR code
beyond those bearing data.</p>
</td>
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class='fn' href='fn.encode_auto.html'
title='qrcode::bits::encode_auto'>encode_auto</a></td>
<td class='docblock short'>
<p>Automatically determines the minimum version to store the data, and encode
the result.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1 +0,0 @@
initSidebarItems({"enum":[["ExtendedMode","An \"extended\" mode indicator, includes all indicators supported by QR code beyond those bearing data."]],"fn":[["encode_auto","Automatically determines the minimum version to store the data, and encode the result."]],"struct":[["Bits","The `Bits` structure stores the encoded data for a QR code."]]});

View file

@ -1,268 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Bits` struct in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Bits">
<title>qrcode::bits::Bits - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>bits</a></p><script>window.sidebarCurrent = {name: 'Bits', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>bits</a>::<wbr><a class='struct' href=''>Bits</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-201' class='srclink' href='../../src/qrcode/src/bits.rs.html#15-19' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Bits {
// some fields omitted
}</pre><div class='docblock'><p>The <code>Bits</code> structure stores the encoded data for a QR code.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-205' class='srclink' href='../../src/qrcode/src/bits.rs.html#21-104' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>(version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></h4>
<div class='docblock'><p>Constructs a new, empty bits structure.</p>
</div><h4 id='method.into_bytes' class='method'><code>fn <a href='#method.into_bytes' class='fnname'>into_bytes</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>&gt;</code></h4>
<div class='docblock'><p>Convert the bits into a bytes vector.</p>
</div><h4 id='method.len' class='method'><code>fn <a href='#method.len' class='fnname'>len</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Total number of bits currently pushed.</p>
</div><h4 id='method.max_len' class='method'><code>fn <a href='#method.max_len' class='fnname'>max_len</a>(&amp;self, ec_level: <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt;</code></h4>
<div class='docblock'><p>The maximum number of bits allowed by the provided QR code version and
error correction level.</p>
</div><h4 id='method.version' class='method'><code>fn <a href='#method.version' class='fnname'>version</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></h4>
<div class='docblock'><p>Version of the QR code.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-246' class='srclink' href='../../src/qrcode/src/bits.rs.html#168-193' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_mode_indicator' class='method'><code>fn <a href='#method.push_mode_indicator' class='fnname'>push_mode_indicator</a>(&amp;mut self, mode: <a class='enum' href='../../qrcode/bits/enum.ExtendedMode.html' title='qrcode::bits::ExtendedMode'>ExtendedMode</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Push the mode indicator to the end of the bits.</p>
<p>If the mode is not supported in the provided version, this method
returns <code>Err(QrError::UnsupportedCharacterSet)</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-252' class='srclink' href='../../src/qrcode/src/bits.rs.html#199-255' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_eci_designator' class='method'><code>fn <a href='#method.push_eci_designator' class='fnname'>push_eci_designator</a>(&amp;mut self, eci_designator: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u32.html'>u32</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Push an ECI (Extended Channel Interpretation) designator to the bits.</p>
<p>An ECI designator is a 6-digit number to specify the character set of
the following binary data. After calling this method, one could call
<code>.push_byte_data()</code> or similar methods to insert the actual data, e.g.</p>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>unused_must_use</span>)]</span>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>bits</span>::<span class='ident'>Bits</span>;
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::<span class='ident'>Version</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>bits</span> <span class='op'>=</span> <span class='ident'>Bits</span>::<span class='ident'>new</span>(<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>));
<span class='ident'>bits</span>.<span class='ident'>push_eci_designator</span>(<span class='number'>9</span>); <span class='comment'>// 9 = ISO-8859-7 (Greek).</span>
<span class='ident'>bits</span>.<span class='ident'>push_byte_data</span>(<span class='string'>b&quot;\xa1\xa2\xa3\xa4\xa5&quot;</span>); <span class='comment'>// ΑΒΓΔΕ</span></pre>
<p>The full list of ECI designator values can be found from
<a href="http://strokescribe.com/en/ECI.html">http://strokescribe.com/en/ECI.html</a>. Some example values are:</p>
<table>
<thead>
<tr>
<th>ECI #</th>
<th>Character set</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>ISO-8859-1 (Western European)</td>
</tr>
<tr>
<td>20</td>
<td>Shift JIS (Japanese)</td>
</tr>
<tr>
<td>23</td>
<td>Windows 1252 (Latin 1) (Western European)</td>
</tr>
<tr>
<td>25</td>
<td>UTF-16 Big Endian</td>
</tr>
<tr>
<td>26</td>
<td>UTF-8</td>
</tr>
<tr>
<td>28</td>
<td>Big 5 (Traditional Chinese)</td>
</tr>
<tr>
<td>29</td>
<td>GB-18030 (Simplified Chinese)</td>
</tr>
<tr>
<td>30</td>
<td>EUC-KR (Korean)</td>
</tr>
</tbody>
</table>
<p>If the QR code version does not support ECI, this method will return
<code>Err(QrError::UnsupportedCharacterSet)</code>.</p>
<p>If the designator is outside of the expected range, this method will
return <code>Err(QrError::InvalidECIDesignator)</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-258' class='srclink' href='../../src/qrcode/src/bits.rs.html#303-324' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_numeric_data' class='method'><code>fn <a href='#method.push_numeric_data' class='fnname'>push_numeric_data</a>(&amp;mut self, data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Encodes a numeric string to the bits.</p>
<p>The data should only contain the characters 0 to 9.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-283' class='srclink' href='../../src/qrcode/src/bits.rs.html#406-420' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_alphanumeric_data' class='method'><code>fn <a href='#method.push_alphanumeric_data' class='fnname'>push_alphanumeric_data</a>(&amp;mut self, data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Encodes an alphanumeric string to the bits.</p>
<p>The data should only contain the charaters A to Z (excluding lowercase),
0 to 9, space, <code>$</code>, <code>%</code>, <code>*</code>, <code>+</code>, <code>-</code>, <code>.</code>, <code>/</code> or <code>:</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-297' class='srclink' href='../../src/qrcode/src/bits.rs.html#456-465' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_byte_data' class='method'><code>fn <a href='#method.push_byte_data' class='fnname'>push_byte_data</a>(&amp;mut self, data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Encodes 8-bit byte data to the bits.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-304' class='srclink' href='../../src/qrcode/src/bits.rs.html#505-520' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_kanji_data' class='method'><code>fn <a href='#method.push_kanji_data' class='fnname'>push_kanji_data</a>(&amp;mut self, data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Encodes Shift JIS double-byte data to the bits.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-314' class='srclink' href='../../src/qrcode/src/bits.rs.html#556-600' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_fnc1_first_position' class='method'><code>fn <a href='#method.push_fnc1_first_position' class='fnname'>push_fnc1_first_position</a>(&amp;mut self) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Encodes an indicator that the following data are formatted according to
the UCC/EAN Application Identifiers standard.</p>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>unused_must_use</span>)]</span>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>bits</span>::<span class='ident'>Bits</span>;
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::<span class='ident'>Version</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>bits</span> <span class='op'>=</span> <span class='ident'>Bits</span>::<span class='ident'>new</span>(<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>));
<span class='ident'>bits</span>.<span class='ident'>push_fnc1_first_position</span>();
<span class='ident'>bits</span>.<span class='ident'>push_numeric_data</span>(<span class='string'>b&quot;01049123451234591597033130128&quot;</span>);
<span class='ident'>bits</span>.<span class='ident'>push_alphanumeric_data</span>(<span class='string'>b&quot;%10ABC123&quot;</span>);</pre>
<p>In QR code, the character <code>%</code> is used as the data field separator (0x1D).</p>
</div><h4 id='method.push_fnc1_second_position' class='method'><code>fn <a href='#method.push_fnc1_second_position' class='fnname'>push_fnc1_second_position</a>(&amp;mut self, application_indicator: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Encodes an indicator that the following data are formatted in accordance
with specific industry or application specifications previously agreed
with AIM International.</p>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>unused_must_use</span>)]</span>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>bits</span>::<span class='ident'>Bits</span>;
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::<span class='ident'>Version</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>bits</span> <span class='op'>=</span> <span class='ident'>Bits</span>::<span class='ident'>new</span>(<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>));
<span class='ident'>bits</span>.<span class='ident'>push_fnc1_second_position</span>(<span class='number'>37</span>);
<span class='ident'>bits</span>.<span class='ident'>push_alphanumeric_data</span>(<span class='string'>b&quot;AA1234BBB112&quot;</span>);
<span class='ident'>bits</span>.<span class='ident'>push_byte_data</span>(<span class='string'>b&quot;text text text text\r&quot;</span>);</pre>
<p>If the application indicator is a single Latin alphabet (az / AZ),
please pass in its ASCII value + 100:</p>
<pre class='rust rust-example-rendered'>
<span class='ident'>bits</span>.<span class='ident'>push_fnc1_second_position</span>(<span class='string'>b&#39;A&#39;</span> <span class='op'>+</span> <span class='number'>100</span>);</pre>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-325' class='srclink' href='../../src/qrcode/src/bits.rs.html#657-692' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_terminator' class='method'><code>fn <a href='#method.push_terminator' class='fnname'>push_terminator</a>(&amp;mut self, ec_level: <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Pushes the ending bits to indicate no more data.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-340' class='srclink' href='../../src/qrcode/src/bits.rs.html#755-778' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.push_segments' class='method'><code>fn <a href='#method.push_segments' class='fnname'>push_segments</a>&lt;I&gt;(&amp;mut self, data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>, segments_iter: I) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt; <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a>&lt;Item=<a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a>&gt;</span></code></h4>
<div class='docblock'><p>Push a segmented data to the bits, and then terminate it.</p>
</div><h4 id='method.push_optimal_data' class='method'><code>fn <a href='#method.push_optimal_data' class='fnname'>push_optimal_data</a>(&amp;mut self, data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>&gt;</code></h4>
<div class='docblock'><p>Pushes the data the bits, using the optimal encoding.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,143 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `MaskPattern` enum in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, MaskPattern">
<title>qrcode::canvas::MaskPattern - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a></p><script>window.sidebarCurrent = {name: 'MaskPattern', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content enum">
<h1 class='fqn'><span class='in-band'>Enum <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a>::<wbr><a class='enum' href=''>MaskPattern</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-872' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1380-1404' title='goto source code'>[src]</a></span></h1>
<pre class='rust enum'>pub enum MaskPattern {
Checkerboard,
HorizontalLines,
VerticalLines,
DiagonalLines,
LargeCheckerboard,
Fields,
Diamonds,
Meadow,
}</pre><div class='docblock'><p>The mask patterns. Since QR code and Micro QR code do not use the same
pattern number, we name them according to their shape instead of the number.</p>
</div><h2 class='variants'>Variants</h2>
<span id='variant.Checkerboard' class='variant'><code>Checkerboard</code></span><div class='docblock'><p>QR code pattern 000: <code>(x + y) % 2 == 0</code>.</p>
</div><span id='variant.HorizontalLines' class='variant'><code>HorizontalLines</code></span><div class='docblock'><p>QR code pattern 001: <code>y % 2 == 0</code>.</p>
</div><span id='variant.VerticalLines' class='variant'><code>VerticalLines</code></span><div class='docblock'><p>QR code pattern 010: <code>x % 3 == 0</code>.</p>
</div><span id='variant.DiagonalLines' class='variant'><code>DiagonalLines</code></span><div class='docblock'><p>QR code pattern 011: <code>(x + y) % 3 == 0</code>.</p>
</div><span id='variant.LargeCheckerboard' class='variant'><code>LargeCheckerboard</code></span><div class='docblock'><p>QR code pattern 100: <code>((x/3) + (y/2)) % 2 == 0</code>.</p>
</div><span id='variant.Fields' class='variant'><code>Fields</code></span><div class='docblock'><p>QR code pattern 101: <code>(x*y)%2 + (x*y)%3 == 0</code>.</p>
</div><span id='variant.Diamonds' class='variant'><code>Diamonds</code></span><div class='docblock'><p>QR code pattern 110: <code>((x*y)%2 + (x*y)%3) % 2 == 0</code>.</p>
</div><span id='variant.Meadow' class='variant'><code>Meadow</code></span><div class='docblock'><p>QR code pattern 111: <code>((x+y)%2 + (x*y)%3) % 2 == 0</code>.</p>
</div><h2 id='implementations'>Trait Implementations</h2><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../../qrcode/canvas/enum.MaskPattern.html' title='qrcode::canvas::MaskPattern'>MaskPattern</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-889' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1379' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/canvas/enum.MaskPattern.html' title='qrcode::canvas::MaskPattern'>MaskPattern</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../../qrcode/canvas/enum.MaskPattern.html' title='qrcode::canvas::MaskPattern'>MaskPattern</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-892' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1379' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='enum' href='../../qrcode/canvas/enum.MaskPattern.html' title='qrcode::canvas::MaskPattern'>MaskPattern</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-893' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1379' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,160 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Module` enum in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Module">
<title>qrcode::canvas::Module - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a></p><script>window.sidebarCurrent = {name: 'Module', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content enum">
<h1 class='fqn'><span class='in-band'>Enum <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a>::<wbr><a class='enum' href=''>Module</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-661' class='srclink' href='../../src/qrcode/src/canvas.rs.html#30-49' title='goto source code'>[src]</a></span></h1>
<pre class='rust enum'>pub enum Module {
Empty,
Light,
Dark,
LightUnmasked,
DarkUnmasked,
}</pre><div class='docblock'><p>The color of a module (pixel) in the QR code.</p>
</div><h2 class='variants'>Variants</h2>
<span id='variant.Empty' class='variant'><code>Empty</code></span><div class='docblock'><p>The module is empty.</p>
</div><span id='variant.Light' class='variant'><code>Light</code></span><div class='docblock'><p>The module is light (white), and cannot be masked. This mainly refers to
modules of functional patterns.</p>
</div><span id='variant.Dark' class='variant'><code>Dark</code></span><div class='docblock'><p>The module is dark (black), and cannot be masked. This mainly refers to
modules of functional patterns.</p>
</div><span id='variant.LightUnmasked' class='variant'><code>LightUnmasked</code></span><div class='docblock'><p>The module is light (white), but not yet masked. This mainly refers to
modules of data and error correction bits before masking.</p>
</div><span id='variant.DarkUnmasked' class='variant'><code>DarkUnmasked</code></span><div class='docblock'><p>The module is dark (black), but not yet masked. This mainly refers to
modules of data and error correction bits before masking.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-689' class='srclink' href='../../src/qrcode/src/canvas.rs.html#51-79' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.is_dark' class='method'><code>fn <a href='#method.is_dark' class='fnname'>is_dark</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Checks whether a module is dark.</p>
</div><h4 id='method.mask' class='method'><code>fn <a href='#method.mask' class='fnname'>mask</a>(&amp;self, should_invert: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></h4>
<div class='docblock'><p>Apply a mask to the unmasked modules.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>canvas</span>::<span class='ident'>Module</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Module</span>::<span class='ident'>LightUnmasked</span>.<span class='ident'>mask</span>(<span class='boolvalue'>true</span>), <span class='ident'>Module</span>::<span class='ident'>Dark</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Module</span>::<span class='ident'>DarkUnmasked</span>.<span class='ident'>mask</span>(<span class='boolvalue'>true</span>), <span class='ident'>Module</span>::<span class='ident'>Light</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Module</span>::<span class='ident'>LightUnmasked</span>.<span class='ident'>mask</span>(<span class='boolvalue'>false</span>), <span class='ident'>Module</span>::<span class='ident'>Light</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Module</span>::<span class='ident'>Dark</span>.<span class='ident'>mask</span>(<span class='boolvalue'>true</span>), <span class='ident'>Module</span>::<span class='ident'>Dark</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Module</span>::<span class='ident'>Dark</span>.<span class='ident'>mask</span>(<span class='boolvalue'>false</span>), <span class='ident'>Module</span>::<span class='ident'>Dark</span>);</pre>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-667' class='srclink' href='../../src/qrcode/src/canvas.rs.html#29' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-676' class='srclink' href='../../src/qrcode/src/canvas.rs.html#29' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-677' class='srclink' href='../../src/qrcode/src/canvas.rs.html#29' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-680' class='srclink' href='../../src/qrcode/src/canvas.rs.html#29' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-683' class='srclink' href='../../src/qrcode/src/canvas.rs.html#29' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,116 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `is_functional` fn in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, is_functional">
<title>qrcode::canvas::is_functional - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a></p><script>window.sidebarCurrent = {name: 'is_functional', ty: 'fn', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content fn">
<h1 class='fqn'><span class='in-band'>Function <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a>::<wbr><a class='fn' href=''>is_functional</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-816' class='srclink' href='../../src/qrcode/src/canvas.rs.html#895-932' title='goto source code'>[src]</a></span></h1>
<pre class='rust fn'>pub fn is_functional(version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>, width: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>, x: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>, y: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></pre><div class='docblock'><p>Gets whether the module at the given coordinates represents a functional
module.</p>
</div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,159 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `canvas` mod in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, canvas">
<title>qrcode::canvas - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a></p><script>window.sidebarCurrent = {name: 'canvas', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>qrcode</a>::<wbr><a class='mod' href=''>canvas</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-650' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1-1882' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>The <code>canvas</code> module puts raw bits into the QR code canvas.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::{<span class='ident'>Version</span>, <span class='ident'>EcLevel</span>};
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>canvas</span>::{<span class='ident'>Canvas</span>, <span class='ident'>MaskPattern</span>};
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>Canvas</span>::<span class='ident'>new</span>(<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>), <span class='ident'>EcLevel</span>::<span class='ident'>L</span>);
<span class='ident'>c</span>.<span class='ident'>draw_all_functional_patterns</span>();
<span class='ident'>c</span>.<span class='ident'>draw_data</span>(<span class='string'>b&quot;data_here&quot;</span>, <span class='string'>b&quot;ec_code_here&quot;</span>);
<span class='ident'>c</span>.<span class='ident'>apply_mask</span>(<span class='ident'>MaskPattern</span>::<span class='ident'>Checkerboard</span>);
<span class='kw'>let</span> <span class='ident'>bools</span> <span class='op'>=</span> <span class='ident'>c</span>.<span class='ident'>to_bools</span>();</pre>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class='struct' href='struct.Canvas.html'
title='qrcode::canvas::Canvas'>Canvas</a></td>
<td class='docblock short'>
<p><code>Canvas</code> is an intermediate helper structure to render error-corrected data
into a QR code.</p>
</td>
</tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
<tr class=' module-item'>
<td><a class='enum' href='enum.MaskPattern.html'
title='qrcode::canvas::MaskPattern'>MaskPattern</a></td>
<td class='docblock short'>
<p>The mask patterns. Since QR code and Micro QR code do not use the same
pattern number, we name them according to their shape instead of the number.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='enum' href='enum.Module.html'
title='qrcode::canvas::Module'>Module</a></td>
<td class='docblock short'>
<p>The color of a module (pixel) in the QR code.</p>
</td>
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class='fn' href='fn.is_functional.html'
title='qrcode::canvas::is_functional'>is_functional</a></td>
<td class='docblock short'>
<p>Gets whether the module at the given coordinates represents a functional
module.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1 +0,0 @@
initSidebarItems({});

View file

@ -1 +0,0 @@
initSidebarItems({"enum":[["MaskPattern","The mask patterns. Since QR code and Micro QR code do not use the same pattern number, we name them according to their shape instead of the number."],["Module","The color of a module (pixel) in the QR code."]],"fn":[["is_functional","Gets whether the module at the given coordinates represents a functional module."]],"struct":[["Canvas","`Canvas` is an intermediate helper structure to render error-corrected data into a QR code."]]});

View file

@ -1,156 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Canvas` struct in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Canvas">
<title>qrcode::canvas::Canvas - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a></p><script>window.sidebarCurrent = {name: 'Canvas', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>canvas</a>::<wbr><a class='struct' href=''>Canvas</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-696' class='srclink' href='../../src/qrcode/src/canvas.rs.html#88-101' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Canvas {
// some fields omitted
}</pre><div class='docblock'><p><code>Canvas</code> is an intermediate helper structure to render error-corrected data
into a QR code.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-708' class='srclink' href='../../src/qrcode/src/canvas.rs.html#103-160' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>(version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>, ec_level: <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></h4>
<div class='docblock'><p>Constructs a new canvas big enough for a QR code of the given version.</p>
</div><h4 id='method.get' class='method'><code>fn <a href='#method.get' class='fnname'>get</a>(&amp;self, x: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>, y: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>) -&gt; <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></h4>
<div class='docblock'><p>Obtains a module at the given coordinates. For convenience, negative
coordinates will wrap around.</p>
</div><h4 id='method.get_mut' class='method'><code>fn <a href='#method.get_mut' class='fnname'>get_mut</a>(&amp;mut self, x: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>, y: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>) -&gt; &amp;mut <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a></code></h4>
<div class='docblock'><p>Obtains a mutable module at the given coordinates. For convenience,
negative coordinates will wrap around.</p>
</div><h4 id='method.put' class='method'><code>fn <a href='#method.put' class='fnname'>put</a>(&amp;mut self, x: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>, y: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>, module: <a class='enum' href='../../qrcode/canvas/enum.Module.html' title='qrcode::canvas::Module'>Module</a>)</code></h4>
<div class='docblock'><p>Sets the color of a module at the given coordinates. For convenience,
negative coordinates will wrap around.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-813' class='srclink' href='../../src/qrcode/src/canvas.rs.html#877-891' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.draw_all_functional_patterns' class='method'><code>fn <a href='#method.draw_all_functional_patterns' class='fnname'>draw_all_functional_patterns</a>(&amp;mut self)</code></h4>
<div class='docblock'><p>Draw all functional patterns, before data placement.</p>
<p>All functional patterns (e.g. the finder pattern) <em>except</em> the format
info pattern will be filled in. The format info pattern will be filled
with light modules instead. Data bits can then put in the empty modules.
with <code>.draw_data()</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-848' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1273-1314' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.draw_data' class='method'><code>fn <a href='#method.draw_data' class='fnname'>draw_data</a>(&amp;mut self, data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>, ec: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>)</code></h4>
<div class='docblock'><p>Draws the encoded data and error correction codes to the empty modules.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-933' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1430-1481' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.apply_mask' class='method'><code>fn <a href='#method.apply_mask' class='fnname'>apply_mask</a>(&amp;mut self, pattern: <a class='enum' href='../../qrcode/canvas/enum.MaskPattern.html' title='qrcode::canvas::MaskPattern'>MaskPattern</a>)</code></h4>
<div class='docblock'><p>Applies a mask to the canvas. This method will also draw the format info
patterns.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-1037' class='srclink' href='../../src/qrcode/src/canvas.rs.html#1850-1882' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.apply_best_mask' class='method'><code>fn <a href='#method.apply_best_mask' class='fnname'>apply_best_mask</a>(&amp;self) -&gt; <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></h4>
<div class='docblock'><p>Construct a new canvas and apply the best masking that gives the lowest
penalty score.</p>
</div><h4 id='method.to_bools' class='method'><code>fn <a href='#method.to_bools' class='fnname'>to_bools</a>(&amp;self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>&gt;</code></h4>
<div class='docblock'><p>Convert the modules into a vector of booleans.</p>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-701' class='srclink' href='../../src/qrcode/src/canvas.rs.html#87' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='struct' href='../../qrcode/canvas/struct.Canvas.html' title='qrcode::canvas::Canvas'>Canvas</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,116 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `construct_codewords` fn in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, construct_codewords">
<title>qrcode::ec::construct_codewords - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>ec</a></p><script>window.sidebarCurrent = {name: 'construct_codewords', ty: 'fn', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content fn">
<h1 class='fqn'><span class='in-band'>Function <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>ec</a>::<wbr><a class='fn' href=''>construct_codewords</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-591' class='srclink' href='../../src/qrcode/src/ec.rs.html#101-130' title='goto source code'>[src]</a></span></h1>
<pre class='rust fn'>pub fn construct_codewords(rawbits: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>, version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>, ec_level: <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a><a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>&gt;, <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>&gt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a>&gt;</pre><div class='docblock'><p>Constructs data and error correction codewords ready to be put in the QR
code matrix.</p>
</div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,123 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `create_error_correction_code` fn in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, create_error_correction_code">
<title>qrcode::ec::create_error_correction_code - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>ec</a></p><script>window.sidebarCurrent = {name: 'create_error_correction_code', ty: 'fn', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content fn">
<h1 class='fqn'><span class='in-band'>Function <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>ec</a>::<wbr><a class='fn' href=''>create_error_correction_code</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-572' class='srclink' href='../../src/qrcode/src/ec.rs.html#20-40' title='goto source code'>[src]</a></span></h1>
<pre class='rust fn'>pub fn create_error_correction_code(data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>, ec_code_size: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>&gt;</pre><div class='docblock'><p>Creates the error correction code in N bytes.</p>
<p>This method only supports computing the error-correction code up to
69 bytes. Longer blocks will result in task panic.</p>
<p>This method treats the data as a polynomial of the form
(a[0] x<sup>m+n</sup> + a[1] x<sup>m+n-1</sup> + … + a[m] x<sup>n</sup>) in
GF(256), and then computes the polynomial modulus with a generator
polynomial of degree N.</p>
</div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,116 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `max_allowed_errors` fn in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, max_allowed_errors">
<title>qrcode::ec::max_allowed_errors - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>ec</a></p><script>window.sidebarCurrent = {name: 'max_allowed_errors', ty: 'fn', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content fn">
<h1 class='fqn'><span class='in-band'>Function <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>ec</a>::<wbr><a class='fn' href=''>max_allowed_errors</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-619' class='srclink' href='../../src/qrcode/src/ec.rs.html#162-178' title='goto source code'>[src]</a></span></h1>
<pre class='rust fn'>pub fn max_allowed_errors(version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>, ec_level: <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt;</pre><div class='docblock'><p>Computes the maximum allowed number of erratic modules can be introduced to
the QR code, before the data becomes truly corrupted.</p>
</div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,139 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `ec` mod in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, ec">
<title>qrcode::ec - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a></p><script>window.sidebarCurrent = {name: 'ec', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>qrcode</a>::<wbr><a class='mod' href=''>ec</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-567' class='srclink' href='../../src/qrcode/src/ec.rs.html#1-443' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>The <code>ec</code> module applies the Reed-Solomon error correction codes.</p>
</div><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class='fn' href='fn.construct_codewords.html'
title='qrcode::ec::construct_codewords'>construct_codewords</a></td>
<td class='docblock short'>
<p>Constructs data and error correction codewords ready to be put in the QR
code matrix.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.create_error_correction_code.html'
title='qrcode::ec::create_error_correction_code'>create_error_correction_code</a></td>
<td class='docblock short'>
<p>Creates the error correction code in N bytes.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.max_allowed_errors.html'
title='qrcode::ec::max_allowed_errors'>max_allowed_errors</a></td>
<td class='docblock short'>
<p>Computes the maximum allowed number of erratic modules can be introduced to
the QR code, before the data becomes truly corrupted.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1 +0,0 @@
initSidebarItems({"fn":[["construct_codewords","Constructs data and error correction codewords ready to be put in the QR code matrix."],["create_error_correction_code","Creates the error correction code in N bytes."],["max_allowed_errors","Computes the maximum allowed number of erratic modules can be introduced to the QR code, before the data becomes truly corrupted."]]});

View file

@ -1,187 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `qrcode` crate.">
<meta name="keywords" content="rust, rustlang, rust-lang, qrcode">
<title>qrcode - Rust</title>
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'></p><script>window.sidebarCurrent = {name: 'qrcode', ty: 'mod', relpath: '../'};</script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Crate <a class='mod' href=''>qrcode</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-0' class='srclink' href='../src/qrcode/src/lib.rs.html#1-315' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>QRCode encoder</p>
<p>This crate provides a QR code and Micro QR code encoder for binary data.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>image</span>;
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>qrcode</span>;
<span class='kw'>use</span> <span class='ident'>image</span>::<span class='ident'>GrayImage</span>;
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>QrCode</span>;
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>new</span>(<span class='string'>b&quot;Some content here.&quot;</span>);
<span class='kw'>match</span> <span class='ident'>code</span> {
<span class='prelude-val'>Err</span>(<span class='ident'>err</span>) <span class='op'>=&gt;</span> <span class='macro'>panic</span><span class='macro'>!</span>(<span class='string'>&quot;Failed to encode the QR code: {:?}&quot;</span>, <span class='ident'>err</span>),
<span class='prelude-val'>Ok</span>(<span class='ident'>code</span>) <span class='op'>=&gt;</span> {
<span class='kw'>let</span> <span class='ident'>image</span>: <span class='ident'>GrayImage</span> <span class='op'>=</span> <span class='ident'>code</span>.<span class='ident'>render</span>().<span class='ident'>min_width</span>(<span class='number'>100</span>).<span class='ident'>to_image</span>();
<span class='comment'>// render `image`...</span>
}
}
</pre>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Reexports</a></h2>
<table><tr><td><code>pub use types::{<a class='type' href='../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>, <a class='enum' href='../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>, <a class='enum' href='../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>};</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table>
<tr class=' module-item'>
<td><a class='mod' href='bits/index.html'
title='qrcode::bits'>bits</a></td>
<td class='docblock short'>
<p>The <code>bits</code> module encodes binary data into raw bits used in a QR code.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='mod' href='canvas/index.html'
title='qrcode::canvas'>canvas</a></td>
<td class='docblock short'>
<p>The <code>canvas</code> module puts raw bits into the QR code canvas.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='mod' href='ec/index.html'
title='qrcode::ec'>ec</a></td>
<td class='docblock short'>
<p>The <code>ec</code> module applies the Reed-Solomon error correction codes.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='mod' href='optimize/index.html'
title='qrcode::optimize'>optimize</a></td>
<td class='docblock short'>
<p>Find the optimal data mode sequence to encode a piece of data.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='mod' href='render/index.html'
title='qrcode::render'>render</a></td>
<td class='docblock short'>
<p>Render a QR code into image.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='mod' href='types/index.html'
title='qrcode::types'>types</a></td>
<td class='docblock short'>
</td>
</tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class='struct' href='struct.QrCode.html'
title='qrcode::QrCode'>QrCode</a></td>
<td class='docblock short'>
<p>The encoded QR code symbol.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../jquery.js"></script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>

View file

@ -1,115 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `total_encoded_len` fn in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, total_encoded_len">
<title>qrcode::optimize::total_encoded_len - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a></p><script>window.sidebarCurrent = {name: 'total_encoded_len', ty: 'fn', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content fn">
<h1 class='fqn'><span class='in-band'>Function <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a>::<wbr><a class='fn' href=''>total_encoded_len</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-501' class='srclink' href='../../src/qrcode/src/optimize.rs.html#322-325' title='goto source code'>[src]</a></span></h1>
<pre class='rust fn'>pub fn total_encoded_len(segments: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>, version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></pre><div class='docblock'><p>Computes the total encoded length of all segments.</p>
</div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,145 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `optimize` mod in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, optimize">
<title>qrcode::optimize - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a></p><script>window.sidebarCurrent = {name: 'optimize', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>qrcode</a>::<wbr><a class='mod' href=''>optimize</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-376' class='srclink' href='../../src/qrcode/src/optimize.rs.html#1-675' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>Find the optimal data mode sequence to encode a piece of data.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class='struct' href='struct.Optimizer.html'
title='qrcode::optimize::Optimizer'>Optimizer</a></td>
<td class='docblock short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class='struct' href='struct.Parser.html'
title='qrcode::optimize::Parser'>Parser</a></td>
<td class='docblock short'>
<p>QR code data parser to classify the input into distinct segments.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='struct' href='struct.Segment.html'
title='qrcode::optimize::Segment'>Segment</a></td>
<td class='docblock short'>
<p>A segment of data committed to an encoding mode.</p>
</td>
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class='fn' href='fn.total_encoded_len.html'
title='qrcode::optimize::total_encoded_len'>total_encoded_len</a></td>
<td class='docblock short'>
<p>Computes the total encoded length of all segments.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1 +0,0 @@
initSidebarItems({"fn":[["total_encoded_len","Computes the total encoded length of all segments."]],"struct":[["Optimizer",""],["Parser","QR code data parser to classify the input into distinct segments."],["Segment","A segment of data committed to an encoding mode."]]});

View file

@ -1,220 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Optimizer` struct in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Optimizer">
<title>qrcode::optimize::Optimizer - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a></p><script>window.sidebarCurrent = {name: 'Optimizer', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a>::<wbr><a class='struct' href=''>Optimizer</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-471' class='srclink' href='../../src/qrcode/src/optimize.rs.html#241-247' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Optimizer&lt;I&gt; {
// some fields omitted
}</pre><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl&lt;I:&nbsp;<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a>&lt;Item=<a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a>&gt;&gt; <a class='struct' href='../../qrcode/optimize/struct.Optimizer.html' title='qrcode::optimize::Optimizer'>Optimizer</a>&lt;I&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a id='src-478' class='srclink' href='../../src/qrcode/src/optimize.rs.html#249-274' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>(segments: I, version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='struct' href='../../qrcode/optimize/struct.Optimizer.html' title='qrcode::optimize::Optimizer'>Optimizer</a>&lt;I&gt;</code></h4>
<div class='docblock'><p>Optimize the segments by combining adjacent segments when possible.</p>
<p>Currently this method uses a greedy algorithm by combining segments from
left to right until the new segment is longer than before. This method
does <em>not</em> use Annex J from the ISO standard.</p>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl&lt;I:&nbsp;<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a>&lt;Item=<a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a>&gt;&gt; <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a> for <a class='struct' href='../../qrcode/optimize/struct.Optimizer.html' title='qrcode::optimize::Optimizer'>Optimizer</a>&lt;I&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a id='src-490' class='srclink' href='../../src/qrcode/src/optimize.rs.html#282-319' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='associatedtype.Item' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class='type'>Item</a> = <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></h4>
<div class='docblock'><p>The type of the elements being iterated over.</p>
</div><h4 id='method.next' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#tymethod.next' class='fnname'>next</a>(&amp;mut self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a>&gt;</code></h4>
<div class='docblock'><p>Advances the iterator and returns the next value. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#tymethod.next">Read more</a></p>
</div><h4 id='method.size_hint' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.size_hint' class='fnname'>size_hint</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns the bounds on the remaining length of the iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.size_hint">Read more</a></p>
</div><h4 id='method.count' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.count' class='fnname'>count</a>(self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes the iterator, counting the number of iterations and returning it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.count">Read more</a></p>
</div><h4 id='method.last' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.last' class='fnname'>last</a>(self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes the iterator, returning the last element. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.last">Read more</a></p>
</div><h4 id='method.nth' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.nth' class='fnname'>nth</a>(&amp;mut self, n: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes the <code>n</code> first elements of the iterator, then returns the <code>next()</code> one. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.nth">Read more</a></p>
</div><h4 id='method.chain' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.chain' class='fnname'>chain</a>&lt;U&gt;(self, other: U) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Chain.html' title='core::iter::Chain'>Chain</a>&lt;Self,&nbsp;U::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIter</a>&gt; <span class='where'>where U: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>&lt;Item=Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Takes two iterators and creates a new iterator over both in sequence. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.chain">Read more</a></p>
</div><h4 id='method.zip' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.zip' class='fnname'>zip</a>&lt;U&gt;(self, other: U) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Zip.html' title='core::iter::Zip'>Zip</a>&lt;Self,&nbsp;U::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIter</a>&gt; <span class='where'>where U: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>&#39;Zips up&#39; two iterators into a single iterator of pairs. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.zip">Read more</a></p>
</div><h4 id='method.map' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.map' class='fnname'>map</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Map.html' title='core::iter::Map'>Map</a>&lt;Self,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Takes a closure and creates an iterator which calls that closure on each element. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.map">Read more</a></p>
</div><h4 id='method.filter' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter' class='fnname'>filter</a>&lt;P&gt;(self, predicate: P) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Filter.html' title='core::iter::Filter'>Filter</a>&lt;Self,&nbsp;P&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which uses a closure to determine if an element should be yielded. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter">Read more</a></p>
</div><h4 id='method.filter_map' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter_map' class='fnname'>filter_map</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.FilterMap.html' title='core::iter::FilterMap'>FilterMap</a>&lt;Self,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;B&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that both filters and maps. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter_map">Read more</a></p>
</div><h4 id='method.enumerate' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.enumerate' class='fnname'>enumerate</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Enumerate.html' title='core::iter::Enumerate'>Enumerate</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which gives the current iteration count as well as the next value. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.enumerate">Read more</a></p>
</div><h4 id='method.peekable' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.peekable' class='fnname'>peekable</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Peekable.html' title='core::iter::Peekable'>Peekable</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which can use <code>peek</code> to look at the next element of the iterator without consuming it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.peekable">Read more</a></p>
</div><h4 id='method.skip_while' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip_while' class='fnname'>skip_while</a>&lt;P&gt;(self, predicate: P) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.SkipWhile.html' title='core::iter::SkipWhile'>SkipWhile</a>&lt;Self,&nbsp;P&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that [<code>skip()</code>]s elements based on a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip_while">Read more</a></p>
</div><h4 id='method.take_while' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take_while' class='fnname'>take_while</a>&lt;P&gt;(self, predicate: P) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.TakeWhile.html' title='core::iter::TakeWhile'>TakeWhile</a>&lt;Self,&nbsp;P&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that yields elements based on a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take_while">Read more</a></p>
</div><h4 id='method.skip' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip' class='fnname'>skip</a>(self, n: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Skip.html' title='core::iter::Skip'>Skip</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that skips the first <code>n</code> elements. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip">Read more</a></p>
</div><h4 id='method.take' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take' class='fnname'>take</a>(self, n: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Take.html' title='core::iter::Take'>Take</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that yields its first <code>n</code> elements. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take">Read more</a></p>
</div><h4 id='method.scan' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.scan' class='fnname'>scan</a>&lt;St,&nbsp;B,&nbsp;F&gt;(self, initial_state: St, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Scan.html' title='core::iter::Scan'>Scan</a>&lt;Self,&nbsp;St,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;mut St, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;B&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>An iterator adaptor similar to [<code>fold()</code>] that holds internal state and produces a new iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.scan">Read more</a></p>
</div><h4 id='method.flat_map' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.flat_map' class='fnname'>flat_map</a>&lt;U,&nbsp;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.FlatMap.html' title='core::iter::FlatMap'>FlatMap</a>&lt;Self,&nbsp;U,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; U, U: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that works like map, but flattens nested structure. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.flat_map">Read more</a></p>
</div><h4 id='method.fuse' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fuse' class='fnname'>fuse</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Fuse.html' title='core::iter::Fuse'>Fuse</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which ends after the first <code>None</code>. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fuse">Read more</a></p>
</div><h4 id='method.inspect' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.inspect' class='fnname'>inspect</a>&lt;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Inspect.html' title='core::iter::Inspect'>Inspect</a>&lt;Self,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Do something with each element of an iterator, passing the value on. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.inspect">Read more</a></p>
</div><h4 id='method.by_ref' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.by_ref' class='fnname'>by_ref</a>(&amp;mut self) -&gt; &amp;mut Self</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Borrows an iterator, rather than consuming it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.by_ref">Read more</a></p>
</div><h4 id='method.collect' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.collect' class='fnname'>collect</a>&lt;B&gt;(self) -&gt; B <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.FromIterator.html' title='core::iter::traits::FromIterator'>FromIterator</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Transforms an iterator into a collection. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.collect">Read more</a></p>
</div><h4 id='method.partition' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partition' class='fnname'>partition</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a>B, B<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a> <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html' title='core::default::Default'>Default</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html' title='core::iter::traits::Extend'>Extend</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;, F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes an iterator, creating two collections from it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partition">Read more</a></p>
</div><h4 id='method.fold' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fold' class='fnname'>fold</a>&lt;B,&nbsp;F&gt;(self, init: B, f: F) -&gt; B <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(B, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>An iterator adaptor that applies a function, producing a single, final value. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fold">Read more</a></p>
</div><h4 id='method.all' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.all' class='fnname'>all</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Tests if every element of the iterator matches a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.all">Read more</a></p>
</div><h4 id='method.any' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.any' class='fnname'>any</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Tests if any element of the iterator matches a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.any">Read more</a></p>
</div><h4 id='method.find' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.find' class='fnname'>find</a>&lt;P&gt;(&amp;mut self, predicate: P) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Searches for an element of an iterator that satisfies a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.find">Read more</a></p>
</div><h4 id='method.position' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.position' class='fnname'>position</a>&lt;P&gt;(&amp;mut self, predicate: P) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Searches for an element in an iterator, returning its index. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.position">Read more</a></p>
</div><h4 id='method.rposition' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rposition' class='fnname'>rposition</a>&lt;P&gt;(&amp;mut self, predicate: P) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>, Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.ExactSizeIterator.html' title='core::iter::traits::ExactSizeIterator'>ExactSizeIterator</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.DoubleEndedIterator.html' title='core::iter::traits::DoubleEndedIterator'>DoubleEndedIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Searches for an element in an iterator from the right, returning its index. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rposition">Read more</a></p>
</div><h4 id='method.max' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max' class='fnname'>max</a>(self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns the maximum element of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max">Read more</a></p>
</div><h4 id='method.min' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min' class='fnname'>min</a>(self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns the minimum element of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min">Read more</a></p>
</div><h4 id='method.max_by_key' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max_by_key' class='fnname'>max_by_key</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a>, F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></h4>
<div class='docblock'><p>Returns the element that gives the maximum value from the specified function. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max_by_key">Read more</a></p>
</div><h4 id='method.min_by_key' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min_by_key' class='fnname'>min_by_key</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a>, F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></h4>
<div class='docblock'><p>Returns the element that gives the minimum value from the specified function. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min_by_key">Read more</a></p>
</div><h4 id='method.rev' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rev' class='fnname'>rev</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Rev.html' title='core::iter::Rev'>Rev</a>&lt;Self&gt; <span class='where'>where Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.DoubleEndedIterator.html' title='core::iter::traits::DoubleEndedIterator'>DoubleEndedIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Reverses an iterator&#39;s direction. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rev">Read more</a></p>
</div><h4 id='method.unzip' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.unzip' class='fnname'>unzip</a>&lt;A,&nbsp;B,&nbsp;FromA,&nbsp;FromB&gt;(self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a>FromA, FromB<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a> <span class='where'>where FromA: <a class='trait' href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html' title='core::default::Default'>Default</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html' title='core::iter::traits::Extend'>Extend</a>&lt;A&gt;, FromB: <a class='trait' href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html' title='core::default::Default'>Default</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html' title='core::iter::traits::Extend'>Extend</a>&lt;B&gt;, Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a>&lt;Item=<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a>A, B<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Converts an iterator of pairs into a pair of containers. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.unzip">Read more</a></p>
</div><h4 id='method.cloned' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cloned' class='fnname'>cloned</a>&lt;'a,&nbsp;T&gt;(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Cloned.html' title='core::iter::Cloned'>Cloned</a>&lt;Self&gt; <span class='where'>where Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a>&lt;Item=&amp;'a T&gt;, T: 'a + <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which <code>clone()</code>s all of its elements. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cloned">Read more</a></p>
</div><h4 id='method.cycle' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cycle' class='fnname'>cycle</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Cycle.html' title='core::iter::Cycle'>Cycle</a>&lt;Self&gt; <span class='where'>where Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Repeats an iterator endlessly. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cycle">Read more</a></p>
</div><h4 id='method.sum' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.sum' class='fnname'>sum</a>&lt;S&gt;(self) -&gt; S <span class='where'>where S: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Add.html' title='core::ops::Add'>Add</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>,&nbsp;Output=S&gt; + <a class='trait' href='https://doc.rust-lang.org/nightly/core/num/trait.Zero.html' title='core::num::Zero'>Zero</a></span></code></h4>
<div class='docblock'><p>Sums the elements of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.sum">Read more</a></p>
</div><h4 id='method.product' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.product' class='fnname'>product</a>&lt;P&gt;(self) -&gt; P <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Mul.html' title='core::ops::Mul'>Mul</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>,&nbsp;Output=P&gt; + <a class='trait' href='https://doc.rust-lang.org/nightly/core/num/trait.One.html' title='core::num::One'>One</a></span></code></h4>
<div class='docblock'><p>Iterates over the entire iterator, multiplying all the elements <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.product">Read more</a></p>
</div><h4 id='method.cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cmp' class='fnname'>cmp</a>&lt;I&gt;(self, other: I) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>&lt;Item=Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a></span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Lexicographically compares the elements of this <code>Iterator</code> with those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cmp">Read more</a></p>
</div><h4 id='method.partial_cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partial_cmp' class='fnname'>partial_cmp</a>&lt;I&gt;(self, other: I) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a>&gt; <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Lexicographically compares the elements of this <code>Iterator</code> with those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partial_cmp">Read more</a></p>
</div><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.eq' class='fnname'>eq</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are equal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ne' class='fnname'>ne</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are unequal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ne">Read more</a></p>
</div><h4 id='method.lt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.lt' class='fnname'>lt</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically less than those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.lt">Read more</a></p>
</div><h4 id='method.le' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.le' class='fnname'>le</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically less or equal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.le">Read more</a></p>
</div><h4 id='method.gt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.gt' class='fnname'>gt</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically greater than those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.gt">Read more</a></p>
</div><h4 id='method.ge' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ge' class='fnname'>ge</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically greater than or equal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ge">Read more</a></p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,229 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Parser` struct in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Parser">
<title>qrcode::optimize::Parser - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a></p><script>window.sidebarCurrent = {name: 'Parser', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a>::<wbr><a class='struct' href=''>Parser</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-447' class='srclink' href='../../src/qrcode/src/optimize.rs.html#82-87' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Parser&lt;'a&gt; {
// some fields omitted
}</pre><div class='docblock'><p>QR code data parser to classify the input into distinct segments.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl&lt;'a&gt; <a class='struct' href='../../qrcode/optimize/struct.Parser.html' title='qrcode::optimize::Parser'>Parser</a>&lt;'a&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a id='src-453' class='srclink' href='../../src/qrcode/src/optimize.rs.html#89-109' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>(data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='struct' href='../../qrcode/optimize/struct.Parser.html' title='qrcode::optimize::Parser'>Parser</a></code></h4>
<div class='docblock'><p>Creates a new iterator which parse the data into segments that only
contains their exclusive subsets. No optimization is done at this point.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>optimize</span>::{<span class='ident'>Parser</span>, <span class='ident'>Segment</span>};
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::<span class='ident'>Mode</span>::{<span class='ident'>Alphanumeric</span>, <span class='ident'>Numeric</span>, <span class='ident'>Byte</span>};
<span class='kw'>let</span> <span class='ident'>parse_res</span> <span class='op'>=</span> <span class='ident'>Parser</span>::<span class='ident'>new</span>(<span class='string'>b&quot;ABC123abcd&quot;</span>).<span class='ident'>collect</span>::<span class='op'>&lt;</span><span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>Segment</span><span class='op'>&gt;&gt;</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>parse_res</span>, <span class='macro'>vec</span><span class='macro'>!</span>[<span class='ident'>Segment</span> { <span class='ident'>mode</span>: <span class='ident'>Alphanumeric</span>, <span class='ident'>begin</span>: <span class='number'>0</span>, <span class='ident'>end</span>: <span class='number'>3</span> },
<span class='ident'>Segment</span> { <span class='ident'>mode</span>: <span class='ident'>Numeric</span>, <span class='ident'>begin</span>: <span class='number'>3</span>, <span class='ident'>end</span>: <span class='number'>6</span> },
<span class='ident'>Segment</span> { <span class='ident'>mode</span>: <span class='ident'>Byte</span>, <span class='ident'>begin</span>: <span class='number'>6</span>, <span class='ident'>end</span>: <span class='number'>10</span> }]);</pre>
</div></div><h3 class='impl'><span class='in-band'><code>impl&lt;'a&gt; <a class='struct' href='../../qrcode/optimize/struct.Parser.html' title='qrcode::optimize::Parser'>Parser</a>&lt;'a&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a id='src-485' class='srclink' href='../../src/qrcode/src/optimize.rs.html#276-280' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.optimize' class='method'><code>fn <a href='#method.optimize' class='fnname'>optimize</a>(self, version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='struct' href='../../qrcode/optimize/struct.Optimizer.html' title='qrcode::optimize::Optimizer'>Optimizer</a>&lt;<a class='struct' href='../../qrcode/optimize/struct.Parser.html' title='qrcode::optimize::Parser'>Parser</a>&lt;'a&gt;&gt;</code></h4>
</div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl&lt;'a&gt; <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a> for <a class='struct' href='../../qrcode/optimize/struct.Parser.html' title='qrcode::optimize::Parser'>Parser</a>&lt;'a&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a id='src-457' class='srclink' href='../../src/qrcode/src/optimize.rs.html#111-164' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='associatedtype.Item' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class='type'>Item</a> = <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></h4>
<div class='docblock'><p>The type of the elements being iterated over.</p>
</div><h4 id='method.next' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#tymethod.next' class='fnname'>next</a>(&amp;mut self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a>&gt;</code></h4>
<div class='docblock'><p>Advances the iterator and returns the next value. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#tymethod.next">Read more</a></p>
</div><h4 id='method.size_hint' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.size_hint' class='fnname'>size_hint</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns the bounds on the remaining length of the iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.size_hint">Read more</a></p>
</div><h4 id='method.count' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.count' class='fnname'>count</a>(self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes the iterator, counting the number of iterations and returning it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.count">Read more</a></p>
</div><h4 id='method.last' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.last' class='fnname'>last</a>(self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes the iterator, returning the last element. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.last">Read more</a></p>
</div><h4 id='method.nth' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.nth' class='fnname'>nth</a>(&amp;mut self, n: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes the <code>n</code> first elements of the iterator, then returns the <code>next()</code> one. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.nth">Read more</a></p>
</div><h4 id='method.chain' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.chain' class='fnname'>chain</a>&lt;U&gt;(self, other: U) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Chain.html' title='core::iter::Chain'>Chain</a>&lt;Self,&nbsp;U::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIter</a>&gt; <span class='where'>where U: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>&lt;Item=Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Takes two iterators and creates a new iterator over both in sequence. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.chain">Read more</a></p>
</div><h4 id='method.zip' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.zip' class='fnname'>zip</a>&lt;U&gt;(self, other: U) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Zip.html' title='core::iter::Zip'>Zip</a>&lt;Self,&nbsp;U::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIter</a>&gt; <span class='where'>where U: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>&#39;Zips up&#39; two iterators into a single iterator of pairs. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.zip">Read more</a></p>
</div><h4 id='method.map' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.map' class='fnname'>map</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Map.html' title='core::iter::Map'>Map</a>&lt;Self,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Takes a closure and creates an iterator which calls that closure on each element. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.map">Read more</a></p>
</div><h4 id='method.filter' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter' class='fnname'>filter</a>&lt;P&gt;(self, predicate: P) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Filter.html' title='core::iter::Filter'>Filter</a>&lt;Self,&nbsp;P&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which uses a closure to determine if an element should be yielded. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter">Read more</a></p>
</div><h4 id='method.filter_map' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter_map' class='fnname'>filter_map</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.FilterMap.html' title='core::iter::FilterMap'>FilterMap</a>&lt;Self,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;B&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that both filters and maps. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.filter_map">Read more</a></p>
</div><h4 id='method.enumerate' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.enumerate' class='fnname'>enumerate</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Enumerate.html' title='core::iter::Enumerate'>Enumerate</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which gives the current iteration count as well as the next value. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.enumerate">Read more</a></p>
</div><h4 id='method.peekable' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.peekable' class='fnname'>peekable</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Peekable.html' title='core::iter::Peekable'>Peekable</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which can use <code>peek</code> to look at the next element of the iterator without consuming it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.peekable">Read more</a></p>
</div><h4 id='method.skip_while' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip_while' class='fnname'>skip_while</a>&lt;P&gt;(self, predicate: P) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.SkipWhile.html' title='core::iter::SkipWhile'>SkipWhile</a>&lt;Self,&nbsp;P&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that [<code>skip()</code>]s elements based on a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip_while">Read more</a></p>
</div><h4 id='method.take_while' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take_while' class='fnname'>take_while</a>&lt;P&gt;(self, predicate: P) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.TakeWhile.html' title='core::iter::TakeWhile'>TakeWhile</a>&lt;Self,&nbsp;P&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that yields elements based on a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take_while">Read more</a></p>
</div><h4 id='method.skip' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip' class='fnname'>skip</a>(self, n: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Skip.html' title='core::iter::Skip'>Skip</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that skips the first <code>n</code> elements. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.skip">Read more</a></p>
</div><h4 id='method.take' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take' class='fnname'>take</a>(self, n: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Take.html' title='core::iter::Take'>Take</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that yields its first <code>n</code> elements. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.take">Read more</a></p>
</div><h4 id='method.scan' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.scan' class='fnname'>scan</a>&lt;St,&nbsp;B,&nbsp;F&gt;(self, initial_state: St, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Scan.html' title='core::iter::Scan'>Scan</a>&lt;Self,&nbsp;St,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;mut St, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;B&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>An iterator adaptor similar to [<code>fold()</code>] that holds internal state and produces a new iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.scan">Read more</a></p>
</div><h4 id='method.flat_map' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.flat_map' class='fnname'>flat_map</a>&lt;U,&nbsp;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.FlatMap.html' title='core::iter::FlatMap'>FlatMap</a>&lt;Self,&nbsp;U,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; U, U: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator that works like map, but flattens nested structure. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.flat_map">Read more</a></p>
</div><h4 id='method.fuse' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fuse' class='fnname'>fuse</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Fuse.html' title='core::iter::Fuse'>Fuse</a>&lt;Self&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which ends after the first <code>None</code>. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fuse">Read more</a></p>
</div><h4 id='method.inspect' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.inspect' class='fnname'>inspect</a>&lt;F&gt;(self, f: F) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Inspect.html' title='core::iter::Inspect'>Inspect</a>&lt;Self,&nbsp;F&gt; <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Do something with each element of an iterator, passing the value on. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.inspect">Read more</a></p>
</div><h4 id='method.by_ref' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.by_ref' class='fnname'>by_ref</a>(&amp;mut self) -&gt; &amp;mut Self</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Borrows an iterator, rather than consuming it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.by_ref">Read more</a></p>
</div><h4 id='method.collect' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.collect' class='fnname'>collect</a>&lt;B&gt;(self) -&gt; B <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.FromIterator.html' title='core::iter::traits::FromIterator'>FromIterator</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Transforms an iterator into a collection. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.collect">Read more</a></p>
</div><h4 id='method.partition' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partition' class='fnname'>partition</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a>B, B<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a> <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html' title='core::default::Default'>Default</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html' title='core::iter::traits::Extend'>Extend</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;, F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Consumes an iterator, creating two collections from it. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partition">Read more</a></p>
</div><h4 id='method.fold' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fold' class='fnname'>fold</a>&lt;B,&nbsp;F&gt;(self, init: B, f: F) -&gt; B <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(B, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>An iterator adaptor that applies a function, producing a single, final value. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.fold">Read more</a></p>
</div><h4 id='method.all' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.all' class='fnname'>all</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Tests if every element of the iterator matches a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.all">Read more</a></p>
</div><h4 id='method.any' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.any' class='fnname'>any</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Tests if any element of the iterator matches a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.any">Read more</a></p>
</div><h4 id='method.find' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.find' class='fnname'>find</a>&lt;P&gt;(&amp;mut self, predicate: P) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Searches for an element of an iterator that satisfies a predicate. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.find">Read more</a></p>
</div><h4 id='method.position' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.position' class='fnname'>position</a>&lt;P&gt;(&amp;mut self, predicate: P) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Searches for an element in an iterator, returning its index. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.position">Read more</a></p>
</div><h4 id='method.rposition' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rposition' class='fnname'>rposition</a>&lt;P&gt;(&amp;mut self, predicate: P) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt; <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>, Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.ExactSizeIterator.html' title='core::iter::traits::ExactSizeIterator'>ExactSizeIterator</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.DoubleEndedIterator.html' title='core::iter::traits::DoubleEndedIterator'>DoubleEndedIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Searches for an element in an iterator from the right, returning its index. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rposition">Read more</a></p>
</div><h4 id='method.max' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max' class='fnname'>max</a>(self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns the maximum element of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max">Read more</a></p>
</div><h4 id='method.min' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min' class='fnname'>min</a>(self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns the minimum element of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min">Read more</a></p>
</div><h4 id='method.max_by_key' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max_by_key' class='fnname'>max_by_key</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a>, F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></h4>
<div class='docblock'><p>Returns the element that gives the maximum value from the specified function. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.max_by_key">Read more</a></p>
</div><h4 id='method.min_by_key' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min_by_key' class='fnname'>min_by_key</a>&lt;B,&nbsp;F&gt;(self, f: F) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt; <span class='where'>where B: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a>, F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&amp;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>) -&gt; B</span></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></h4>
<div class='docblock'><p>Returns the element that gives the minimum value from the specified function. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.min_by_key">Read more</a></p>
</div><h4 id='method.rev' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rev' class='fnname'>rev</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Rev.html' title='core::iter::Rev'>Rev</a>&lt;Self&gt; <span class='where'>where Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.DoubleEndedIterator.html' title='core::iter::traits::DoubleEndedIterator'>DoubleEndedIterator</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Reverses an iterator&#39;s direction. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.rev">Read more</a></p>
</div><h4 id='method.unzip' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.unzip' class='fnname'>unzip</a>&lt;A,&nbsp;B,&nbsp;FromA,&nbsp;FromB&gt;(self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a>FromA, FromB<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a> <span class='where'>where FromA: <a class='trait' href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html' title='core::default::Default'>Default</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html' title='core::iter::traits::Extend'>Extend</a>&lt;A&gt;, FromB: <a class='trait' href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html' title='core::default::Default'>Default</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html' title='core::iter::traits::Extend'>Extend</a>&lt;B&gt;, Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a>&lt;Item=<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a>A, B<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Converts an iterator of pairs into a pair of containers. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.unzip">Read more</a></p>
</div><h4 id='method.cloned' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cloned' class='fnname'>cloned</a>&lt;'a,&nbsp;T&gt;(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Cloned.html' title='core::iter::Cloned'>Cloned</a>&lt;Self&gt; <span class='where'>where Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Iterator</a>&lt;Item=&amp;'a T&gt;, T: 'a + <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Creates an iterator which <code>clone()</code>s all of its elements. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cloned">Read more</a></p>
</div><h4 id='method.cycle' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cycle' class='fnname'>cycle</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/core/iter/struct.Cycle.html' title='core::iter::Cycle'>Cycle</a>&lt;Self&gt; <span class='where'>where Self: <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a></span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Repeats an iterator endlessly. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cycle">Read more</a></p>
</div><h4 id='method.sum' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.sum' class='fnname'>sum</a>&lt;S&gt;(self) -&gt; S <span class='where'>where S: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Add.html' title='core::ops::Add'>Add</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>,&nbsp;Output=S&gt; + <a class='trait' href='https://doc.rust-lang.org/nightly/core/num/trait.Zero.html' title='core::num::Zero'>Zero</a></span></code></h4>
<div class='docblock'><p>Sums the elements of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.sum">Read more</a></p>
</div><h4 id='method.product' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.product' class='fnname'>product</a>&lt;P&gt;(self) -&gt; P <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Mul.html' title='core::ops::Mul'>Mul</a>&lt;Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>,&nbsp;Output=P&gt; + <a class='trait' href='https://doc.rust-lang.org/nightly/core/num/trait.One.html' title='core::num::One'>One</a></span></code></h4>
<div class='docblock'><p>Iterates over the entire iterator, multiplying all the elements <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.product">Read more</a></p>
</div><h4 id='method.cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cmp' class='fnname'>cmp</a>&lt;I&gt;(self, other: I) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>&lt;Item=Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>&gt;, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a></span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Lexicographically compares the elements of this <code>Iterator</code> with those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.cmp">Read more</a></p>
</div><h4 id='method.partial_cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partial_cmp' class='fnname'>partial_cmp</a>&lt;I&gt;(self, other: I) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a>&gt; <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Lexicographically compares the elements of this <code>Iterator</code> with those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.partial_cmp">Read more</a></p>
</div><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.eq' class='fnname'>eq</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are equal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ne' class='fnname'>ne</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are unequal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ne">Read more</a></p>
</div><h4 id='method.lt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.lt' class='fnname'>lt</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically less than those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.lt">Read more</a></p>
</div><h4 id='method.le' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.le' class='fnname'>le</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically less or equal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.le">Read more</a></p>
</div><h4 id='method.gt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.gt' class='fnname'>gt</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically greater than those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.gt">Read more</a></p>
</div><h4 id='method.ge' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ge' class='fnname'>ge</a>&lt;I&gt;(self, other: I) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a> <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, Self::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html' title='core::iter::iterator::Iterator'>Item</a>: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a>&lt;I::<a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>Item</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></h4>
<div class='docblock'><p>Determines if the elements of this <code>Iterator</code> are lexicographically greater than or equal to those of another. <a href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#method.ge">Read more</a></p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,144 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Segment` struct in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Segment">
<title>qrcode::optimize::Segment - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a></p><script>window.sidebarCurrent = {name: 'Segment', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>optimize</a>::<wbr><a class='struct' href=''>Segment</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-380' class='srclink' href='../../src/qrcode/src/optimize.rs.html#13-22' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Segment {
pub mode: <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a>,
pub begin: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>,
pub end: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>,
}</pre><div class='docblock'><p>A segment of data committed to an encoding mode.</p>
</div><h2 class='fields'>Fields</h2><span id='structfield.mode'><code>mode: <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span>
<span class='stab '></span><div class='docblock'><p>The encoding mode of the segment of data.</p>
</div><span id='structfield.begin'><code>begin: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></span>
<span class='stab '></span><div class='docblock'><p>The start index of the segment.</p>
</div><span id='structfield.end'><code>end: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></span>
<span class='stab '></span><div class='docblock'><p>The end index (exclusive) of the segment.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-424' class='srclink' href='../../src/qrcode/src/optimize.rs.html#24-37' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.encoded_len' class='method'><code>fn <a href='#method.encoded_len' class='fnname'>encoded_len</a>(&amp;self, version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Compute the number of bits (including the size of the mode indicator and
length bits) when this segment is encoded.</p>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-384' class='srclink' href='../../src/qrcode/src/optimize.rs.html#12' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-390' class='srclink' href='../../src/qrcode/src/optimize.rs.html#12' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-391' class='srclink' href='../../src/qrcode/src/optimize.rs.html#12' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-399' class='srclink' href='../../src/qrcode/src/optimize.rs.html#12' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-405' class='srclink' href='../../src/qrcode/src/optimize.rs.html#12' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../qrcode/optimize/struct.Segment.html' title='qrcode::optimize::Segment'>Segment</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,132 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `render` mod in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, render">
<title>qrcode::render - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a></p><script>window.sidebarCurrent = {name: 'render', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>qrcode</a>::<wbr><a class='mod' href=''>render</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-1053' class='srclink' href='../../src/qrcode/src/render.rs.html#1-220' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>Render a QR code into image.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class='struct' href='struct.Renderer.html'
title='qrcode::render::Renderer'>Renderer</a></td>
<td class='docblock short'>
<p>A QR code renderer. This is a builder type which converts a bool-vector into
an image.</p>
</td>
</tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table>
<tr class=' module-item'>
<td><a class='trait' href='trait.BlankAndWhitePixel.html'
title='qrcode::render::BlankAndWhitePixel'>BlankAndWhitePixel</a></td>
<td class='docblock short'>
<p>A pixel which can support black and white colors.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1 +0,0 @@
initSidebarItems({"struct":[["Renderer","A QR code renderer. This is a builder type which converts a bool-vector into an image."]],"trait":[["BlankAndWhitePixel","A pixel which can support black and white colors."]]});

View file

@ -1,140 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Renderer` struct in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Renderer">
<title>qrcode::render::Renderer - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>render</a></p><script>window.sidebarCurrent = {name: 'Renderer', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>render</a>::<wbr><a class='struct' href=''>Renderer</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-1079' class='srclink' href='../../src/qrcode/src/render.rs.html#55-64' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Renderer&lt;'a,&nbsp;P:&nbsp;<a class='trait' href='../../qrcode/render/trait.BlankAndWhitePixel.html' title='qrcode::render::BlankAndWhitePixel'>BlankAndWhitePixel</a>&gt; {
// some fields omitted
}</pre><div class='docblock'><p>A QR code renderer. This is a builder type which converts a bool-vector into
an image.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl&lt;'a,&nbsp;P:&nbsp;<a class='trait' href='../../qrcode/render/trait.BlankAndWhitePixel.html' title='qrcode::render::BlankAndWhitePixel'>BlankAndWhitePixel</a> + 'static&gt; <a class='struct' href='../../qrcode/render/struct.Renderer.html' title='qrcode::render::Renderer'>Renderer</a>&lt;'a,&nbsp;P&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a id='src-1089' class='srclink' href='../../src/qrcode/src/render.rs.html#66-150' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>(content: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;'a [</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>, modules_count: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, quiet_zone: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u32.html'>u32</a>) -&gt; <a class='struct' href='../../qrcode/render/struct.Renderer.html' title='qrcode::render::Renderer'>Renderer</a>&lt;'a,&nbsp;P&gt;</code></h4>
<div class='docblock'><p>Creates a new renderer.</p>
</div><h4 id='method.dark_color' class='method'><code>fn <a href='#method.dark_color' class='fnname'>dark_color</a>(&amp;mut self, color: P) -&gt; &amp;mut Self</code></h4>
<div class='docblock'><p>Sets color of a dark module. Default is opaque black.</p>
</div><h4 id='method.light_color' class='method'><code>fn <a href='#method.light_color' class='fnname'>light_color</a>(&amp;mut self, color: P) -&gt; &amp;mut Self</code></h4>
<div class='docblock'><p>Sets color of a light module. Default is opaque white.</p>
</div><h4 id='method.quiet_zone' class='method'><code>fn <a href='#method.quiet_zone' class='fnname'>quiet_zone</a>(&amp;mut self, has_quiet_zone: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>) -&gt; &amp;mut Self</code></h4>
<div class='docblock'><p>Whether to include the quiet zone in the generated image.</p>
</div><h4 id='method.module_size' class='method'><code>fn <a href='#method.module_size' class='fnname'>module_size</a>(&amp;mut self, size: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u32.html'>u32</a>) -&gt; &amp;mut Self</code></h4>
<div class='docblock'><p>Sets the size of each module in pixels. Default is 8px.</p>
</div><h4 id='method.min_width' class='method'><code>fn <a href='#method.min_width' class='fnname'>min_width</a>(&amp;mut self, width: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u32.html'>u32</a>) -&gt; &amp;mut Self</code></h4>
<div class='docblock'><p>Sets the minimal total image width (and thus height) in pixels,
including the quiet zone if applicable. The renderer will try to find
the dimension as small as possible, such that each module in the QR code
has uniform size (no distortion).</p>
<p>For instance, a version 1 QR code has 19 modules across including the
quiet zone. If we request an image of width ≥200px, we get that each
module&#39;s size should be 11px, so the actual image size will be 209px.</p>
</div><h4 id='method.to_image' class='method'><code>fn <a href='#method.to_image' class='fnname'>to_image</a>(&amp;self) -&gt; <a class='struct' href='../../image/buffer/struct.ImageBuffer.html' title='image::buffer::ImageBuffer'>ImageBuffer</a>&lt;P,&nbsp;<a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;P::Subpixel&gt;&gt;</code></h4>
<div class='docblock'><p>Renders the QR code into an image.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,130 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `BlankAndWhitePixel` trait in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, BlankAndWhitePixel">
<title>qrcode::render::BlankAndWhitePixel - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>render</a></p><script>window.sidebarCurrent = {name: 'BlankAndWhitePixel', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content trait">
<h1 class='fqn'><span class='in-band'>Trait <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>render</a>::<wbr><a class='trait' href=''>BlankAndWhitePixel</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-1056' class='srclink' href='../../src/qrcode/src/render.rs.html#8-11' title='goto source code'>[src]</a></span></h1>
<pre class='rust trait'>pub trait BlankAndWhitePixel: <a class='trait' href='../../image/buffer/trait.Pixel.html' title='image::buffer::Pixel'>Pixel</a> {
fn <a href='#tymethod.black_color' class='fnname'>black_color</a>() -&gt; Self;
fn <a href='#tymethod.white_color' class='fnname'>white_color</a>() -&gt; Self;
}</pre><div class='docblock'><p>A pixel which can support black and white colors.</p>
</div>
<h2 id='required-methods'>Required Methods</h2>
<div class='methods'>
<h3 id='tymethod.black_color' class='method stab '><code>fn <a href='#tymethod.black_color' class='fnname'>black_color</a>() -&gt; Self</code></h3><h3 id='tymethod.white_color' class='method stab '><code>fn <a href='#tymethod.white_color' class='fnname'>white_color</a>() -&gt; Self</code></h3></div>
<h2 id='implementors'>Implementors</h2>
<ul class='item-list' id='implementors-list'>
<li><code>impl&lt;S:&nbsp;<a class='trait' href='../../image/traits/trait.Primitive.html' title='image::traits::Primitive'>Primitive</a> + 'static&gt; BlankAndWhitePixel for <a class='struct' href='../../image/color/struct.Rgb.html' title='image::color::Rgb'>Rgb</a>&lt;S&gt;</code></li>
<li><code>impl&lt;S:&nbsp;<a class='trait' href='../../image/traits/trait.Primitive.html' title='image::traits::Primitive'>Primitive</a> + 'static&gt; BlankAndWhitePixel for <a class='struct' href='../../image/color/struct.Rgba.html' title='image::color::Rgba'>Rgba</a>&lt;S&gt;</code></li>
<li><code>impl&lt;S:&nbsp;<a class='trait' href='../../image/traits/trait.Primitive.html' title='image::traits::Primitive'>Primitive</a> + 'static&gt; BlankAndWhitePixel for <a class='struct' href='../../image/color/struct.Luma.html' title='image::color::Luma'>Luma</a>&lt;S&gt;</code></li>
<li><code>impl&lt;S:&nbsp;<a class='trait' href='../../image/traits/trait.Primitive.html' title='image::traits::Primitive'>Primitive</a> + 'static&gt; BlankAndWhitePixel for <a class='struct' href='../../image/color/struct.LumaA.html' title='image::color::LumaA'>LumaA</a>&lt;S&gt;</code></li>
</ul><script type="text/javascript" async
src="../../implementors/qrcode/render/trait.BlankAndWhitePixel.js">
</script></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1 +0,0 @@
initSidebarItems({"mod":[["bits","The `bits` module encodes binary data into raw bits used in a QR code."],["canvas","The `canvas` module puts raw bits into the QR code canvas."],["ec","The `ec` module applies the Reed-Solomon error correction codes."],["optimize","Find the optimal data mode sequence to encode a piece of data."],["render","Render a QR code into image."],["types",""]],"struct":[["QrCode","The encoded QR code symbol."]]});

View file

@ -1,230 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `QrCode` struct in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, QrCode">
<title>qrcode::QrCode - Rust</title>
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='index.html'>qrcode</a></p><script>window.sidebarCurrent = {name: 'QrCode', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>qrcode</a>::<wbr><a class='struct' href=''>QrCode</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-1132' class='srclink' href='../src/qrcode/src/lib.rs.html#48-53' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct QrCode {
// some fields omitted
}</pre><div class='docblock'><p>The encoded QR code symbol.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-1144' class='srclink' href='../src/qrcode/src/lib.rs.html#55-227' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>&lt;D:&nbsp;<a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>&gt;&gt;(data: D) -&gt; <a class='type' href='../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a>&gt;</code></h4>
<div class='docblock'><p>Constructs a new QR code which automatically encodes the given data.</p>
<p>This method uses the &quot;medium&quot; error correction level and automatically
chooses the smallest QR code.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>QrCode</span>;
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>new</span>(<span class='string'>b&quot;Some data&quot;</span>).<span class='ident'>unwrap</span>();</pre>
</div><h4 id='method.with_error_correction_level' class='method'><code>fn <a href='#method.with_error_correction_level' class='fnname'>with_error_correction_level</a>&lt;D:&nbsp;<a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>&gt;&gt;(data: D, ec_level: <a class='enum' href='../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a>&gt;</code></h4>
<div class='docblock'><p>Constructs a new QR code which automatically encodes the given data at a
specific error correction level.</p>
<p>This method automatically chooses the smallest QR code.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::{<span class='ident'>QrCode</span>, <span class='ident'>EcLevel</span>};
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>with_error_correction_level</span>(<span class='string'>b&quot;Some data&quot;</span>, <span class='ident'>EcLevel</span>::<span class='ident'>H</span>).<span class='ident'>unwrap</span>();</pre>
</div><h4 id='method.with_version' class='method'><code>fn <a href='#method.with_version' class='fnname'>with_version</a>&lt;D:&nbsp;<a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>&gt;&gt;(data: D, version: <a class='enum' href='../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>, ec_level: <a class='enum' href='../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a>&gt;</code></h4>
<div class='docblock'><p>Constructs a new QR code for the given version and error correction
level.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::{<span class='ident'>QrCode</span>, <span class='ident'>Version</span>, <span class='ident'>EcLevel</span>};
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>with_version</span>(<span class='string'>b&quot;Some data&quot;</span>, <span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>5</span>), <span class='ident'>EcLevel</span>::<span class='ident'>M</span>).<span class='ident'>unwrap</span>();</pre>
<p>This method can also be used to generate Micro QR code.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::{<span class='ident'>QrCode</span>, <span class='ident'>Version</span>, <span class='ident'>EcLevel</span>};
<span class='kw'>let</span> <span class='ident'>micro_code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>with_version</span>(<span class='string'>b&quot;123&quot;</span>, <span class='ident'>Version</span>::<span class='ident'>Micro</span>(<span class='number'>1</span>), <span class='ident'>EcLevel</span>::<span class='ident'>L</span>).<span class='ident'>unwrap</span>();</pre>
</div><h4 id='method.with_bits' class='method'><code>fn <a href='#method.with_bits' class='fnname'>with_bits</a>(bits: <a class='struct' href='../qrcode/bits/struct.Bits.html' title='qrcode::bits::Bits'>Bits</a>, ec_level: <a class='enum' href='../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='type' href='../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;<a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a>&gt;</code></h4>
<div class='docblock'><p>Constructs a new QR code with encoded bits.</p>
<p>Use this method only if there are very special need to manipulate the
raw bits before encoding. Some examples are:</p>
<ul>
<li>Encode data using specific character set with ECI</li>
<li>Use the FNC1 modes</li>
<li>Avoid the optimal segmentation algorithm</li>
</ul>
<p>See the <code>Bits</code> structure for detail.</p>
<pre class='rust rust-example-rendered'>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>allow</span>(<span class='ident'>unused_must_use</span>)]</span>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::{<span class='ident'>QrCode</span>, <span class='ident'>Version</span>, <span class='ident'>EcLevel</span>};
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>bits</span>::<span class='ident'>Bits</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>bits</span> <span class='op'>=</span> <span class='ident'>Bits</span>::<span class='ident'>new</span>(<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>));
<span class='ident'>bits</span>.<span class='ident'>push_eci_designator</span>(<span class='number'>9</span>);
<span class='ident'>bits</span>.<span class='ident'>push_byte_data</span>(<span class='string'>b&quot;\xca\xfe\xe4\xe9\xea\xe1\xf2 QR&quot;</span>);
<span class='ident'>bits</span>.<span class='ident'>push_terminator</span>(<span class='ident'>EcLevel</span>::<span class='ident'>L</span>);
<span class='kw'>let</span> <span class='ident'>qrcode</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>with_bits</span>(<span class='ident'>bits</span>, <span class='ident'>EcLevel</span>::<span class='ident'>L</span>);</pre>
</div><h4 id='method.version' class='method'><code>fn <a href='#method.version' class='fnname'>version</a>(&amp;self) -&gt; <a class='enum' href='../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></h4>
<div class='docblock'><p>Gets the version of this QR code.</p>
</div><h4 id='method.error_correction_level' class='method'><code>fn <a href='#method.error_correction_level' class='fnname'>error_correction_level</a>(&amp;self) -&gt; <a class='enum' href='../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></h4>
<div class='docblock'><p>Gets the error correction level of this QR code.</p>
</div><h4 id='method.width' class='method'><code>fn <a href='#method.width' class='fnname'>width</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Gets the number of modules per side, i.e. the width of this QR code.</p>
<p>The width here does not contain the quiet zone paddings.</p>
</div><h4 id='method.max_allowed_errors' class='method'><code>fn <a href='#method.max_allowed_errors' class='fnname'>max_allowed_errors</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Gets the maximum number of allowed erratic modules can be introduced
before the data becomes corrupted. Note that errors should not be
introduced to functional modules.</p>
</div><h4 id='method.is_functional' class='method'><code>fn <a href='#method.is_functional' class='fnname'>is_functional</a>(&amp;self, x: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, y: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Checks whether a module at coordinate (x, y) is a functional module or
not.</p>
</div><h4 id='method.to_debug_str' class='method'><code>fn <a href='#method.to_debug_str' class='fnname'>to_debug_str</a>(&amp;self, on_char: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>, off_char: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a></code></h4>
<div class='docblock'><p>Converts the QR code into a human-readable string. This is mainly for
debugging only.</p>
</div><h4 id='method.to_vec' class='method'><code>fn <a href='#method.to_vec' class='fnname'>to_vec</a>(&amp;self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>&gt;</code></h4>
<div class='docblock'><p>Converts the QR code to a vector of booleans. Each entry represents the
color of the module, with &quot;true&quot; means dark and &quot;false&quot; means light.</p>
</div><h4 id='method.into_vec' class='method'><code>fn <a href='#method.into_vec' class='fnname'>into_vec</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a>&gt;</code></h4>
<div class='docblock'><p>Converts the QR code to a vector of booleans. Each entry represents the
color of the module, with &quot;true&quot; means dark and &quot;false&quot; means light.</p>
</div><h4 id='method.render' class='method'><code>fn <a href='#method.render' class='fnname'>render</a>&lt;P:&nbsp;<a class='trait' href='../qrcode/render/trait.BlankAndWhitePixel.html' title='qrcode::render::BlankAndWhitePixel'>BlankAndWhitePixel</a> + 'static&gt;(&amp;self) -&gt; <a class='struct' href='../qrcode/render/struct.Renderer.html' title='qrcode::render::Renderer'>Renderer</a>&lt;P&gt;</code></h4>
<div class='docblock'><p>Renders the QR code into an image. The result is an image builder, which
you may do some additional configuration before copying it into a
concrete image.</p>
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>image</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>new</span>(<span class='string'>b&quot;hello&quot;</span>).<span class='ident'>unwrap</span>()
.<span class='ident'>render</span>()
.<span class='ident'>dark_color</span>(<span class='ident'>Rgb</span> { <span class='ident'>data</span>: [<span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>128</span>] })
.<span class='ident'>light_color</span>(<span class='ident'>Rgb</span> { <span class='ident'>data</span>: [<span class='number'>224</span>, <span class='number'>224</span>, <span class='number'>224</span>] }) <span class='comment'>// adjust colors</span>
.<span class='ident'>quiet_zone</span>(<span class='boolvalue'>false</span>) <span class='comment'>// disable quiet zone (white border)</span>
.<span class='ident'>min_width</span>(<span class='number'>300</span>) <span class='comment'>// sets minimum image size</span>
.<span class='ident'>to_image</span>();</pre>
<p>Note: the <code>image</code> crate itself also provides method to rotate the image,
or overlay a logo on top of the QR code.</p>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html' title='core::ops::Index'>Index</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a>&gt; for <a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-1203' class='srclink' href='../src/qrcode/src/lib.rs.html#229-236' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='associatedtype.Output' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>The returned type after indexing</p>
</div><h4 id='method.index' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, (x, y): <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a>) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>The method for the indexing (<code>Foo[Bar]</code>) operation</p>
</div></div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-1137' class='srclink' href='../src/qrcode/src/lib.rs.html#47' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='struct' href='../qrcode/struct.QrCode.html' title='qrcode::QrCode'>QrCode</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../jquery.js"></script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>

View file

@ -1,155 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `EcLevel` enum in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, EcLevel">
<title>qrcode::types::EcLevel - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'EcLevel', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content enum">
<h1 class='fqn'><span class='in-band'>Enum <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a>::<wbr><a class='enum' href=''>EcLevel</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-47' class='srclink' href='../../src/qrcode/src/types.rs.html#52-64' title='goto source code'>[src]</a></span></h1>
<pre class='rust enum'>pub enum EcLevel {
L,
M,
Q,
H,
}</pre><div class='docblock'><p>The error correction level. It allows the original information be recovered
even if parts of the code is damaged.</p>
</div><h2 class='variants'>Variants</h2>
<span id='variant.L' class='variant'><code>L</code></span><div class='docblock'><p>Low error correction. Allows up to 7% of wrong blocks.</p>
</div><span id='variant.M' class='variant'><code>M</code></span><div class='docblock'><p>Medium error correction (default). Allows up to 15% of wrong blocks.</p>
</div><span id='variant.Q' class='variant'><code>Q</code></span><div class='docblock'><p>&quot;Quartile&quot; error correction. Allows up to 25% of wrong blocks.</p>
</div><span id='variant.H' class='variant'><code>H</code></span><div class='docblock'><p>High error correction. Allows up to 30% of wrong blocks.</p>
</div><h2 id='implementations'>Trait Implementations</h2><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a> for <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-56' class='srclink' href='../../src/qrcode/src/types.rs.html#51' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a></code></h4>
<div class='docblock'><p>This method returns an <code>Ordering</code> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a> for <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-62' class='srclink' href='../../src/qrcode/src/types.rs.html#51' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.partial_cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a>&gt;</code></h4>
<div class='docblock'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p>
</div><h4 id='method.lt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
</div><h4 id='method.le' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
</div><h4 id='method.gt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
</div><h4 id='method.ge' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-68' class='srclink' href='../../src/qrcode/src/types.rs.html#51' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-71' class='srclink' href='../../src/qrcode/src/types.rs.html#51' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-72' class='srclink' href='../../src/qrcode/src/types.rs.html#51' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-75' class='srclink' href='../../src/qrcode/src/types.rs.html#51' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-81' class='srclink' href='../../src/qrcode/src/types.rs.html#51' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,185 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Mode` enum in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Mode">
<title>qrcode::types::Mode - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'Mode', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content enum">
<h1 class='fqn'><span class='in-band'>Enum <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a>::<wbr><a class='enum' href=''>Mode</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-151' class='srclink' href='../../src/qrcode/src/types.rs.html#146-159' title='goto source code'>[src]</a></span></h1>
<pre class='rust enum'>pub enum Mode {
Numeric,
Alphanumeric,
Byte,
Kanji,
}</pre><div class='docblock'><p>The mode indicator, which specifies the character set of the encoded data.</p>
</div><h2 class='variants'>Variants</h2>
<span id='variant.Numeric' class='variant'><code>Numeric</code></span><div class='docblock'><p>The data contains only characters 0 to 9.</p>
</div><span id='variant.Alphanumeric' class='variant'><code>Alphanumeric</code></span><div class='docblock'><p>The data contains only uppercase letters (AZ), numbers (09) and a few
punctuations marks (space, <code>$</code>, <code>%</code>, <code>*</code>, <code>+</code>, <code>-</code>, <code>.</code>, <code>/</code>, <code>:</code>).</p>
</div><span id='variant.Byte' class='variant'><code>Byte</code></span><div class='docblock'><p>The data contains arbitrary binary data.</p>
</div><span id='variant.Kanji' class='variant'><code>Kanji</code></span><div class='docblock'><p>The data contains Shift-JIS-encoded double-byte text.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-177' class='srclink' href='../../src/qrcode/src/types.rs.html#161-235' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.length_bits_count' class='method'><code>fn <a href='#method.length_bits_count' class='fnname'>length_bits_count</a>(&amp;self, version: <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Computes the number of bits needed to encode the data length.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::{<span class='ident'>Version</span>, <span class='ident'>Mode</span>};
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Mode</span>::<span class='ident'>Numeric</span>.<span class='ident'>length_bits_count</span>(<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>)), <span class='number'>10</span>);</pre>
<p>This method will return <code>Err(QrError::UnsupportedCharacterSet)</code> if the
mode is not supported in the given version.</p>
</div><h4 id='method.data_bits_count' class='method'><code>fn <a href='#method.data_bits_count' class='fnname'>data_bits_count</a>(&amp;self, raw_data_len: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Computes the number of bits needed to some data of a given raw length.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::<span class='ident'>Mode</span>;
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Mode</span>::<span class='ident'>Numeric</span>.<span class='ident'>data_bits_count</span>(<span class='number'>7</span>), <span class='number'>24</span>);</pre>
<p>Note that in Kanji mode, the <code>raw_data_len</code> is the number of Kanjis,
i.e. half the total size of bytes.</p>
</div><h4 id='method.max' class='method'><code>fn <a href='#method.max' class='fnname'>max</a>(&amp;self, other: <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a>) -&gt; <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></h4>
<div class='docblock'><p>Find the lowest common mode which both modes are compatible with.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>qrcode</span>::<span class='ident'>types</span>::<span class='ident'>Mode</span>;
<span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>Mode</span>::<span class='ident'>Numeric</span>;
<span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>Mode</span>::<span class='ident'>Kanji</span>;
<span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='ident'>a</span>.<span class='ident'>max</span>(<span class='ident'>b</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span> <span class='op'>&lt;=</span> <span class='ident'>c</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>b</span> <span class='op'>&lt;=</span> <span class='ident'>c</span>);</pre>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a> for <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-190' class='srclink' href='../../src/qrcode/src/types.rs.html#237-254' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.partial_cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&amp;self, other: &amp;<a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a>&gt;</code></h4>
<div class='docblock'><p>Defines a partial ordering between modes. If <code>a &lt;= b</code>, then <code>b</code> contains
a superset of all characters supported by <code>a</code>.</p>
</div><h4 id='method.lt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
</div><h4 id='method.le' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
</div><h4 id='method.gt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
</div><h4 id='method.ge' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
</div></div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-156' class='srclink' href='../../src/qrcode/src/types.rs.html#145' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-159' class='srclink' href='../../src/qrcode/src/types.rs.html#145' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-160' class='srclink' href='../../src/qrcode/src/types.rs.html#145' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-163' class='srclink' href='../../src/qrcode/src/types.rs.html#145' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='enum' href='../../qrcode/types/enum.Mode.html' title='qrcode::types::Mode'>Mode</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-169' class='srclink' href='../../src/qrcode/src/types.rs.html#145' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,147 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `QrError` enum in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, QrError">
<title>qrcode::types::QrError - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'QrError', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content enum">
<h1 class='fqn'><span class='in-band'>Enum <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a>::<wbr><a class='enum' href=''>QrError</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-12' class='srclink' href='../../src/qrcode/src/types.rs.html#10-27' title='goto source code'>[src]</a></span></h1>
<pre class='rust enum'>pub enum QrError {
DataTooLong,
InvalidVersion,
UnsupportedCharacterSet,
InvalidEciDesignator,
InvalidCharacter,
}</pre><div class='docblock'><p><code>QrError</code> encodes the error encountered when generating a QR code.</p>
</div><h2 class='variants'>Variants</h2>
<span id='variant.DataTooLong' class='variant'><code>DataTooLong</code></span><div class='docblock'><p>The data is too long to encode into a QR code for the given version.</p>
</div><span id='variant.InvalidVersion' class='variant'><code>InvalidVersion</code></span><div class='docblock'><p>The provided version / error correction level combination is invalid.</p>
</div><span id='variant.UnsupportedCharacterSet' class='variant'><code>UnsupportedCharacterSet</code></span><div class='docblock'><p>Some characters in the data cannot be supported by the provided QR code
version.</p>
</div><span id='variant.InvalidEciDesignator' class='variant'><code>InvalidEciDesignator</code></span><div class='docblock'><p>The provided ECI designator is invalid. A valid designator should be
between 0 and 999999.</p>
</div><span id='variant.InvalidCharacter' class='variant'><code>InvalidCharacter</code></span><div class='docblock'><p>A character not belonging to the character set is found.</p>
</div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html' title='core::fmt::Display'>Display</a> for <a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-40' class='srclink' href='../../src/qrcode/src/types.rs.html#29-40' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, fmt: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>,&nbsp;<a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html' title='core::fmt::Error'>Error</a>&gt;</code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-18' class='srclink' href='../../src/qrcode/src/types.rs.html#9' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-21' class='srclink' href='../../src/qrcode/src/types.rs.html#9' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-22' class='srclink' href='../../src/qrcode/src/types.rs.html#9' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-25' class='srclink' href='../../src/qrcode/src/types.rs.html#9' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-31' class='srclink' href='../../src/qrcode/src/types.rs.html#9' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt-1' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,160 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `Version` enum in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Version">
<title>qrcode::types::Version - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'Version', ty: 'enum', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content enum">
<h1 class='fqn'><span class='in-band'>Enum <a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a>::<wbr><a class='enum' href=''>Version</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-89' class='srclink' href='../../src/qrcode/src/types.rs.html#77-83' title='goto source code'>[src]</a></span></h1>
<pre class='rust enum'>pub enum Version {
Normal(<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>),
Micro(<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>),
}</pre><div class='docblock'><p>In QR code terminology, <code>Version</code> means the size of the generated image.
Larger version means the size of code is larger, and therefore can carry
more information.</p>
<p>The smallest version is <code>Version::Normal(1)</code> of size 21×21, and the largest
is <code>Version::Normal(40)</code> of size 177×177.</p>
</div><h2 class='variants'>Variants</h2>
<span id='variant.Normal' class='variant'><code>Normal(<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>)</code></span><div class='docblock'><p>A normal QR code version. The parameter should be between 1 and 40.</p>
</div><span id='variant.Micro' class='variant'><code>Micro(<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a>)</code></span><div class='docblock'><p>A Micro QR code version. The parameter should be between 1 and 4.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-132' class='srclink' href='../../src/qrcode/src/types.rs.html#85-137' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.width' class='method'><code>fn <a href='#method.width' class='fnname'>width</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.i16.html'>i16</a></code></h4>
<div class='docblock'><p>Get the number of &quot;modules&quot; on each size of the QR code, i.e. the width
and height of the code.</p>
</div><h4 id='method.fetch' class='method'><code>fn <a href='#method.fetch' class='fnname'>fetch</a>&lt;T&gt;(&amp;self, ec_level: <a class='enum' href='../../qrcode/types/enum.EcLevel.html' title='qrcode::types::EcLevel'>EcLevel</a>, table: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.array.html'>[</a>T<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.array.html'>; 4]</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='type' href='../../qrcode/types/type.QrResult.html' title='qrcode::types::QrResult'>QrResult</a>&lt;T&gt; <span class='where'>where T: <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html' title='core::default::Default'>Default</a> + <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a></span></code></h4>
<div class='docblock'><p>Obtains an object from a hard-coded table.</p>
<p>The table must be a 44×4 array. The outer array represents the content
for each version. The first 40 entry corresponds to QR code versions 1
to 40, and the last 4 corresponds to Micro QR code version 1 to 4. The
inner array represents the content in each error correction level, in
the order [L, M, Q, H].</p>
<p>If the entry compares equal to the default value of T, this method
returns <code>Err(QrError::InvalidVersion)</code>.</p>
</div><h4 id='method.mode_bits_count' class='method'><code>fn <a href='#method.mode_bits_count' class='fnname'>mode_bits_count</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>The number of bits needed to encode the mode indicator.</p>
</div><h4 id='method.is_micro' class='method'><code>fn <a href='#method.is_micro' class='fnname'>is_micro</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Checks whether is version refers to a Micro QR code.</p>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-94' class='srclink' href='../../src/qrcode/src/types.rs.html#76' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></h4>
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html' title='core::marker::Copy'>Copy</a> for <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-99' class='srclink' href='../../src/qrcode/src/types.rs.html#76' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-100' class='srclink' href='../../src/qrcode/src/types.rs.html#76' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-105' class='srclink' href='../../src/qrcode/src/types.rs.html#76' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, __arg_0: &amp;<a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='enum' href='../../qrcode/types/enum.Version.html' title='qrcode::types::Version'>Version</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-124' class='srclink' href='../../src/qrcode/src/types.rs.html#76' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='type' href='https://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</p>
</div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,154 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `types` mod in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, types">
<title>qrcode::types - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a></p><script>window.sidebarCurrent = {name: 'types', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>qrcode</a>::<wbr><a class='mod' href=''>types</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-7' class='srclink' href='../../src/qrcode/src/types.rs.html#1-278' title='goto source code'>[src]</a></span></h1>
<h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
<tr class=' module-item'>
<td><a class='enum' href='enum.EcLevel.html'
title='qrcode::types::EcLevel'>EcLevel</a></td>
<td class='docblock short'>
<p>The error correction level. It allows the original information be recovered
even if parts of the code is damaged.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='enum' href='enum.Mode.html'
title='qrcode::types::Mode'>Mode</a></td>
<td class='docblock short'>
<p>The mode indicator, which specifies the character set of the encoded data.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='enum' href='enum.QrError.html'
title='qrcode::types::QrError'>QrError</a></td>
<td class='docblock short'>
<p><code>QrError</code> encodes the error encountered when generating a QR code.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='enum' href='enum.Version.html'
title='qrcode::types::Version'>Version</a></td>
<td class='docblock short'>
<p>In QR code terminology, <code>Version</code> means the size of the generated image.
Larger version means the size of code is larger, and therefore can carry
more information.</p>
</td>
</tr></table><h2 id='types' class='section-header'><a href="#types">Type Definitions</a></h2>
<table>
<tr class=' module-item'>
<td><a class='type' href='type.QrResult.html'
title='qrcode::types::QrResult'>QrResult</a></td>
<td class='docblock short'>
<p><code>QrResult</code> is a convenient alias for a QR code generation result.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1 +0,0 @@
initSidebarItems({"enum":[["EcLevel","The error correction level. It allows the original information be recovered even if parts of the code is damaged."],["Mode","The mode indicator, which specifies the character set of the encoded data."],["QrError","`QrError` encodes the error encountered when generating a QR code."],["Version","In QR code terminology, `Version` means the size of the generated image. Larger version means the size of code is larger, and therefore can carry more information."]],"type":[["QrResult","`QrResult` is a convenient alias for a QR code generation result."]]});

View file

@ -1,115 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="API documentation for the Rust `QrResult` type in crate `qrcode`.">
<meta name="keywords" content="rust, rustlang, rust-lang, QrResult">
<title>qrcode::types::QrResult - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a></p><script>window.sidebarCurrent = {name: 'QrResult', ty: 'type', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content type">
<h1 class='fqn'><span class='in-band'><a href='../index.html'>qrcode</a>::<wbr><a href='index.html'>types</a>::<wbr><a class='type' href=''>QrResult</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a id='src-45' class='srclink' href='../../src/qrcode/src/types.rs.html#43' title='goto source code'>[src]</a></span></h1>
<pre class='rust typedef'>type QrResult&lt;T&gt; = <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;T,&nbsp;<a class='enum' href='../../qrcode/types/enum.QrError.html' title='qrcode::types::QrError'>QrError</a>&gt;;</pre><div class='docblock'><p><code>QrResult</code> is a convenient alias for a QR code generation result.</p>
</div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>

View file

@ -1,736 +0,0 @@
/**
* Copyright 2013 The Rust Project Developers. See the COPYRIGHT
* file at the top-level directory of this distribution and at
* http://rust-lang.org/COPYRIGHT.
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
* option. This file may not be copied, modified, or distributed
* except according to those terms.
*/
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
@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');
}
/* See SourceSerifPro-LICENSE.txt for the Source Serif Pro license and
* Heuristica-LICENSE.txt for the Heuristica license. */
@font-face {
font-family: 'Source Serif Pro';
font-style: normal;
font-weight: 400;
src: local('Source Serif Pro'), url("SourceSerifPro-Regular.woff") format('woff');
}
@font-face {
font-family: 'Source Serif Pro';
font-style: italic;
font-weight: 400;
src: url("Heuristica-Italic.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.woff") format('woff');
}
/* See SourceCodePro-LICENSE.txt for the Source Code Pro license. */
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
src: local('Source Code Pro'), url("SourceCodePro-Regular.woff") format('woff');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 600;
src: local('Source Code Pro Semibold'), url("SourceCodePro-Semibold.woff") format('woff');
}
@import "normalize.css";
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* General structure and fonts */
body {
font: 16px/1.4 "Source Serif Pro", Georgia, Times, "Times New Roman", 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), h4:not(.method):not(.type):not(.tymethod) {
font-weight: 500;
margin: 20px 0 15px 0;
padding-bottom: 6px;
}
h1.fqn {
border-bottom: 1px dashed;
margin-top: 0;
position: relative;
}
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
border-bottom: 1px solid;
}
h3.impl, h3.method, h4.method, h3.type, h4.type {
font-weight: 600;
margin-top: 10px;
margin-bottom: 10px;
position: relative;
}
h3.impl, h3.method, h3.type {
margin-top: 15px;
}
h1, h2, h3, h4, .sidebar, a.source, .search-input, .content table :not(code)>a, .collapse-toggle {
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
ol, ul {
padding-left: 25px;
}
ul ul, ol ul, ul ol, ol ol {
margin-bottom: 0;
}
p {
margin: 0 0 .6em 0;
}
code, pre {
font-family: "Source Code Pro", Menlo, Monaco, Consolas, "DejaVu Sans Mono", Inconsolata, monospace;
white-space: pre-wrap;
}
.docblock code {
border-radius: 3px;
padding: 0 0.2em;
}
.docblock pre code {
padding: 0;
}
pre {
padding: 14px;
}
.source pre {
padding: 20px;
}
img {
max-width: 100%;
}
.content.source {
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: absolute;
left: 0;
top: 0;
min-height: 100%;
}
.content, nav { max-width: 960px; }
/* Everything else */
.js-only, .hidden { display: none !important; }
.sidebar {
padding: 10px;
}
.sidebar img {
margin: 20px auto;
display: block;
}
.sidebar .location {
font-size: 17px;
margin: 30px 0 20px 0;
text-align: center;
}
.location a:first-child { font-weight: 500; }
.block {
padding: 0 10px;
margin-bottom: 14px;
}
.block h2, .block h3 {
margin-top: 0;
margin-bottom: 8px;
text-align: center;
}
.block ul, .block li {
margin: 0;
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;
}
.content {
padding: 15px 0;
}
.content.source pre.rust {
white-space: pre;
overflow: auto;
padding-left: 0;
}
.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: nowrap; }
.docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 {
border-bottom: 1px solid;
}
.docblock h1 { font-size: 1.3em; }
.docblock h2 { font-size: 1.15em; }
.docblock h3, .docblock h4, .docblock h5 { font-size: 1em; }
.docblock {
margin-left: 24px;
}
.content .out-of-band {
font-size: 23px;
margin: 0px;
padding: 0px;
text-align: right;
display: inline-block;
font-weight: normal;
position: absolute;
right: 0;
}
h3.impl > .out-of-band {
font-size: 21px;
}
h4 > code, h3 > code {
position: inherit;
}
.in-band, code {
z-index: 5;
}
.content .in-band {
margin: 0px;
padding: 0px;
display: inline-block;
}
#main { position: relative; }
#main > .since {
top: inherit;
font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.content table {
border-spacing: 0 5px;
border-collapse: separate;
}
.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; }
.docblock table {
border: 1px solid;
margin: .5em 0;
border-collapse: collapse;
width: 100%;
}
.docblock table td {
padding: .5em;
border-top: 1px dashed;
border-bottom: 1px dashed;
}
.docblock table th {
padding: .5em;
text-align: left;
border-top: 1px solid;
border-bottom: 1px solid;
}
.content .item-list {
list-style-type: none;
padding: 0;
}
.content .item-list li { margin-bottom: 3px; }
.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;
}
/* Shift "where ..." part of method or fn definition down a line */
.content .method .where, .content .fn .where { display: block; }
/* Bit of whitespace to indent it */
.content .method .where::before, .content .fn .where::before { content: ' '; }
.content .methods > div { margin-left: 40px; }
.content .impl-items .docblock, .content .impl-items .stability {
margin-left: 40px;
}
.content .impl-items .method, .content .impl-items > .type {
margin-left: 20px;
}
.content .stability code {
font-size: 90%;
}
nav {
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;
}
.docblock a:hover, .stability a {
text-decoration: underline;
}
.content span.enum, .content a.enum, .block a.current.enum { color: #5e9766; }
.content span.struct, .content a.struct, .block a.current.struct { color: #df3600; }
.content a.type { color: #e57300; }
.content a.macro { color: #068000; }
.block a.current.crate { font-weight: 500; }
.search-input {
width: 100%;
/* Override Normalize.css: we have margins and do
not want to overflow - the `moz` attribute is necessary
until Firefox 29, too early to drop at this point */
-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;
}
.search-input:focus {
border-color: #66afe9;
border-radius: 2px;
border: 0;
outline: 0;
box-shadow: 0 0 8px #078dd8;
}
.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; }
.content .search-results td:first-child a { padding-right: 10px; }
tr.result span.primitive::after { content: ' (primitive type)'; 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;
background: #e9e9e9;
box-shadow: 0 0 6px rgba(0,0,0,.2);
width: 550px;
height: 330px;
border: 1px solid #bfbfbf;
}
#help dt {
float: left;
border-radius: 4px;
border: 1px solid #bfbfbf;
background: #fff;
width: 23px;
text-align: center;
clear: left;
display: block;
margin-top: -1px;
}
#help dd { margin: 5px 33px; }
#help .infos { padding-left: 0; }
#help h1, #help h2 { margin-top: 0; }
#help > div div {
width: 50%;
float: left;
padding: 20px;
}
em.stab {
display: inline-block;
border-width: 1px;
border-style: solid;
padding: 3px;
margin-bottom: 5px;
font-size: 90%;
font-style: normal;
}
em.stab p {
display: inline;
}
.module-item .stab {
border-width: 0;
padding: 0;
margin: 0;
background: inherit !important;
}
.module-item.unstable {
opacity: 0.65;
}
.since {
font-weight: normal;
font-size: initial;
color: grey;
position: absolute;
right: 0;
top: 0;
}
.variants_table {
width: 100%;
}
.variants_table tbody tr td:first-child {
width: 1%; /* make the variant name as small as possible */
}
td.summary-column {
width: 100%;
}
.summary {
padding-right: 0px;
}
.line-numbers :target { background-color: transparent; }
/* Code highlighting */
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 .boolval, 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; }
.rusttest { display: none; }
pre.rust { position: relative; }
a.test-arrow {
display: inline-block;
position: absolute;
background-color: #4e8bca;
padding: 5px 10px 5px 10px;
border-radius: 5px;
font-size: 130%;
top: 5px;
right: 5px;
}
.methods .section-header {
/* Override parent class attributes. */
border-bottom: none !important;
font-size: 1.1em !important;
margin: 0 0 -5px;
padding: 0;
}
.section-header:hover a:after {
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;
color: #999;
top: 0;
}
.toggle-wrapper > .collapse-toggle {
left: -24px;
margin-top: 0px;
}
.toggle-wrapper {
position: relative;
}
.toggle-wrapper.collapsed {
height: 1em;
transition: height .2s;
}
.collapse-toggle > .inner {
display: inline-block;
width: 1.2ch;
text-align: center;
}
.toggle-label {
color: #999;
}
.ghost {
display: none;
}
.ghost + .since {
position: initial;
display: table-cell;
}
.since + .srclink {
display: table-cell;
padding-left: 10px;
}
span.since {
position: initial;
font-size: 20px;
margin-right: 5px;
}
.enum > .toggle-wrapper > .collapse-toggle, .struct > .toggle-wrapper > .collapse-toggle {
left: 0;
margin-top: 5px;
}
.enum > .toggle-wrapper + .docblock, .struct > .toggle-wrapper + .docblock {
margin-left: 30px;
margin-bottom: 20px;
margin-top: 5px;
}
.enum > .collapsed, .struct > .collapsed {
margin-bottom: 25px;
}
:target > code {
background: #FDFFD3;
}
/* Media Queries */
@media (max-width: 700px) {
body {
padding-top: 0px;
}
.sidebar {
height: 40px;
min-height: 40px;
width: 100%;
margin: 0px;
padding: 0px;
position: static;
}
.sidebar .location {
float: right;
margin: 0px;
padding: 3px 10px 1px 10px;
min-height: 39px;
background: inherit;
text-align: left;
font-size: 24px;
}
.sidebar .location:empty {
padding: 0;
}
.sidebar img {
width: 35px;
margin-top: 5px;
margin-bottom: 0px;
float: left;
}
nav.sub {
margin: 0 auto;
}
.sidebar .block {
display: none;
}
.content {
margin-left: 0px;
}
.content .in-band {
width: 100%;
}
.content .out-of-band {
display: none;
}
.toggle-wrapper > .collapse-toggle {
left: 0px;
}
.toggle-wrapper {
height: 1.5em;
}
}
@media print {
nav.sub, .content .out-of-band, .collapse-toggle {
display: none;
}
}

3
rustfmt.toml Normal file
View file

@ -0,0 +1,3 @@
max_width = 120
use_small_heuristics = "Max"
use_field_init_shorthand = true

File diff suppressed because one or more lines are too long

8
src/bin/qrencode.rs Normal file
View file

@ -0,0 +1,8 @@
use std::env;
pub fn main() {
let arg = env::args().nth(1).unwrap();
let code = qrcode::QrCode::new(arg.as_bytes()).unwrap();
print!("{}", code.render().dark_color("\x1b[7m \x1b[0m").light_color("\x1b[49m \x1b[0m").build());
}

993
src/bits.rs Normal file
View file

@ -0,0 +1,993 @@
//! The `bits` module encodes binary data into raw bits used in a QR code.
use std::cmp::min;
#[cfg(feature = "bench")]
extern crate test;
use crate::cast::{As, Truncate};
use crate::optimize::{total_encoded_len, Optimizer, Parser, Segment};
use crate::types::{EcLevel, Mode, QrError, QrResult, Version};
//------------------------------------------------------------------------------
//{{{ Bits
/// The `Bits` structure stores the encoded data for a QR code.
pub struct Bits {
data: Vec<u8>,
bit_offset: usize,
version: Version,
}
impl Bits {
/// Constructs a new, empty bits structure.
pub fn new(version: Version) -> Self {
Self { data: Vec::new(), bit_offset: 0, version }
}
/// Pushes an N-bit big-endian integer to the end of the bits.
///
/// Note: It is up to the developer to ensure that `number` really only is
/// `n` bit in size. Otherwise the excess bits may stomp on the existing
/// ones.
fn push_number(&mut self, n: usize, number: u16) {
debug_assert!(n == 16 || n < 16 && number < (1 << n), "{} is too big as a {}-bit number", number, n);
let b = self.bit_offset + n;
let last_index = self.data.len().wrapping_sub(1);
match (self.bit_offset, b) {
(0, 0..=8) => {
self.data.push((number << (8 - b)).truncate_as_u8());
}
(0, _) => {
self.data.push((number >> (b - 8)).truncate_as_u8());
self.data.push((number << (16 - b)).truncate_as_u8());
}
(_, 0..=8) => {
self.data[last_index] |= (number << (8 - b)).truncate_as_u8();
}
(_, 9..=16) => {
self.data[last_index] |= (number >> (b - 8)).truncate_as_u8();
self.data.push((number << (16 - b)).truncate_as_u8());
}
_ => {
self.data[last_index] |= (number >> (b - 8)).truncate_as_u8();
self.data.push((number >> (b - 16)).truncate_as_u8());
self.data.push((number << (24 - b)).truncate_as_u8());
}
}
self.bit_offset = b & 7;
}
/// Pushes an N-bit big-endian integer to the end of the bits, and check
/// that the number does not overflow the bits.
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
fn push_number_checked(&mut self, n: usize, number: usize) -> QrResult<()> {
if n > 16 || number >= (1 << n) {
Err(QrError::DataTooLong)
} else {
self.push_number(n, number.as_u16());
Ok(())
}
}
/// Reserves `n` extra bits of space for pushing.
fn reserve(&mut self, n: usize) {
let extra_bytes = (n + (8 - self.bit_offset) % 8) / 8;
self.data.reserve(extra_bytes);
}
/// Convert the bits into a bytes vector.
pub fn into_bytes(self) -> Vec<u8> {
self.data
}
/// Total number of bits currently pushed.
pub fn len(&self) -> usize {
if self.bit_offset == 0 {
self.data.len() * 8
} else {
(self.data.len() - 1) * 8 + self.bit_offset
}
}
/// Whether there are any bits pushed.
pub fn is_empty(&self) -> bool {
self.data.is_empty()
}
/// The maximum number of bits allowed by the provided QR code version and
/// error correction level.
///
/// # Errors
///
/// Returns `Err(QrError::InvalidVersion)` if it is not valid to use the
/// `ec_level` for the given version (e.g. `Version::Micro(1)` with
/// `EcLevel::H`).
pub fn max_len(&self, ec_level: EcLevel) -> QrResult<usize> {
self.version.fetch(ec_level, &DATA_LENGTHS)
}
/// Version of the QR code.
pub fn version(&self) -> Version {
self.version
}
}
#[test]
fn test_push_number() {
let mut bits = Bits::new(Version::Normal(1));
bits.push_number(3, 0b010); // 0:0 .. 0:3
bits.push_number(3, 0b110); // 0:3 .. 0:6
bits.push_number(3, 0b101); // 0:6 .. 1:1
bits.push_number(7, 0b001_1010); // 1:1 .. 2:0
bits.push_number(4, 0b1100); // 2:0 .. 2:4
bits.push_number(12, 0b1011_0110_1101); // 2:4 .. 4:0
bits.push_number(10, 0b01_1001_0001); // 4:0 .. 5:2
bits.push_number(15, 0b111_0010_1110_0011); // 5:2 .. 7:1
let bytes = bits.into_bytes();
assert_eq!(
bytes,
vec![
0b010__110__10, // 90
0b1__001_1010, // 154
0b1100__1011, // 203
0b0110_1101, // 109
0b01_1001_00, // 100
0b01__111_001, // 121
0b0_1110_001, // 113
0b1__0000000, // 128
]
);
}
#[cfg(feature = "bench")]
#[bench]
fn bench_push_splitted_bytes(bencher: &mut test::Bencher) {
bencher.iter(|| {
let mut bits = Bits::new(Version::Normal(40));
bits.push_number(4, 0b0101);
for _ in 0..1024 {
bits.push_number(8, 0b10101010);
}
bits.into_bytes()
});
}
//}}}
//------------------------------------------------------------------------------
//{{{ Mode indicator
/// An "extended" mode indicator, includes all indicators supported by QR code
/// beyond those bearing data.
#[derive(Copy, Clone)]
pub enum ExtendedMode {
/// ECI mode indicator, to introduce an ECI designator.
Eci,
/// The normal mode to introduce data.
Data(Mode),
/// FNC-1 mode in the first position.
Fnc1First,
/// FNC-1 mode in the second position.
Fnc1Second,
/// Structured append.
StructuredAppend,
}
impl Bits {
/// Push the mode indicator to the end of the bits.
///
/// # Errors
///
/// If the mode is not supported in the provided version, this method
/// returns `Err(QrError::UnsupportedCharacterSet)`.
pub fn push_mode_indicator(&mut self, mode: ExtendedMode) -> QrResult<()> {
#[allow(clippy::match_same_arms)]
let number = match (self.version, mode) {
(Version::Micro(1), ExtendedMode::Data(Mode::Numeric)) => return Ok(()),
(Version::Micro(_), ExtendedMode::Data(Mode::Numeric)) => 0,
(Version::Micro(_), ExtendedMode::Data(Mode::Alphanumeric)) => 1,
(Version::Micro(_), ExtendedMode::Data(Mode::Byte)) => 0b10,
(Version::Micro(_), ExtendedMode::Data(Mode::Kanji)) => 0b11,
(Version::Micro(_), _) => return Err(QrError::UnsupportedCharacterSet),
(_, ExtendedMode::Data(Mode::Numeric)) => 0b0001,
(_, ExtendedMode::Data(Mode::Alphanumeric)) => 0b0010,
(_, ExtendedMode::Data(Mode::Byte)) => 0b0100,
(_, ExtendedMode::Data(Mode::Kanji)) => 0b1000,
(_, ExtendedMode::Eci) => 0b0111,
(_, ExtendedMode::Fnc1First) => 0b0101,
(_, ExtendedMode::Fnc1Second) => 0b1001,
(_, ExtendedMode::StructuredAppend) => 0b0011,
};
let bits = self.version.mode_bits_count();
self.push_number_checked(bits, number).or(Err(QrError::UnsupportedCharacterSet))
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ ECI
impl Bits {
/// Push an ECI (Extended Channel Interpretation) designator to the bits.
///
/// An ECI designator is a 6-digit number to specify the character set of
/// the following binary data. After calling this method, one could call
/// `.push_byte_data()` or similar methods to insert the actual data, e.g.
///
/// #![allow(unused_must_use)]
///
/// use qrcode::bits::Bits;
/// use qrcode::types::Version;
///
/// let mut bits = Bits::new(Version::Normal(1));
/// bits.push_eci_designator(9); // 9 = ISO-8859-7 (Greek).
/// bits.push_byte_data(b"\xa1\xa2\xa3\xa4\xa5"); // ΑΒΓΔΕ
///
///
/// The full list of ECI designator values can be found from
/// <http://strokescribe.com/en/ECI.html>. Some example values are:
///
/// ECI # | Character set
/// ------|-------------------------------------
/// 3 | ISO-8859-1 (Western European)
/// 20 | Shift JIS (Japanese)
/// 23 | Windows 1252 (Latin 1) (Western European)
/// 25 | UTF-16 Big Endian
/// 26 | UTF-8
/// 28 | Big 5 (Traditional Chinese)
/// 29 | GB-18030 (Simplified Chinese)
/// 30 | EUC-KR (Korean)
///
/// # Errors
///
/// If the QR code version does not support ECI, this method will return
/// `Err(QrError::UnsupportedCharacterSet)`.
///
/// If the designator is outside of the expected range, this method will
/// return `Err(QrError::InvalidECIDesignator)`.
pub fn push_eci_designator(&mut self, eci_designator: u32) -> QrResult<()> {
self.reserve(12); // assume the common case that eci_designator <= 127.
self.push_mode_indicator(ExtendedMode::Eci)?;
match eci_designator {
0..=127 => {
self.push_number(8, eci_designator.as_u16());
}
128..=16383 => {
self.push_number(2, 0b10);
self.push_number(14, eci_designator.as_u16());
}
16384..=999_999 => {
self.push_number(3, 0b110);
self.push_number(5, (eci_designator >> 16).as_u16());
self.push_number(16, (eci_designator & 0xffff).as_u16());
}
_ => return Err(QrError::InvalidEciDesignator),
}
Ok(())
}
}
#[cfg(test)]
mod eci_tests {
use crate::bits::Bits;
use crate::types::{QrError, Version};
#[test]
fn test_9() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_eci_designator(9), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b0111__0000, 0b1001__0000]);
}
#[test]
fn test_899() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_eci_designator(899), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b0111__10_00, 0b00111000, 0b0011__0000]);
}
#[test]
fn test_999999() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_eci_designator(999999), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b0111__110_0, 0b11110100, 0b00100011, 0b1111__0000]);
}
#[test]
fn test_invalid_designator() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_eci_designator(1000000), Err(QrError::InvalidEciDesignator));
}
#[test]
fn test_unsupported_character_set() {
let mut bits = Bits::new(Version::Micro(4));
assert_eq!(bits.push_eci_designator(9), Err(QrError::UnsupportedCharacterSet));
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Mode::Numeric mode
impl Bits {
fn push_header(&mut self, mode: Mode, raw_data_len: usize) -> QrResult<()> {
let length_bits = mode.length_bits_count(self.version);
self.reserve(length_bits + 4 + mode.data_bits_count(raw_data_len));
self.push_mode_indicator(ExtendedMode::Data(mode))?;
self.push_number_checked(length_bits, raw_data_len)?;
Ok(())
}
/// Encodes a numeric string to the bits.
///
/// The data should only contain the characters 0 to 9.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
pub fn push_numeric_data(&mut self, data: &[u8]) -> QrResult<()> {
self.push_header(Mode::Numeric, data.len())?;
for chunk in data.chunks(3) {
let number = chunk.iter().map(|b| u16::from(*b - b'0')).fold(0, |a, b| a * 10 + b);
let length = chunk.len() * 3 + 1;
self.push_number(length, number);
}
Ok(())
}
}
#[cfg(test)]
mod numeric_tests {
use crate::bits::Bits;
use crate::types::{QrError, Version};
#[test]
fn test_iso_18004_2006_example_1() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_numeric_data(b"01234567"), Ok(()));
assert_eq!(
bits.into_bytes(),
vec![0b0001_0000, 0b001000_00, 0b00001100, 0b01010110, 0b01_100001, 0b1__0000000]
);
}
#[test]
fn test_iso_18004_2000_example_2() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_numeric_data(b"0123456789012345"), Ok(()));
assert_eq!(
bits.into_bytes(),
vec![
0b0001_0000,
0b010000_00,
0b00001100,
0b01010110,
0b01_101010,
0b0110_1110,
0b000101_00,
0b11101010,
0b0101__0000,
]
);
}
#[test]
fn test_iso_18004_2006_example_2() {
let mut bits = Bits::new(Version::Micro(3));
assert_eq!(bits.push_numeric_data(b"0123456789012345"), Ok(()));
assert_eq!(
bits.into_bytes(),
vec![
0b00_10000_0,
0b00000110,
0b0_0101011,
0b001_10101,
0b00110_111,
0b0000101_0,
0b01110101,
0b00101__000,
]
);
}
#[test]
fn test_data_too_long_error() {
let mut bits = Bits::new(Version::Micro(1));
assert_eq!(bits.push_numeric_data(b"12345678"), Err(QrError::DataTooLong));
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Mode::Alphanumeric mode
/// In QR code `Mode::Alphanumeric` mode, a pair of alphanumeric characters will
/// be encoded as a base-45 integer. `alphanumeric_digit` converts each
/// character into its corresponding base-45 digit.
///
/// The conversion is specified in ISO/IEC 18004:2006, §8.4.3, Table 5.
#[inline]
fn alphanumeric_digit(character: u8) -> u16 {
match character {
b'0'..=b'9' => u16::from(character - b'0'),
b'A'..=b'Z' => u16::from(character - b'A') + 10,
b' ' => 36,
b'$' => 37,
b'%' => 38,
b'*' => 39,
b'+' => 40,
b'-' => 41,
b'.' => 42,
b'/' => 43,
b':' => 44,
_ => 0,
}
}
impl Bits {
/// Encodes an alphanumeric string to the bits.
///
/// The data should only contain the charaters A to Z (excluding lowercase),
/// 0 to 9, space, `$`, `%`, `*`, `+`, `-`, `.`, `/` or `:`.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
pub fn push_alphanumeric_data(&mut self, data: &[u8]) -> QrResult<()> {
self.push_header(Mode::Alphanumeric, data.len())?;
for chunk in data.chunks(2) {
let number = chunk.iter().map(|b| alphanumeric_digit(*b)).fold(0, |a, b| a * 45 + b);
let length = chunk.len() * 5 + 1;
self.push_number(length, number);
}
Ok(())
}
}
#[cfg(test)]
mod alphanumeric_tests {
use crate::bits::Bits;
use crate::types::{QrError, Version};
#[test]
fn test_iso_18004_2006_example() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_alphanumeric_data(b"AC-42"), Ok(()));
assert_eq!(
bits.into_bytes(),
vec![0b0010_0000, 0b00101_001, 0b11001110, 0b11100111, 0b001_00001, 0b0__0000000]
);
}
#[test]
fn test_micro_qr_unsupported() {
let mut bits = Bits::new(Version::Micro(1));
assert_eq!(bits.push_alphanumeric_data(b"A"), Err(QrError::UnsupportedCharacterSet));
}
#[test]
fn test_data_too_long() {
let mut bits = Bits::new(Version::Micro(2));
assert_eq!(bits.push_alphanumeric_data(b"ABCDEFGH"), Err(QrError::DataTooLong));
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Mode::Byte mode
impl Bits {
/// Encodes 8-bit byte data to the bits.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
pub fn push_byte_data(&mut self, data: &[u8]) -> QrResult<()> {
self.push_header(Mode::Byte, data.len())?;
for b in data {
self.push_number(8, u16::from(*b));
}
Ok(())
}
}
#[cfg(test)]
mod byte_tests {
use crate::bits::Bits;
use crate::types::{QrError, Version};
#[test]
fn test() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_byte_data(b"\x12\x34\x56\x78\x9a\xbc\xde\xf0"), Ok(()));
assert_eq!(
bits.into_bytes(),
vec![
0b0100_0000,
0b1000_0001,
0b0010_0011,
0b0100_0101,
0b0110_0111,
0b1000_1001,
0b1010_1011,
0b1100_1101,
0b1110_1111,
0b0000__0000,
]
);
}
#[test]
fn test_micro_qr_unsupported() {
let mut bits = Bits::new(Version::Micro(2));
assert_eq!(bits.push_byte_data(b"?"), Err(QrError::UnsupportedCharacterSet));
}
#[test]
fn test_data_too_long() {
let mut bits = Bits::new(Version::Micro(3));
assert_eq!(bits.push_byte_data(b"0123456701234567"), Err(QrError::DataTooLong));
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Mode::Kanji mode
impl Bits {
/// Encodes Shift JIS double-byte data to the bits.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
///
/// Returns `Err(QrError::InvalidCharacter)` if the data is not Shift JIS
/// double-byte data (e.g. if the length of data is not an even number).
pub fn push_kanji_data(&mut self, data: &[u8]) -> QrResult<()> {
self.push_header(Mode::Kanji, data.len() / 2)?;
for kanji in data.chunks(2) {
if kanji.len() != 2 {
return Err(QrError::InvalidCharacter);
}
let cp = u16::from(kanji[0]) * 256 + u16::from(kanji[1]);
let bytes = if cp < 0xe040 { cp - 0x8140 } else { cp - 0xc140 };
let number = (bytes >> 8) * 0xc0 + (bytes & 0xff);
self.push_number(13, number);
}
Ok(())
}
}
#[cfg(test)]
mod kanji_tests {
use crate::bits::Bits;
use crate::types::{QrError, Version};
#[test]
fn test_iso_18004_example() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_kanji_data(b"\x93\x5f\xe4\xaa"), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b1000_0000, 0b0010_0110, 0b11001111, 0b1_1101010, 0b101010__00]);
}
#[test]
fn test_micro_qr_unsupported() {
let mut bits = Bits::new(Version::Micro(2));
assert_eq!(bits.push_kanji_data(b"?"), Err(QrError::UnsupportedCharacterSet));
}
#[test]
fn test_data_too_long() {
let mut bits = Bits::new(Version::Micro(3));
assert_eq!(bits.push_kanji_data(b"\x93_\x93_\x93_\x93_\x93_\x93_\x93_\x93_"), Err(QrError::DataTooLong));
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ FNC1 mode
impl Bits {
/// Encodes an indicator that the following data are formatted according to
/// the UCC/EAN Application Identifiers standard.
///
/// #![allow(unused_must_use)]
///
/// use qrcode::bits::Bits;
/// use qrcode::types::Version;
///
/// let mut bits = Bits::new(Version::Normal(1));
/// bits.push_fnc1_first_position();
/// bits.push_numeric_data(b"01049123451234591597033130128");
/// bits.push_alphanumeric_data(b"%10ABC123");
///
/// In QR code, the character `%` is used as the data field separator (0x1D).
///
/// # Errors
///
/// If the mode is not supported in the provided version, this method
/// returns `Err(QrError::UnsupportedCharacterSet)`.
pub fn push_fnc1_first_position(&mut self) -> QrResult<()> {
self.push_mode_indicator(ExtendedMode::Fnc1First)
}
/// Encodes an indicator that the following data are formatted in accordance
/// with specific industry or application specifications previously agreed
/// with AIM International.
///
/// #![allow(unused_must_use)]
///
/// use qrcode::bits::Bits;
/// use qrcode::types::Version;
///
/// let mut bits = Bits::new(Version::Normal(1));
/// bits.push_fnc1_second_position(37);
/// bits.push_alphanumeric_data(b"AA1234BBB112");
/// bits.push_byte_data(b"text text text text\r");
///
/// If the application indicator is a single Latin alphabet (az / AZ),
/// please pass in its ASCII value + 100:
///
/// ```ignore
/// bits.push_fnc1_second_position(b'A' + 100);
/// ```
///
/// # Errors
///
/// If the mode is not supported in the provided version, this method
/// returns `Err(QrError::UnsupportedCharacterSet)`.
pub fn push_fnc1_second_position(&mut self, application_indicator: u8) -> QrResult<()> {
self.push_mode_indicator(ExtendedMode::Fnc1Second)?;
self.push_number(8, u16::from(application_indicator));
Ok(())
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Finish
// This table is copied from ISO/IEC 18004:2006 §6.4.10, Table 7.
static DATA_LENGTHS: [[usize; 4]; 44] = [
// Normal versions
[152, 128, 104, 72],
[272, 224, 176, 128],
[440, 352, 272, 208],
[640, 512, 384, 288],
[864, 688, 496, 368],
[1088, 864, 608, 480],
[1248, 992, 704, 528],
[1552, 1232, 880, 688],
[1856, 1456, 1056, 800],
[2192, 1728, 1232, 976],
[2592, 2032, 1440, 1120],
[2960, 2320, 1648, 1264],
[3424, 2672, 1952, 1440],
[3688, 2920, 2088, 1576],
[4184, 3320, 2360, 1784],
[4712, 3624, 2600, 2024],
[5176, 4056, 2936, 2264],
[5768, 4504, 3176, 2504],
[6360, 5016, 3560, 2728],
[6888, 5352, 3880, 3080],
[7456, 5712, 4096, 3248],
[8048, 6256, 4544, 3536],
[8752, 6880, 4912, 3712],
[9392, 7312, 5312, 4112],
[10208, 8000, 5744, 4304],
[10960, 8496, 6032, 4768],
[11744, 9024, 6464, 5024],
[12248, 9544, 6968, 5288],
[13048, 10136, 7288, 5608],
[13880, 10984, 7880, 5960],
[14744, 11640, 8264, 6344],
[15640, 12328, 8920, 6760],
[16568, 13048, 9368, 7208],
[17528, 13800, 9848, 7688],
[18448, 14496, 10288, 7888],
[19472, 15312, 10832, 8432],
[20528, 15936, 11408, 8768],
[21616, 16816, 12016, 9136],
[22496, 17728, 12656, 9776],
[23648, 18672, 13328, 10208],
// Micro versions
[20, 0, 0, 0],
[40, 32, 0, 0],
[84, 68, 0, 0],
[128, 112, 80, 0],
];
impl Bits {
/// Pushes the ending bits to indicate no more data.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
///
/// Returns `Err(QrError::InvalidVersion)` if it is not valid to use the
/// `ec_level` for the given version (e.g. `Version::Micro(1)` with
/// `EcLevel::H`).
pub fn push_terminator(&mut self, ec_level: EcLevel) -> QrResult<()> {
let terminator_size = match self.version {
Version::Micro(a) => a.as_usize() * 2 + 1,
_ => 4,
};
let cur_length = self.len();
let data_length = self.max_len(ec_level)?;
if cur_length > data_length {
return Err(QrError::DataTooLong);
}
let terminator_size = min(terminator_size, data_length - cur_length);
if terminator_size > 0 {
self.push_number(terminator_size, 0);
}
if self.len() < data_length {
const PADDING_BYTES: &[u8] = &[0b1110_1100, 0b0001_0001];
self.bit_offset = 0;
let data_bytes_length = data_length / 8;
let padding_bytes_count = data_bytes_length - self.data.len();
let padding = PADDING_BYTES.iter().cloned().cycle().take(padding_bytes_count);
self.data.extend(padding);
}
if self.len() < data_length {
self.data.push(0);
}
Ok(())
}
}
#[cfg(test)]
mod finish_tests {
use crate::bits::Bits;
use crate::types::{EcLevel, QrError, Version};
#[test]
fn test_hello_world() {
let mut bits = Bits::new(Version::Normal(1));
assert_eq!(bits.push_alphanumeric_data(b"HELLO WORLD"), Ok(()));
assert_eq!(bits.push_terminator(EcLevel::Q), Ok(()));
assert_eq!(
bits.into_bytes(),
vec![
0b00100000, 0b01011011, 0b00001011, 0b01111000, 0b11010001, 0b01110010, 0b11011100, 0b01001101,
0b01000011, 0b01000000, 0b11101100, 0b00010001, 0b11101100,
]
);
}
#[test]
fn test_too_long() {
let mut bits = Bits::new(Version::Micro(1));
assert_eq!(bits.push_numeric_data(b"9999999"), Ok(()));
assert_eq!(bits.push_terminator(EcLevel::L), Err(QrError::DataTooLong));
}
#[test]
fn test_no_terminator() {
let mut bits = Bits::new(Version::Micro(1));
assert_eq!(bits.push_numeric_data(b"99999"), Ok(()));
assert_eq!(bits.push_terminator(EcLevel::L), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b101_11111, 0b00111_110, 0b0011__0000]);
}
#[test]
fn test_no_padding() {
let mut bits = Bits::new(Version::Micro(1));
assert_eq!(bits.push_numeric_data(b"9999"), Ok(()));
assert_eq!(bits.push_terminator(EcLevel::L), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b100_11111, 0b00111_100, 0b1_000__0000]);
}
#[test]
fn test_micro_version_1_half_byte_padding() {
let mut bits = Bits::new(Version::Micro(1));
assert_eq!(bits.push_numeric_data(b"999"), Ok(()));
assert_eq!(bits.push_terminator(EcLevel::L), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b011_11111, 0b00111_000, 0b0000__0000]);
}
#[test]
fn test_micro_version_1_full_byte_padding() {
let mut bits = Bits::new(Version::Micro(1));
assert_eq!(bits.push_numeric_data(b""), Ok(()));
assert_eq!(bits.push_terminator(EcLevel::L), Ok(()));
assert_eq!(bits.into_bytes(), vec![0b000_000_00, 0b11101100, 0]);
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Front end.
impl Bits {
/// Push a segmented data to the bits, and then terminate it.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
///
/// Returns `Err(QrError::InvalidData)` if the segment refers to incorrectly
/// encoded byte sequence.
pub fn push_segments<I>(&mut self, data: &[u8], segments_iter: I) -> QrResult<()>
where
I: Iterator<Item = Segment>,
{
for segment in segments_iter {
let slice = &data[segment.begin..segment.end];
match segment.mode {
Mode::Numeric => self.push_numeric_data(slice),
Mode::Alphanumeric => self.push_alphanumeric_data(slice),
Mode::Byte => self.push_byte_data(slice),
Mode::Kanji => self.push_kanji_data(slice),
}?;
}
Ok(())
}
/// Pushes the data the bits, using the optimal encoding.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` on overflow.
pub fn push_optimal_data(&mut self, data: &[u8]) -> QrResult<()> {
let segments = Parser::new(data).optimize(self.version);
self.push_segments(data, segments)
}
}
#[cfg(test)]
mod encode_tests {
use crate::bits::Bits;
use crate::types::{EcLevel, QrError, QrResult, Version};
fn encode(data: &[u8], version: Version, ec_level: EcLevel) -> QrResult<Vec<u8>> {
let mut bits = Bits::new(version);
bits.push_optimal_data(data)?;
bits.push_terminator(ec_level)?;
Ok(bits.into_bytes())
}
#[test]
fn test_alphanumeric() {
let res = encode(b"HELLO WORLD", Version::Normal(1), EcLevel::Q);
assert_eq!(
res,
Ok(vec![
0b00100000, 0b01011011, 0b00001011, 0b01111000, 0b11010001, 0b01110010, 0b11011100, 0b01001101,
0b01000011, 0b01000000, 0b11101100, 0b00010001, 0b11101100,
])
);
}
#[test]
fn test_auto_mode_switch() {
let res = encode(b"123A", Version::Micro(2), EcLevel::L);
assert_eq!(res, Ok(vec![0b0_0011_000, 0b1111011_1, 0b001_00101, 0b0_00000__00, 0b11101100]));
}
#[test]
fn test_too_long() {
let res = encode(b">>>>>>>>", Version::Normal(1), EcLevel::H);
assert_eq!(res, Err(QrError::DataTooLong));
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Auto version minimization
/// Automatically determines the minimum version to store the data, and encode
/// the result.
///
/// This method will not consider any Micro QR code versions.
///
/// # Errors
///
/// Returns `Err(QrError::DataTooLong)` if the data is too long to fit even the
/// highest QR code version.
pub fn encode_auto(data: &[u8], ec_level: EcLevel) -> QrResult<Bits> {
let segments = Parser::new(data).collect::<Vec<Segment>>();
for version in &[Version::Normal(9), Version::Normal(26), Version::Normal(40)] {
let opt_segments = Optimizer::new(segments.iter().cloned(), *version).collect::<Vec<_>>();
let total_len = total_encoded_len(&*opt_segments, *version);
let data_capacity = version.fetch(ec_level, &DATA_LENGTHS).expect("invalid DATA_LENGTHS");
if total_len <= data_capacity {
let min_version = find_min_version(total_len, ec_level);
let mut bits = Bits::new(min_version);
bits.reserve(total_len);
bits.push_segments(data, opt_segments.into_iter())?;
bits.push_terminator(ec_level)?;
return Ok(bits);
}
}
Err(QrError::DataTooLong)
}
/// Finds the smallest version (QR code only) that can store N bits of data
/// in the given error correction level.
fn find_min_version(length: usize, ec_level: EcLevel) -> Version {
let mut base = 0_usize;
let mut size = 39;
while size > 1 {
let half = size / 2;
let mid = base + half;
// mid is always in [0, size).
// mid >= 0: by definition
// mid < size: mid = size / 2 + size / 4 + size / 8 ...
base = if DATA_LENGTHS[mid][ec_level as usize] > length { base } else { mid };
size -= half;
}
// base is always in [0, mid) because base <= mid.
base = if DATA_LENGTHS[base][ec_level as usize] >= length { base } else { base + 1 };
Version::Normal((base + 1).as_i16())
}
#[cfg(test)]
mod encode_auto_tests {
use crate::bits::{encode_auto, find_min_version};
use crate::types::{EcLevel, Version};
#[test]
fn test_find_min_version() {
assert_eq!(find_min_version(60, EcLevel::L), Version::Normal(1));
assert_eq!(find_min_version(200, EcLevel::L), Version::Normal(2));
assert_eq!(find_min_version(200, EcLevel::H), Version::Normal(3));
assert_eq!(find_min_version(20000, EcLevel::L), Version::Normal(37));
assert_eq!(find_min_version(640, EcLevel::L), Version::Normal(4));
assert_eq!(find_min_version(641, EcLevel::L), Version::Normal(5));
assert_eq!(find_min_version(999999, EcLevel::H), Version::Normal(40));
}
#[test]
fn test_alpha_q() {
let bits = encode_auto(b"HELLO WORLD", EcLevel::Q).unwrap();
assert_eq!(bits.version(), Version::Normal(1));
}
#[test]
fn test_alpha_h() {
let bits = encode_auto(b"HELLO WORLD", EcLevel::H).unwrap();
assert_eq!(bits.version(), Version::Normal(2));
}
#[test]
fn test_mixed() {
let bits = encode_auto(b"This is a mixed data test. 1234567890", EcLevel::H).unwrap();
assert_eq!(bits.version(), Version::Normal(4));
}
}
#[cfg(feature = "bench")]
#[bench]
fn bench_find_min_version(bencher: &mut test::Bencher) {
use test::black_box;
bencher.iter(|| {
black_box(find_min_version(60, EcLevel::L));
black_box(find_min_version(200, EcLevel::L));
black_box(find_min_version(200, EcLevel::H));
black_box(find_min_version(20000, EcLevel::L));
black_box(find_min_version(640, EcLevel::L));
black_box(find_min_version(641, EcLevel::L));
black_box(find_min_version(999999, EcLevel::H));
})
}
//}}}
//------------------------------------------------------------------------------

2001
src/canvas.rs Normal file

File diff suppressed because it is too large Load diff

89
src/cast.rs Normal file
View file

@ -0,0 +1,89 @@
use std::fmt::Display;
#[cfg(debug_assertions)]
use checked_int_cast::CheckedIntCast;
pub trait Truncate {
fn truncate_as_u8(self) -> u8;
}
impl Truncate for u16 {
#[allow(clippy::cast_possible_truncation)]
fn truncate_as_u8(self) -> u8 {
(self & 0xff) as u8
}
}
pub trait As {
fn as_u16(self) -> u16;
fn as_i16(self) -> i16;
fn as_u32(self) -> u32;
fn as_usize(self) -> usize;
fn as_isize(self) -> isize;
}
trait ExpectOrOverflow {
type Output;
fn expect_or_overflow<D: Display>(self, value: D, ty: &str) -> Self::Output;
}
impl<T> ExpectOrOverflow for Option<T> {
type Output = T;
fn expect_or_overflow<D: Display>(self, value: D, ty: &str) -> Self::Output {
match self {
Some(v) => v,
None => panic!("{} overflows {}", value, ty),
}
}
}
macro_rules! impl_as {
($ty:ty) => {
#[cfg(debug_assertions)]
impl As for $ty {
fn as_u16(self) -> u16 {
self.as_u16_checked().expect_or_overflow(self, "u16")
}
fn as_i16(self) -> i16 {
self.as_i16_checked().expect_or_overflow(self, "i16")
}
fn as_u32(self) -> u32 {
self.as_u32_checked().expect_or_overflow(self, "u32")
}
fn as_usize(self) -> usize {
self.as_usize_checked().expect_or_overflow(self, "usize")
}
fn as_isize(self) -> isize {
self.as_isize_checked().expect_or_overflow(self, "usize")
}
}
#[cfg(not(debug_assertions))]
impl As for $ty {
fn as_u16(self) -> u16 {
self as u16
}
fn as_i16(self) -> i16 {
self as i16
}
fn as_u32(self) -> u32 {
self as u32
}
fn as_usize(self) -> usize {
self as usize
}
fn as_isize(self) -> isize {
self as isize
}
}
};
}
impl_as!(i16);
impl_as!(u32);
impl_as!(usize);
impl_as!(isize);

486
src/ec.rs Normal file
View file

@ -0,0 +1,486 @@
//! The `ec` module applies the Reed-Solomon error correction codes.
use std::ops::Deref;
use crate::types::{EcLevel, QrResult, Version};
//------------------------------------------------------------------------------
//{{{ Error correction primitive
/// Creates the error correction code in N bytes.
///
/// This method only supports computing the error-correction code up to
/// 69 bytes. Longer blocks will result in task panic.
///
/// This method treats the data as a polynomial of the form
/// (a\[0\] x<sup>m+n</sup> + a\[1\] x<sup>m+n-1</sup> + … + a\[m\] x<sup>n</sup>)
/// in GF(2<sup>8</sup>), and then computes the polynomial modulus with a
/// generator polynomial of degree N.
pub fn create_error_correction_code(data: &[u8], ec_code_size: usize) -> Vec<u8> {
let data_len = data.len();
let log_den = GENERATOR_POLYNOMIALS[ec_code_size];
let mut res = data.to_vec();
res.resize(ec_code_size + data_len, 0);
// rust-lang-nursery/rust-clippy#2213
for i in 0..data_len {
let lead_coeff = res[i] as usize;
if lead_coeff == 0 {
continue;
}
let log_lead_coeff = usize::from(LOG_TABLE[lead_coeff]);
for (u, v) in res[i + 1..].iter_mut().zip(log_den.iter()) {
*u ^= EXP_TABLE[(usize::from(*v) + log_lead_coeff) % 255];
}
}
res.split_off(data_len)
}
#[cfg(test)]
mod ec_tests {
use crate::ec::create_error_correction_code;
#[test]
fn test_poly_mod_1() {
let res = create_error_correction_code(b" [\x0bx\xd1r\xdcMC@\xec\x11\xec\x11\xec\x11", 10);
assert_eq!(&*res, b"\xc4#'w\xeb\xd7\xe7\xe2]\x17");
}
#[test]
fn test_poly_mod_2() {
let res = create_error_correction_code(b" [\x0bx\xd1r\xdcMC@\xec\x11\xec", 13);
assert_eq!(&*res, b"\xa8H\x16R\xd96\x9c\x00.\x0f\xb4z\x10");
}
#[test]
fn test_poly_mod_3() {
let res = create_error_correction_code(b"CUF\x86W&U\xc2w2\x06\x12\x06g&", 18);
assert_eq!(&*res, b"\xd5\xc7\x0b-s\xf7\xf1\xdf\xe5\xf8\x9au\x9aoV\xa1o'");
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Interleave support
/// This method interleaves a vector of slices into a single vector.
///
/// It will first insert all the first elements of the slices in `blocks`, then
/// all the second elements, then all the third elements, and so on.
///
/// The longest slice must be at the last of `blocks`, and `blocks` must not be
/// empty.
fn interleave<T: Copy, V: Deref<Target = [T]>>(blocks: &[V]) -> Vec<T> {
let last_block_len = blocks.last().expect("non-empty blocks").len();
let mut res = Vec::with_capacity(last_block_len * blocks.len());
for i in 0..last_block_len {
for t in blocks {
if i < t.len() {
res.push(t[i]);
}
}
}
res
}
#[test]
fn test_interleave() {
let res = interleave(&[&b"1234"[..], b"5678", b"abcdef", b"ghijkl"]);
assert_eq!(&*res, b"15ag26bh37ci48djekfl");
}
//}}}
//------------------------------------------------------------------------------
//{{{ QR code error correction
/// Constructs data and error correction codewords ready to be put in the QR
/// code matrix.
///
/// # Errors
///
/// Returns `Err(QrError::InvalidVersion)` if it is not valid to use the
/// `ec_level` for the given version (e.g. `Version::Micro(1)` with
/// `EcLevel::H`).
pub fn construct_codewords(rawbits: &[u8], version: Version, ec_level: EcLevel) -> QrResult<(Vec<u8>, Vec<u8>)> {
let (block_1_size, block_1_count, block_2_size, block_2_count) = version.fetch(ec_level, &DATA_BYTES_PER_BLOCK)?;
let blocks_count = block_1_count + block_2_count;
let block_1_end = block_1_size * block_1_count;
let total_size = block_1_end + block_2_size * block_2_count;
debug_assert_eq!(rawbits.len(), total_size);
// Divide the data into blocks.
let mut blocks = Vec::with_capacity(blocks_count);
blocks.extend(rawbits[..block_1_end].chunks(block_1_size));
if block_2_size > 0 {
blocks.extend(rawbits[block_1_end..].chunks(block_2_size));
}
// Generate EC codes.
let ec_bytes = version.fetch(ec_level, &EC_BYTES_PER_BLOCK)?;
let ec_codes = blocks.iter().map(|block| create_error_correction_code(*block, ec_bytes)).collect::<Vec<Vec<u8>>>();
let blocks_vec = interleave(&blocks);
let ec_vec = interleave(&ec_codes);
Ok((blocks_vec, ec_vec))
}
#[cfg(test)]
mod construct_codewords_test {
use crate::ec::construct_codewords;
use crate::types::{EcLevel, Version};
#[test]
fn test_add_ec_simple() {
let msg = b" [\x0bx\xd1r\xdcMC@\xec\x11\xec\x11\xec\x11";
let (blocks_vec, ec_vec) = construct_codewords(msg, Version::Normal(1), EcLevel::M).unwrap();
assert_eq!(&*blocks_vec, msg);
assert_eq!(&*ec_vec, b"\xc4#'w\xeb\xd7\xe7\xe2]\x17");
}
#[test]
fn test_add_ec_complex() {
let msg = b"CUF\x86W&U\xc2w2\x06\x12\x06g&\xf6\xf6B\x07v\x86\xf2\x07&V\x16\xc6\xc7\x92\x06\
\xb6\xe6\xf7w2\x07v\x86W&R\x06\x86\x972\x07F\xf7vV\xc2\x06\x972\x10\xec\x11\xec\
\x11\xec\x11\xec";
let expected_blocks = b"C\xf6\xb6FU\xf6\xe6\xf7FB\xf7v\x86\x07wVWv2\xc2&\x86\x07\x06U\xf2v\
\x97\xc2\x07\x862w&W\x102V&\xec\x06\x16R\x11\x12\xc6\x06\xec\x06\
\xc7\x86\x11g\x92\x97\xec&\x062\x11\x07\xec";
let expected_ec = b"\xd5W\x94\xeb\xc7\xcct\x9f\x0b`\xb1\x05-<\xd4\xads\xcaL\x18\xf7\xb6\x85\
\x93\xf1|K;\xdf\x9d\xf2!\xe5\xc8\xeej\xf8\x86L(\x9a\x1b\xc3\xffu\x81\
\xe6\xac\x9a\xd1\xbdRo\x11\n\x02V\xa3l\x83\xa1\xa3\xf0 ox\xc0\xb2'\x85\
\x8d\xec";
let (blocks_vec, ec_vec) = construct_codewords(msg, Version::Normal(5), EcLevel::Q).unwrap();
assert_eq!(&*blocks_vec, &expected_blocks[..]);
assert_eq!(&*ec_vec, &expected_ec[..]);
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Number of allowed errors
/// Computes the maximum allowed number of erratic modules can be introduced to
/// the QR code, before the data becomes truly corrupted.
///
/// # Errors
///
/// Returns `Err(QrError::InvalidVersion)` if it is not valid to use the
/// `ec_level` for the given version (e.g. `Version::Micro(1)` with
/// `EcLevel::H`).
pub fn max_allowed_errors(version: Version, ec_level: EcLevel) -> QrResult<usize> {
use crate::EcLevel::{L, M};
use crate::Version::{Micro, Normal};
let p = match (version, ec_level) {
(Micro(2), L) | (Normal(1), L) => 3,
(Micro(_), L) | (Normal(2), L) | (Micro(2), M) | (Normal(1), M) => 2,
(Normal(1), _) | (Normal(3), L) => 1,
_ => 0,
};
let ec_bytes_per_block = version.fetch(ec_level, &EC_BYTES_PER_BLOCK)?;
let (_, count1, _, count2) = version.fetch(ec_level, &DATA_BYTES_PER_BLOCK)?;
let ec_bytes = (count1 + count2) * ec_bytes_per_block;
Ok((ec_bytes - p) / 2)
}
#[cfg(test)]
mod max_allowed_errors_test {
use crate::ec::max_allowed_errors;
use crate::types::{EcLevel, Version};
#[test]
fn test_low_versions() {
assert_eq!(Ok(0), max_allowed_errors(Version::Micro(1), EcLevel::L));
assert_eq!(Ok(1), max_allowed_errors(Version::Micro(2), EcLevel::L));
assert_eq!(Ok(2), max_allowed_errors(Version::Micro(2), EcLevel::M));
assert_eq!(Ok(2), max_allowed_errors(Version::Micro(3), EcLevel::L));
assert_eq!(Ok(4), max_allowed_errors(Version::Micro(3), EcLevel::M));
assert_eq!(Ok(3), max_allowed_errors(Version::Micro(4), EcLevel::L));
assert_eq!(Ok(5), max_allowed_errors(Version::Micro(4), EcLevel::M));
assert_eq!(Ok(7), max_allowed_errors(Version::Micro(4), EcLevel::Q));
assert_eq!(Ok(2), max_allowed_errors(Version::Normal(1), EcLevel::L));
assert_eq!(Ok(4), max_allowed_errors(Version::Normal(1), EcLevel::M));
assert_eq!(Ok(6), max_allowed_errors(Version::Normal(1), EcLevel::Q));
assert_eq!(Ok(8), max_allowed_errors(Version::Normal(1), EcLevel::H));
assert_eq!(Ok(4), max_allowed_errors(Version::Normal(2), EcLevel::L));
assert_eq!(Ok(8), max_allowed_errors(Version::Normal(2), EcLevel::M));
assert_eq!(Ok(11), max_allowed_errors(Version::Normal(2), EcLevel::Q));
assert_eq!(Ok(14), max_allowed_errors(Version::Normal(2), EcLevel::H));
assert_eq!(Ok(7), max_allowed_errors(Version::Normal(3), EcLevel::L));
assert_eq!(Ok(13), max_allowed_errors(Version::Normal(3), EcLevel::M));
assert_eq!(Ok(18), max_allowed_errors(Version::Normal(3), EcLevel::Q));
assert_eq!(Ok(22), max_allowed_errors(Version::Normal(3), EcLevel::H));
assert_eq!(Ok(10), max_allowed_errors(Version::Normal(4), EcLevel::L));
assert_eq!(Ok(18), max_allowed_errors(Version::Normal(4), EcLevel::M));
assert_eq!(Ok(26), max_allowed_errors(Version::Normal(4), EcLevel::Q));
assert_eq!(Ok(32), max_allowed_errors(Version::Normal(4), EcLevel::H));
}
#[test]
fn test_high_versions() {
assert_eq!(Ok(375), max_allowed_errors(Version::Normal(40), EcLevel::L));
assert_eq!(Ok(686), max_allowed_errors(Version::Normal(40), EcLevel::M));
assert_eq!(Ok(1020), max_allowed_errors(Version::Normal(40), EcLevel::Q));
assert_eq!(Ok(1215), max_allowed_errors(Version::Normal(40), EcLevel::H));
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Precomputed tables for GF(256).
/// `EXP_TABLE` encodes the value of 2<sup>n</sup> in the Galois Field GF(256).
static EXP_TABLE: &[u8] = b"\
\x01\x02\x04\x08\x10\x20\x40\x80\x1d\x3a\x74\xe8\xcd\x87\x13\x26\
\x4c\x98\x2d\x5a\xb4\x75\xea\xc9\x8f\x03\x06\x0c\x18\x30\x60\xc0\
\x9d\x27\x4e\x9c\x25\x4a\x94\x35\x6a\xd4\xb5\x77\xee\xc1\x9f\x23\
\x46\x8c\x05\x0a\x14\x28\x50\xa0\x5d\xba\x69\xd2\xb9\x6f\xde\xa1\
\x5f\xbe\x61\xc2\x99\x2f\x5e\xbc\x65\xca\x89\x0f\x1e\x3c\x78\xf0\
\xfd\xe7\xd3\xbb\x6b\xd6\xb1\x7f\xfe\xe1\xdf\xa3\x5b\xb6\x71\xe2\
\xd9\xaf\x43\x86\x11\x22\x44\x88\x0d\x1a\x34\x68\xd0\xbd\x67\xce\
\x81\x1f\x3e\x7c\xf8\xed\xc7\x93\x3b\x76\xec\xc5\x97\x33\x66\xcc\
\x85\x17\x2e\x5c\xb8\x6d\xda\xa9\x4f\x9e\x21\x42\x84\x15\x2a\x54\
\xa8\x4d\x9a\x29\x52\xa4\x55\xaa\x49\x92\x39\x72\xe4\xd5\xb7\x73\
\xe6\xd1\xbf\x63\xc6\x91\x3f\x7e\xfc\xe5\xd7\xb3\x7b\xf6\xf1\xff\
\xe3\xdb\xab\x4b\x96\x31\x62\xc4\x95\x37\x6e\xdc\xa5\x57\xae\x41\
\x82\x19\x32\x64\xc8\x8d\x07\x0e\x1c\x38\x70\xe0\xdd\xa7\x53\xa6\
\x51\xa2\x59\xb2\x79\xf2\xf9\xef\xc3\x9b\x2b\x56\xac\x45\x8a\x09\
\x12\x24\x48\x90\x3d\x7a\xf4\xf5\xf7\xf3\xfb\xeb\xcb\x8b\x0b\x16\
\x2c\x58\xb0\x7d\xfa\xe9\xcf\x83\x1b\x36\x6c\xd8\xad\x47\x8e\x01";
/// `LOG_TABLE` is the inverse function of `EXP_TABLE`.
static LOG_TABLE: &[u8] = b"\
\xff\x00\x01\x19\x02\x32\x1a\xc6\x03\xdf\x33\xee\x1b\x68\xc7\x4b\
\x04\x64\xe0\x0e\x34\x8d\xef\x81\x1c\xc1\x69\xf8\xc8\x08\x4c\x71\
\x05\x8a\x65\x2f\xe1\x24\x0f\x21\x35\x93\x8e\xda\xf0\x12\x82\x45\
\x1d\xb5\xc2\x7d\x6a\x27\xf9\xb9\xc9\x9a\x09\x78\x4d\xe4\x72\xa6\
\x06\xbf\x8b\x62\x66\xdd\x30\xfd\xe2\x98\x25\xb3\x10\x91\x22\x88\
\x36\xd0\x94\xce\x8f\x96\xdb\xbd\xf1\xd2\x13\x5c\x83\x38\x46\x40\
\x1e\x42\xb6\xa3\xc3\x48\x7e\x6e\x6b\x3a\x28\x54\xfa\x85\xba\x3d\
\xca\x5e\x9b\x9f\x0a\x15\x79\x2b\x4e\xd4\xe5\xac\x73\xf3\xa7\x57\
\x07\x70\xc0\xf7\x8c\x80\x63\x0d\x67\x4a\xde\xed\x31\xc5\xfe\x18\
\xe3\xa5\x99\x77\x26\xb8\xb4\x7c\x11\x44\x92\xd9\x23\x20\x89\x2e\
\x37\x3f\xd1\x5b\x95\xbc\xcf\xcd\x90\x87\x97\xb2\xdc\xfc\xbe\x61\
\xf2\x56\xd3\xab\x14\x2a\x5d\x9e\x84\x3c\x39\x53\x47\x6d\x41\xa2\
\x1f\x2d\x43\xd8\xb7\x7b\xa4\x76\xc4\x17\x49\xec\x7f\x0c\x6f\xf6\
\x6c\xa1\x3b\x52\x29\x9d\x55\xaa\xfb\x60\x86\xb1\xbb\xcc\x3e\x5a\
\xcb\x59\x5f\xb0\x9c\xa9\xa0\x51\x0b\xf5\x16\xeb\x7a\x75\x2c\xd7\
\x4f\xae\xd5\xe9\xe6\xe7\xad\xe8\x74\xd6\xf4\xea\xa8\x50\x58\xaf";
/// The generator polynomial list.
///
/// `GENERATOR_POLYNOMIALS[i]` is the polynomial for `i` error correction code
/// words. Each entry encodes the log coefficients of the expanded polynomial
/// (x 2<sup>0</sup>)(x 2<sup>1</sup>)…(x 2<sup>i-1</sup>). Each entry is
/// used as the denominator for polynomial division to obtain the modulus which
/// is the Reed-Solomon error correction code.
///
/// A partial list can be found from ISO/IEC 18004:2006 Annex A.
#[rustfmt::skip]
// ^ this attribute is currently useless, see rust-lang-nursery/rustfmt#1080 and 1298
static GENERATOR_POLYNOMIALS: [&[u8]; 70] = [
b"",
b"\x00",
b"\x19\x01",
b"\xc6\xc7\x03",
b"\x4b\xf9\x4e\x06",
b"\x71\xa4\xa6\x77\x0a",
b"\xa6\x00\x86\x05\xb0\x0f",
b"\x57\xe5\x92\x95\xee\x66\x15",
b"\xaf\xee\xd0\xf9\xd7\xfc\xc4\x1c",
b"\x5f\xf6\x89\xe7\xeb\x95\x0b\x7b\x24",
b"\xfb\x43\x2e\x3d\x76\x46\x40\x5e\x20\x2d",
b"\xdc\xc0\x5b\xc2\xac\xb1\xd1\x74\xe3\x0a\x37",
b"\x66\x2b\x62\x79\xbb\x71\xc6\x8f\x83\x57\x9d\x42",
b"\x4a\x98\xb0\x64\x56\x64\x6a\x68\x82\xda\xce\x8c\x4e",
b"\xc7\xf9\x9b\x30\xbe\x7c\xda\x89\xd8\x57\xcf\x3b\x16\x5b",
b"\x08\xb7\x3d\x5b\xca\x25\x33\x3a\x3a\xed\x8c\x7c\x05\x63\x69",
b"\x78\x68\x6b\x6d\x66\xa1\x4c\x03\x5b\xbf\x93\xa9\xb6\xc2\xe1\x78",
b"\x2b\x8b\xce\x4e\x2b\xef\x7b\xce\xd6\x93\x18\x63\x96\x27\xf3\xa3\x88",
b"\xd7\xea\x9e\x5e\xb8\x61\x76\xaa\x4f\xbb\x98\x94\xfc\xb3\x05\x62\x60\x99",
b"\x43\x03\x69\x99\x34\x5a\x53\x11\x96\x9f\x2c\x80\x99\x85\xfc\xde\x8a\xdc\xab",
b"\x11\x3c\x4f\x32\x3d\xa3\x1a\xbb\xca\xb4\xdd\xe1\x53\xef\x9c\xa4\xd4\xd4\xbc\xbe",
b"\xf0\xe9\x68\xf7\xb5\x8c\x43\x62\x55\xc8\xd2\x73\x94\x89\xe6\x24\x7a\xfe\x94\xaf\xd2",
b"\xd2\xab\xf7\xf2\x5d\xe6\x0e\x6d\xdd\x35\xc8\x4a\x08\xac\x62\x50\xdb\x86\xa0\x69\xa5\xe7",
b"\xab\x66\x92\x5b\x31\x67\x41\x11\xc1\x96\x0e\x19\xb7\xf8\x5e\xa4\xe0\xc0\x01\x4e\x38\x93\xfd",
b"\xe5\x79\x87\x30\xd3\x75\xfb\x7e\x9f\xb4\xa9\x98\xc0\xe2\xe4\xda\x6f\x00\x75\xe8\x57\x60\xe3\x15",
b"\xe7\xb5\x9c\x27\xaa\x1a\x0c\x3b\x0f\x94\xc9\x36\x42\xed\xd0\x63\xa7\x90\xb6\x5f\xf3\x81\xb2\xfc\x2d",
b"\xad\x7d\x9e\x02\x67\xb6\x76\x11\x91\xc9\x6f\x1c\xa5\x35\xa1\x15\xf5\x8e\x0d\x66\x30\xe3\x99\x91\xda\x46",
b"\x4f\xe4\x08\xa5\xe3\x15\xb4\x1d\x09\xed\x46\x63\x2d\x3a\x8a\x87\x49\x7e\xac\x5e\xd8\xc1\x9d\x1a\x11\x95\x60",
b"\xa8\xdf\xc8\x68\xe0\xea\x6c\xb4\x6e\xbe\xc3\x93\xcd\x1b\xe8\xc9\x15\x2b\xf5\x57\x2a\xc3\xd4\x77\xf2\x25\x09\x7b",
b"\x9c\x2d\xb7\x1d\x97\xdb\x36\x60\xf9\x18\x88\x05\xf1\xaf\xbd\x1c\x4b\xea\x96\x94\x17\x09\xca\xa2\x44\xfa\x8c\x18\x97",
b"\x29\xad\x91\x98\xd8\x1f\xb3\xb6\x32\x30\x6e\x56\xef\x60\xde\x7d\x2a\xad\xe2\xc1\xe0\x82\x9c\x25\xfb\xd8\xee\x28\xc0\xb4",
b"\x14\x25\xfc\x5d\x3f\x4b\xe1\x1f\x73\x53\x71\x27\x2c\x49\x7a\x89\x76\x77\x90\xf8\xf8\x37\x01\xe1\x69\x7b\xb7\x75\xbb\xc8\xd2",
b"\x0a\x06\x6a\xbe\xf9\xa7\x04\x43\xd1\x8a\x8a\x20\xf2\x7b\x59\x1b\x78\xb9\x50\x9c\x26\x45\xab\x3c\x1c\xde\x50\x34\xfe\xb9\xdc\xf1",
b"\xf5\xe7\x37\x18\x47\x4e\x4c\x51\xe1\xd4\xad\x25\xd7\x2e\x77\xe5\xf5\xa7\x7e\x48\xb5\x5e\xa5\xd2\x62\x7d\x9f\xb8\xa9\xe8\xb9\xe7\x12",
b"\x6f\x4d\x92\x5e\x1a\x15\x6c\x13\x69\x5e\x71\xc1\x56\x8c\xa3\x7d\x3a\x9e\xe5\xef\xda\x67\x38\x46\x72\x3d\xb7\x81\xa7\x0d\x62\x3e\x81\x33",
b"\x07\x5e\x8f\x51\xf7\x7f\xca\xca\xc2\x7d\x92\x1d\x8a\xa2\x99\x41\x69\x7a\x74\xee\x1a\x24\xd8\x70\x7d\xe4\x0f\x31\x08\xa2\x1e\x7e\x6f\x3a\x55",
b"\xc8\xb7\x62\x10\xac\x1f\xf6\xea\x3c\x98\x73\x00\xa7\x98\x71\xf8\xee\x6b\x12\x3f\xda\x25\x57\xd2\x69\xb1\x78\x4a\x79\xc4\x75\xfb\x71\xe9\x1e\x78",
b"\x9a\x4b\x8d\xb4\x3d\xa5\x68\xe8\x2e\xe3\x60\xb2\x5c\x87\x39\xa2\x78\xc2\xd4\xae\xfc\xb7\x2a\x23\x9d\x6f\x17\x85\x64\x08\x69\x25\xc0\xbd\x9f\x13\x9c",
b"\x9f\x22\x26\xe4\xe6\x3b\xf3\x5f\x31\xda\xb0\xa4\x14\x41\x2d\x6f\x27\x51\x31\x76\x71\xde\xc1\xfa\xf2\xa8\xd9\x29\xa4\xf7\xb1\x1e\xee\x12\x78\x99\x3c\xc1",
b"\x51\xd8\xae\x2f\xc8\x96\x3b\x9c\x59\x8f\x59\xa6\xb7\xaa\x98\x15\xa5\xb1\x71\x84\xea\x05\x9a\x44\x7c\xaf\xc4\x9d\xf9\xe9\x53\x18\x99\xf1\x7e\x24\x74\x13\xe7",
b"\x3b\x74\x4f\xa1\xfc\x62\x80\xcd\x80\xa1\xf7\x39\xa3\x38\xeb\x6a\x35\x1a\xbb\xae\xe2\x68\xaa\x07\xaf\x23\xb5\x72\x58\x29\x2f\xa3\x7d\x86\x48\x14\xe8\x35\x23\x0f",
b"\x84\xa7\x34\x8b\xb8\xdf\x95\x5c\xfa\x12\x53\x21\x7f\x6d\xc2\x07\xd3\xf2\x6d\x42\x56\xa9\x57\x60\xbb\x9f\x72\xac\x76\xd0\xb7\xc8\x52\xb3\x26\x27\x22\xf2\x8e\x93\x37",
b"\xfa\x67\xdd\xe6\x19\x12\x89\xe7\x00\x03\x3a\xf2\xdd\xbf\x6e\x54\xe6\x08\xbc\x6a\x60\x93\x0f\x83\x8b\x22\x65\xdf\x27\x65\xd5\xc7\xed\xfe\xc9\x7b\xab\xa2\xc2\x75\x32\x60",
b"\x60\x43\x03\xf5\xd9\xd7\x21\x41\xf0\x6d\x90\x3f\x15\x83\x26\x65\x99\x80\x37\x1f\xed\x03\x5e\xa0\x14\x57\x4d\x38\xbf\x7b\xcf\x4b\x52\x00\x7a\x84\x65\x91\xd7\x0f\x79\xc0\x8a",
b"\xbe\x07\x3d\x79\x47\xf6\x45\x37\xa8\xbc\x59\xf3\xbf\x19\x48\x7b\x09\x91\x0e\xf7\x01\xee\x2c\x4e\x8f\x3e\xe0\x7e\x76\x72\x44\xa3\x34\xc2\xd9\x93\xcc\xa9\x25\x82\x71\x66\x49\xb5",
b"\x06\xac\x48\xfa\x12\xab\xab\xa2\xe5\xbb\xef\x04\xbb\x0b\x25\xe4\x66\x48\x66\x16\x21\x49\x5f\x63\x84\x01\x0f\x59\x04\x70\x82\x5f\xd3\xeb\xe3\x3a\x23\x58\x84\x17\x2c\xa5\x36\xbb\xe1",
b"\x70\x5e\x58\x70\xfd\xe0\xca\x73\xbb\x63\x59\x05\x36\x71\x81\x2c\x3a\x10\x87\xd8\xa9\xd3\x24\x01\x04\x60\x3c\xf1\x49\x68\xea\x08\xf9\xf5\x77\xae\x34\x19\x9d\xe0\x2b\xca\xdf\x13\x52\x0f",
b"\x4c\xa4\xe5\x5c\x4f\xa8\xdb\x6e\x68\x15\xdc\x4a\x13\xc7\xc3\x64\x5d\xbf\x2b\xd5\x48\x38\x8a\xa1\x7d\xbb\x77\xfa\xbd\x89\xbe\x4c\x7e\xf7\x5d\x1e\x84\x06\x3a\xd5\xd0\xa5\xe0\x98\x85\x5b\x3d",
b"\xe4\x19\xc4\x82\xd3\x92\x3c\x18\xfb\x5a\x27\x66\xf0\x3d\xb2\x3f\x2e\x7b\x73\x12\xdd\x6f\x87\xa0\xb6\xcd\x6b\xce\x5f\x96\x78\xb8\x5b\x15\xf7\x9c\x8c\xee\xbf\x0b\x5e\xe3\x54\x32\xa3\x27\x22\x6c",
b"\xac\x79\x01\x29\xc1\xde\xed\x40\x6d\xb5\x34\x78\xd4\xe2\xef\xf5\xd0\x14\xf6\x22\xe1\xcc\x86\x65\x7d\xce\x45\x8a\xfa\x00\x4d\x3a\x8f\xb9\xdc\xfe\xd2\xbe\x70\x58\x5b\x39\x5a\x6d\x05\x0d\xb5\x19\x9c",
b"\xe8\x7d\x9d\xa1\xa4\x09\x76\x2e\xd1\x63\xcb\xc1\x23\x03\xd1\x6f\xc3\xf2\xcb\xe1\x2e\x0d\x20\xa0\x7e\xd1\x82\xa0\xf2\xd7\xf2\x4b\x4d\x2a\xbd\x20\x71\x41\x7c\x45\xe4\x72\xeb\xaf\x7c\xaa\xd7\xe8\x85\xcd",
b"\xd5\xa6\x8e\x2b\x0a\xd8\x8d\xa3\xac\xb4\x66\x46\x59\x3e\xde\x3e\x2a\xd2\x97\xa3\xda\x46\x4d\x27\xa6\xbf\x72\xca\xf5\xbc\xb7\xdd\x4b\xd4\x1b\xed\x7f\xcc\xeb\x3e\xbe\xe8\x12\x2e\xab\x0f\x62\xf7\x42\xa3\x00",
b"\x74\x32\x56\xba\x32\xdc\xfb\x59\xc0\x2e\x56\x7f\x7c\x13\xb8\xe9\x97\xd7\x16\x0e\x3b\x91\x25\xf2\xcb\x86\xfe\x59\xbe\x5e\x3b\x41\x7c\x71\x64\xe9\xeb\x79\x16\x4c\x56\x61\x27\xf2\xc8\xdc\x65\x21\xef\xfe\x74\x33",
b"\x7a\xd6\xe7\x88\xc7\x0b\x06\xcd\x7c\x48\xd5\x75\xbb\x3c\x93\xc9\x49\x4b\x21\x92\xab\xf7\x76\xd0\x9d\xb1\xcb\xeb\x53\x2d\xe2\xca\xe5\xa8\x07\x39\xed\xeb\xc8\x7c\x6a\xfe\xa5\x0e\x93\x00\x39\x2a\x1f\xb2\xd5\xad\x67",
b"\xb7\x1a\xc9\x57\xd2\xdd\x71\x15\x2e\x41\x2d\x32\xee\xb8\xf9\xe1\x66\x3a\xd1\xda\x6d\xa5\x1a\x5f\xb8\xc0\x34\xf5\x23\xfe\xee\xaf\xac\x4f\x7b\x19\x7a\x2b\x78\x6c\xd7\x50\x80\xc9\xeb\x08\x99\x3b\x65\x1f\xc6\x4c\x1f\x9c",
b"\x26\xc5\x7b\xa7\x10\x57\xb2\xee\xe3\x61\x94\xf7\x1a\x5a\xe4\xb6\xec\xc5\x2f\xf9\x24\xd5\x36\x71\xb5\x4a\xb1\xcc\x9b\x3d\x2f\x2a\x00\x84\x90\xfb\xc8\x26\x26\x8a\x36\x2c\x40\x13\x16\xce\x10\x0a\xe4\xd3\xa1\xab\x2c\xc2\xd2",
b"\x6a\x78\x6b\x9d\xa4\xd8\x70\x74\x02\x5b\xf8\xa3\x24\xc9\xca\xe5\x06\x90\xfe\x9b\x87\xd0\xaa\xd1\x0c\x8b\x7f\x8e\xb6\xf9\xb1\xae\xbe\x1c\x0a\x55\xef\xb8\x65\x7c\x98\xce\x60\x17\xa3\x3d\x1b\xc4\xf7\x97\x9a\xca\xcf\x14\x3d\x0a",
b"\x3a\x8c\xed\x5d\x6a\x3d\xc1\x02\x57\x49\xc2\xd7\x9f\xa3\x0a\x9b\x05\x79\x99\x3b\xf8\x04\x75\x16\x3c\xb1\x90\x2c\x48\xe4\x3e\x01\x13\xaa\x71\x9e\x19\xaf\xc7\x8b\x5a\x01\xd2\x07\x77\x9a\x59\x9f\x82\x7a\x2e\x93\xbe\x87\x5e\x44\x42",
b"\x52\x74\x1a\xf7\x42\x1b\x3e\x6b\xfc\xb6\xc8\xb9\xeb\x37\xfb\xf2\xd2\x90\x9a\xed\xb0\x8d\xc0\xf8\x98\xf9\xce\x55\xfd\x8e\x41\xa5\x7d\x17\x18\x1e\x7a\xf0\xd6\x06\x81\xda\x1d\x91\x7f\x86\xce\xf5\x75\x1d\x29\x3f\x9f\x8e\xe9\x7d\x94\x7b",
b"\x39\x73\xe8\x0b\xc3\xd9\x03\xce\x4d\x43\x1d\xa6\xb4\x6a\x76\xcb\x11\x45\x98\xd5\x4a\x2c\x31\x2b\x62\x3d\xfd\x7a\x0e\x2b\xd1\x8f\x09\x68\x6b\xab\xe0\x39\xfe\xfb\xe2\xe8\xdd\xc2\xf0\x75\xa1\x52\xb2\xf6\xb2\x21\x32\x56\xd7\xef\xb4\xb4\xb5",
b"\x6b\x8c\x1a\x0c\x09\x8d\xf3\xc5\xe2\xc5\xdb\x2d\xd3\x65\xdb\x78\x1c\xb5\x7f\x06\x64\xf7\x02\xcd\xc6\x39\x73\xdb\x65\x6d\xa0\x52\x25\x26\xee\x31\xa0\xd1\x79\x56\x0b\x7c\x1e\xb5\x54\x19\xc2\x57\x41\x66\xbe\xdc\x46\x1b\xd1\x10\x59\x07\x21\xf0",
b"\xa1\xf4\x69\x73\x40\x09\xdd\xec\x10\x91\x94\x22\x90\xba\x0d\x14\xfe\xf6\x26\x23\xca\x48\x04\xd4\x9f\xd3\xa5\x87\xfc\xfa\x19\x57\x1e\x78\xe2\xea\x5c\xc7\x48\x07\x9b\xda\xe7\x2c\x7d\xb2\x9c\xae\x7c\x2b\x64\x1f\x38\x65\xcc\x40\xaf\xe1\xa9\x92\x2d",
b"\x41\xca\x71\x62\x47\xdf\xf8\x76\xd6\x5e\x00\x7a\x25\x17\x02\xe4\x3a\x79\x07\x69\x87\x4e\xf3\x76\x46\x4c\xdf\x59\x48\x32\x46\x6f\xc2\x11\xd4\x7e\xb5\x23\xdd\x75\xeb\x0b\xe5\x95\x93\x7b\xd5\x28\x73\x06\xc8\x64\x1a\xf6\xb6\xda\x7f\xd7\x24\xba\x6e\x6a",
b"\x1e\x47\x24\x47\x13\xc3\xac\x6e\x3d\x02\xa9\xc2\x5a\x88\x3b\xb6\xe7\x91\x66\x27\xaa\xe7\xd6\x43\xc4\xcf\x35\x70\xf6\x5a\x5a\x79\xb7\x92\x4a\x4d\x26\x59\x16\xe7\x37\x38\xf2\x70\xd9\x6e\x7b\x3e\xc9\xd9\x80\xa5\x3c\xb5\x25\xa1\xf6\x84\xf6\x12\x73\x88\xa8",
b"\x2d\x33\xaf\x09\x07\x9e\x9f\x31\x44\x77\x5c\x7b\xb1\xcc\xbb\xfe\xc8\x4e\x8d\x95\x77\x1a\x7f\x35\xa0\x5d\xc7\xd4\x1d\x18\x91\x9c\xd0\x96\xda\xd1\x04\xd8\x5b\x2f\xb8\x92\x2f\x8c\xc3\xc3\x7d\xf2\xee\x3f\x63\x6c\x8c\xe6\xf2\x1f\xcc\x0b\xb2\xf3\xd9\x9c\xd5\xe7",
b"\x89\x9e\xf7\xf0\x25\xee\xd6\x80\x63\xda\x2e\x8a\xc6\x80\x5c\xdb\x6d\x8b\xa6\x19\x42\x43\x0e\x3a\xee\x95\xb1\xc3\xdd\x9a\xab\x30\x50\x0c\x3b\xbe\xe4\x13\x37\xd0\x5c\x70\xe5\x25\x3c\x0a\x2f\x51\x00\xc0\x25\xab\xaf\x93\x80\x49\xa6\x3d\x95\x0c\x18\x5f\x46\x71\x28",
b"\x05\x76\xde\xb4\x88\x88\xa2\x33\x2e\x75\x0d\xd7\x51\x11\x8b\xf7\xc5\xab\x5f\xad\x41\x89\xb2\x44\x6f\x5f\x65\x29\x48\xd6\xa9\xc5\x5f\x07\x2c\x9a\x4d\x6f\xec\x28\x79\x8f\x3f\x57\x50\xfd\xf0\x7e\xd9\x4d\x22\xe8\x6a\x32\xa8\x52\x4c\x92\x43\x6a\xab\x19\x84\x5d\x2d\x69",
b"\xbf\xac\x71\x56\x07\xa6\xf6\xb9\x9b\xfa\x62\x71\x59\x56\xd6\xe1\x9c\xbe\x3a\x21\x90\x43\xb3\xa3\x34\x9a\xe9\x97\x68\xfb\xa0\x7e\xaf\xd0\xe1\x46\xe3\x92\x04\x98\x8b\x67\x19\x6b\x3d\xcc\x9f\xfa\xc1\xe1\x69\xa0\x62\xa7\x02\x35\x10\xf2\x53\xd2\xc4\x67\xf8\x56\xd3\x29\xab",
b"\xf7\x9f\xdf\x21\xe0\x5d\x4d\x46\x5a\xa0\x20\xfe\x2b\x96\x54\x65\xbe\xcd\x85\x34\x3c\xca\xa5\xdc\xcb\x97\x5d\x54\x0f\x54\xfd\xad\xa0\x59\xe3\x34\xc7\x61\x5f\xe7\x34\xb1\x29\x7d\x89\xf1\xa6\xe1\x76\x02\x36\x20\x52\xd7\xaf\xc6\x2b\xee\xeb\x1b\x65\xb8\x7f\x03\x05\x08\xa3\xee",
b"\x69\x49\x44\x01\x1d\xa8\x75\x0e\x58\xd0\x37\x2e\x2a\xd9\x06\x54\xb3\x61\x06\xf0\xc0\xe7\x9e\x40\x76\xa0\xcb\x39\x3d\x6c\xc7\x7c\x41\xbb\xdd\xa7\x27\xb6\x9f\xb4\xf4\xcb\xe4\xfe\x0d\xaf\x3d\x5a\xce\x28\xc7\x5e\x43\x39\x51\xe5\x2e\x7b\x59\x25\x1f\xca\x42\xfa\x23\xaa\xf3\x58\x33",
];
//}}}
//------------------------------------------------------------------------------
//{{{ Tables for error correction sizes
/// `EC_BYTES_PER_BLOCK` provides the number of codewords (bytes) used for error
/// correction per block in each version.
///
/// This is a copy of ISO/IEC 18004:2006, §6.5.1, Table 9 (The 4th column divide
/// by the sum of the 6th column).
static EC_BYTES_PER_BLOCK: [[usize; 4]; 44] = [
// Normal versions.
[7, 10, 13, 17], // 1
[10, 16, 22, 28], // 2
[15, 26, 18, 22], // 3
[20, 18, 26, 16], // 4
[26, 24, 18, 22], // 5
[18, 16, 24, 28], // 6
[20, 18, 18, 26], // 7
[24, 22, 22, 26], // 8
[30, 22, 20, 24], // 9
[18, 26, 24, 28], // 10
[20, 30, 28, 24], // 11
[24, 22, 26, 28], // 12
[26, 22, 24, 22], // 13
[30, 24, 20, 24], // 14
[22, 24, 30, 24], // 15
[24, 28, 24, 30], // 16
[28, 28, 28, 28], // 17
[30, 26, 28, 28], // 18
[28, 26, 26, 26], // 19
[28, 26, 30, 28], // 20
[28, 26, 28, 30], // 21
[28, 28, 30, 24], // 22
[30, 28, 30, 30], // 23
[30, 28, 30, 30], // 24
[26, 28, 30, 30], // 25
[28, 28, 28, 30], // 26
[30, 28, 30, 30], // 27
[30, 28, 30, 30], // 28
[30, 28, 30, 30], // 29
[30, 28, 30, 30], // 30
[30, 28, 30, 30], // 31
[30, 28, 30, 30], // 32
[30, 28, 30, 30], // 33
[30, 28, 30, 30], // 34
[30, 28, 30, 30], // 35
[30, 28, 30, 30], // 36
[30, 28, 30, 30], // 37
[30, 28, 30, 30], // 38
[30, 28, 30, 30], // 39
[30, 28, 30, 30], // 40
// Micro versions.
[2, 0, 0, 0], // M1
[5, 6, 0, 0], // M2
[6, 8, 0, 0], // M3
[8, 10, 14, 0], // M4
];
/// `DATA_BYTES_PER_BLOCK` provides the number of codewords (bytes) used for
/// real data per block in each version.
///
/// This is a copy of ISO/IEC 18004:2006, §6.5.1, Table 9 (The value "k" of the
/// 7th column, followed by the 6th column).
///
/// Every entry is a 4-tuple. Take `DATA_BYTES_PER_BLOCK[39][3] == (15, 20, 16, 61)`
/// as an example, this means in version 40 with correction level H, there are
/// 20 blocks with 15 bytes in size, and 61 blocks with 16 bytes in size.
static DATA_BYTES_PER_BLOCK: [[(usize, usize, usize, usize); 4]; 44] = [
// Normal versions.
[(19, 1, 0, 0), (16, 1, 0, 0), (13, 1, 0, 0), (9, 1, 0, 0)], // 1
[(34, 1, 0, 0), (28, 1, 0, 0), (22, 1, 0, 0), (16, 1, 0, 0)], // 2
[(55, 1, 0, 0), (44, 1, 0, 0), (17, 2, 0, 0), (13, 2, 0, 0)], // 3
[(80, 1, 0, 0), (32, 2, 0, 0), (24, 2, 0, 0), (9, 4, 0, 0)], // 4
[(108, 1, 0, 0), (43, 2, 0, 0), (15, 2, 16, 2), (11, 2, 12, 2)], // 5
[(68, 2, 0, 0), (27, 4, 0, 0), (19, 4, 0, 0), (15, 4, 0, 0)], // 6
[(78, 2, 0, 0), (31, 4, 0, 0), (14, 2, 15, 4), (13, 4, 14, 1)], // 7
[(97, 2, 0, 0), (38, 2, 39, 2), (18, 4, 19, 2), (14, 4, 15, 2)], // 8
[(116, 2, 0, 0), (36, 3, 37, 2), (16, 4, 17, 4), (12, 4, 13, 4)], // 9
[(68, 2, 69, 2), (43, 4, 44, 1), (19, 6, 20, 2), (15, 6, 16, 2)], // 10
[(81, 4, 0, 0), (50, 1, 51, 4), (22, 4, 23, 4), (12, 3, 13, 8)], // 11
[(92, 2, 93, 2), (36, 6, 37, 2), (20, 4, 21, 6), (14, 7, 15, 4)], // 12
[(107, 4, 0, 0), (37, 8, 38, 1), (20, 8, 21, 4), (11, 12, 12, 4)], // 13
[(115, 3, 116, 1), (40, 4, 41, 5), (16, 11, 17, 5), (12, 11, 13, 5)], // 14
[(87, 5, 88, 1), (41, 5, 42, 5), (24, 5, 25, 7), (12, 11, 13, 7)], // 15
[(98, 5, 99, 1), (45, 7, 46, 3), (19, 15, 20, 2), (15, 3, 16, 13)], // 16
[(107, 1, 108, 5), (46, 10, 47, 1), (22, 1, 23, 15), (14, 2, 15, 17)], // 17
[(120, 5, 121, 1), (43, 9, 44, 4), (22, 17, 23, 1), (14, 2, 15, 19)], // 18
[(113, 3, 114, 4), (44, 3, 45, 11), (21, 17, 22, 4), (13, 9, 14, 16)], // 19
[(107, 3, 108, 5), (41, 3, 42, 13), (24, 15, 25, 5), (15, 15, 16, 10)], // 20
[(116, 4, 117, 4), (42, 17, 0, 0), (22, 17, 23, 6), (16, 19, 17, 6)], // 21
[(111, 2, 112, 7), (46, 17, 0, 0), (24, 7, 25, 16), (13, 34, 0, 0)], // 22
[(121, 4, 122, 5), (47, 4, 48, 14), (24, 11, 25, 14), (15, 16, 16, 14)], // 23
[(117, 6, 118, 4), (45, 6, 46, 14), (24, 11, 25, 16), (16, 30, 17, 2)], // 24
[(106, 8, 107, 4), (47, 8, 48, 13), (24, 7, 25, 22), (15, 22, 16, 13)], // 25
[(114, 10, 115, 2), (46, 19, 47, 4), (22, 28, 23, 6), (16, 33, 17, 4)], // 26
[(122, 8, 123, 4), (45, 22, 46, 3), (23, 8, 24, 26), (15, 12, 16, 28)], // 27
[(117, 3, 118, 10), (45, 3, 46, 23), (24, 4, 25, 31), (15, 11, 16, 31)], // 28
[(116, 7, 117, 7), (45, 21, 46, 7), (23, 1, 24, 37), (15, 19, 16, 26)], // 29
[(115, 5, 116, 10), (47, 19, 48, 10), (24, 15, 25, 25), (15, 23, 16, 25)], // 30
[(115, 13, 116, 3), (46, 2, 47, 29), (24, 42, 25, 1), (15, 23, 16, 28)], // 31
[(115, 17, 0, 0), (46, 10, 47, 23), (24, 10, 25, 35), (15, 19, 16, 35)], // 32
[(115, 17, 116, 1), (46, 14, 47, 21), (24, 29, 25, 19), (15, 11, 16, 46)], // 33
[(115, 13, 116, 6), (46, 14, 47, 23), (24, 44, 25, 7), (16, 59, 17, 1)], // 34
[(121, 12, 122, 7), (47, 12, 48, 26), (24, 39, 25, 14), (15, 22, 16, 41)], // 35
[(121, 6, 122, 14), (47, 6, 48, 34), (24, 46, 25, 10), (15, 2, 16, 64)], // 36
[(122, 17, 123, 4), (46, 29, 47, 14), (24, 49, 25, 10), (15, 24, 16, 46)], // 37
[(122, 4, 123, 18), (46, 13, 47, 32), (24, 48, 25, 14), (15, 42, 16, 32)], // 38
[(117, 20, 118, 4), (47, 40, 48, 7), (24, 43, 25, 22), (15, 10, 16, 67)], // 39
[(118, 19, 119, 6), (47, 18, 48, 31), (24, 34, 25, 34), (15, 20, 16, 61)], // 40
// Micro versions.
[(3, 1, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)], // M1
[(5, 1, 0, 0), (4, 1, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)], // M2
[(11, 1, 0, 0), (9, 1, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)], // M3
[(16, 1, 0, 0), (14, 1, 0, 0), (10, 1, 0, 0), (0, 0, 0, 0)], // M4
];
//}}}

373
src/lib.rs Normal file
View file

@ -0,0 +1,373 @@
//! QRCode encoder
//!
//! This crate provides a QR code and Micro QR code encoder for binary data.
//!
#![cfg_attr(feature = "image", doc = "```rust")]
#![cfg_attr(not(feature = "image"), doc = "```ignore")]
//! use qrcode::QrCode;
//! use image::Luma;
//!
//! // Encode some data into bits.
//! let code = QrCode::new(b"01234567").unwrap();
//!
//! // Render the bits into an image.
//! let image = code.render::<Luma<u8>>().build();
//!
//! // Save the image.
//! # if cfg!(unix) {
//! image.save("/tmp/qrcode.png").unwrap();
//! # }
//!
//! // You can also render it into a string.
//! let string = code.render()
//! .light_color(' ')
//! .dark_color('#')
//! .build();
//! println!("{}", string);
//! ```
#![cfg_attr(feature = "bench", feature(test, external_doc))] // Unstable libraries
#![deny(warnings, clippy::pedantic)]
#![allow(
clippy::must_use_candidate, // This is just annoying.
clippy::use_self, // Rust 1.33 doesn't support Self::EnumVariant, let's try again in 1.37.
)]
#![cfg_attr(feature = "bench", doc(include = "../README.md"))]
// ^ make sure we can test our README.md.
use std::ops::Index;
pub mod bits;
pub mod canvas;
mod cast;
pub mod ec;
pub mod optimize;
pub mod render;
pub mod types;
pub use crate::types::{Color, EcLevel, QrResult, Version};
use crate::cast::As;
use crate::render::{Pixel, Renderer};
use checked_int_cast::CheckedIntCast;
/// The encoded QR code symbol.
#[derive(Clone)]
pub struct QrCode {
content: Vec<Color>,
version: Version,
ec_level: EcLevel,
width: usize,
}
impl QrCode {
/// Constructs a new QR code which automatically encodes the given data.
///
/// This method uses the "medium" error correction level and automatically
/// chooses the smallest QR code.
///
/// use qrcode::QrCode;
///
/// let code = QrCode::new(b"Some data").unwrap();
///
/// # Errors
///
/// Returns error if the QR code cannot be constructed, e.g. when the data
/// is too long.
pub fn new<D: AsRef<[u8]>>(data: D) -> QrResult<Self> {
Self::with_error_correction_level(data, EcLevel::M)
}
/// Constructs a new QR code which automatically encodes the given data at a
/// specific error correction level.
///
/// This method automatically chooses the smallest QR code.
///
/// use qrcode::{QrCode, EcLevel};
///
/// let code = QrCode::with_error_correction_level(b"Some data", EcLevel::H).unwrap();
///
/// # Errors
///
/// Returns error if the QR code cannot be constructed, e.g. when the data
/// is too long.
pub fn with_error_correction_level<D: AsRef<[u8]>>(data: D, ec_level: EcLevel) -> QrResult<Self> {
let bits = bits::encode_auto(data.as_ref(), ec_level)?;
Self::with_bits(bits, ec_level)
}
/// Constructs a new QR code for the given version and error correction
/// level.
///
/// use qrcode::{QrCode, Version, EcLevel};
///
/// let code = QrCode::with_version(b"Some data", Version::Normal(5), EcLevel::M).unwrap();
///
/// This method can also be used to generate Micro QR code.
///
/// use qrcode::{QrCode, Version, EcLevel};
///
/// let micro_code = QrCode::with_version(b"123", Version::Micro(1), EcLevel::L).unwrap();
///
/// # Errors
///
/// Returns error if the QR code cannot be constructed, e.g. when the data
/// is too long, or when the version and error correction level are
/// incompatible.
pub fn with_version<D: AsRef<[u8]>>(data: D, version: Version, ec_level: EcLevel) -> QrResult<Self> {
let mut bits = bits::Bits::new(version);
bits.push_optimal_data(data.as_ref())?;
bits.push_terminator(ec_level)?;
Self::with_bits(bits, ec_level)
}
/// Constructs a new QR code with encoded bits.
///
/// Use this method only if there are very special need to manipulate the
/// raw bits before encoding. Some examples are:
///
/// * Encode data using specific character set with ECI
/// * Use the FNC1 modes
/// * Avoid the optimal segmentation algorithm
///
/// See the `Bits` structure for detail.
///
/// #![allow(unused_must_use)]
///
/// use qrcode::{QrCode, Version, EcLevel};
/// use qrcode::bits::Bits;
///
/// let mut bits = Bits::new(Version::Normal(1));
/// bits.push_eci_designator(9);
/// bits.push_byte_data(b"\xca\xfe\xe4\xe9\xea\xe1\xf2 QR");
/// bits.push_terminator(EcLevel::L);
/// let qrcode = QrCode::with_bits(bits, EcLevel::L);
///
/// # Errors
///
/// Returns error if the QR code cannot be constructed, e.g. when the bits
/// are too long, or when the version and error correction level are
/// incompatible.
pub fn with_bits(bits: bits::Bits, ec_level: EcLevel) -> QrResult<Self> {
let version = bits.version();
let data = bits.into_bytes();
let (encoded_data, ec_data) = ec::construct_codewords(&*data, version, ec_level)?;
let mut canvas = canvas::Canvas::new(version, ec_level);
canvas.draw_all_functional_patterns();
canvas.draw_data(&*encoded_data, &*ec_data);
let canvas = canvas.apply_best_mask();
Ok(Self { content: canvas.into_colors(), version, ec_level, width: version.width().as_usize() })
}
/// Gets the version of this QR code.
pub fn version(&self) -> Version {
self.version
}
/// Gets the error correction level of this QR code.
pub fn error_correction_level(&self) -> EcLevel {
self.ec_level
}
/// Gets the number of modules per side, i.e. the width of this QR code.
///
/// The width here does not contain the quiet zone paddings.
pub fn width(&self) -> usize {
self.width
}
/// Gets the maximum number of allowed erratic modules can be introduced
/// before the data becomes corrupted. Note that errors should not be
/// introduced to functional modules.
pub fn max_allowed_errors(&self) -> usize {
ec::max_allowed_errors(self.version, self.ec_level).expect("invalid version or ec_level")
}
/// Checks whether a module at coordinate (x, y) is a functional module or
/// not.
pub fn is_functional(&self, x: usize, y: usize) -> bool {
let x = x.as_i16_checked().expect("coordinate is too large for QR code");
let y = y.as_i16_checked().expect("coordinate is too large for QR code");
canvas::is_functional(self.version, self.version.width(), x, y)
}
/// Converts the QR code into a human-readable string. This is mainly for
/// debugging only.
pub fn to_debug_str(&self, on_char: char, off_char: char) -> String {
self.render().quiet_zone(false).dark_color(on_char).light_color(off_char).build()
}
/// Converts the QR code to a vector of booleans. Each entry represents the
/// color of the module, with "true" means dark and "false" means light.
#[deprecated(since = "0.4.0", note = "use `to_colors()` instead")]
pub fn to_vec(&self) -> Vec<bool> {
self.content.iter().map(|c| *c != Color::Light).collect()
}
/// Converts the QR code to a vector of booleans. Each entry represents the
/// color of the module, with "true" means dark and "false" means light.
#[deprecated(since = "0.4.0", note = "use `into_colors()` instead")]
pub fn into_vec(self) -> Vec<bool> {
self.content.into_iter().map(|c| c != Color::Light).collect()
}
/// Converts the QR code to a vector of colors.
pub fn to_colors(&self) -> Vec<Color> {
self.content.clone()
}
/// Converts the QR code to a vector of colors.
pub fn into_colors(self) -> Vec<Color> {
self.content
}
/// Renders the QR code into an image. The result is an image builder, which
/// you may do some additional configuration before copying it into a
/// concrete image.
///
/// # Examples
///
#[cfg_attr(feature = "image", doc = " ```rust")]
#[cfg_attr(not(feature = "image"), doc = " ```ignore")]
/// # use qrcode::QrCode;
/// # use image::Rgb;
///
/// let image = QrCode::new(b"hello").unwrap()
/// .render()
/// .dark_color(Rgb([0, 0, 128]))
/// .light_color(Rgb([224, 224, 224])) // adjust colors
/// .quiet_zone(false) // disable quiet zone (white border)
/// .min_dimensions(300, 300) // sets minimum image size
/// .build();
/// ```
///
/// Note: the `image` crate itself also provides method to rotate the image,
/// or overlay a logo on top of the QR code.
pub fn render<P: Pixel>(&self) -> Renderer<P> {
let quiet_zone = if self.version.is_micro() { 2 } else { 4 };
Renderer::new(&self.content, self.width, quiet_zone)
}
}
impl Index<(usize, usize)> for QrCode {
type Output = Color;
fn index(&self, (x, y): (usize, usize)) -> &Color {
let index = y * self.width + x;
&self.content[index]
}
}
#[cfg(test)]
mod tests {
use crate::{EcLevel, QrCode, Version};
#[test]
fn test_annex_i_qr() {
// This uses the ISO Annex I as test vector.
let code = QrCode::with_version(b"01234567", Version::Normal(1), EcLevel::M).unwrap();
assert_eq!(
&*code.to_debug_str('#', '.'),
"\
#######..#.##.#######\n\
#.....#..####.#.....#\n\
#.###.#.#.....#.###.#\n\
#.###.#.##....#.###.#\n\
#.###.#.#.###.#.###.#\n\
#.....#.#...#.#.....#\n\
#######.#.#.#.#######\n\
........#..##........\n\
#.#####..#..#.#####..\n\
...#.#.##.#.#..#.##..\n\
..#...##.#.#.#..#####\n\
....#....#.....####..\n\
...######..#.#..#....\n\
........#.#####..##..\n\
#######..##.#.##.....\n\
#.....#.#.#####...#.#\n\
#.###.#.#...#..#.##..\n\
#.###.#.##..#..#.....\n\
#.###.#.#.##.#..#.#..\n\
#.....#........##.##.\n\
#######.####.#..#.#.."
);
}
#[test]
fn test_annex_i_micro_qr() {
let code = QrCode::with_version(b"01234567", Version::Micro(2), EcLevel::L).unwrap();
assert_eq!(
&*code.to_debug_str('#', '.'),
"\
#######.#.#.#\n\
#.....#.###.#\n\
#.###.#..##.#\n\
#.###.#..####\n\
#.###.#.###..\n\
#.....#.#...#\n\
#######..####\n\
.........##..\n\
##.#....#...#\n\
.##.#.#.#.#.#\n\
###..#######.\n\
...#.#....##.\n\
###.#..##.###"
);
}
}
#[cfg(all(test, feature = "image"))]
mod image_tests {
use crate::{EcLevel, QrCode, Version};
use image::{load_from_memory, Luma, Rgb};
#[test]
fn test_annex_i_qr_as_image() {
let code = QrCode::new(b"01234567").unwrap();
let image = code.render::<Luma<u8>>().build();
let expected = load_from_memory(include_bytes!("test_annex_i_qr_as_image.png")).unwrap().to_luma();
assert_eq!(image.dimensions(), expected.dimensions());
assert_eq!(image.into_raw(), expected.into_raw());
}
#[test]
fn test_annex_i_micro_qr_as_image() {
let code = QrCode::with_version(b"01234567", Version::Micro(2), EcLevel::L).unwrap();
let image = code
.render()
.min_dimensions(200, 200)
.dark_color(Rgb([128, 0, 0]))
.light_color(Rgb([255, 255, 128]))
.build();
let expected = load_from_memory(include_bytes!("test_annex_i_micro_qr_as_image.png")).unwrap().to_rgb();
assert_eq!(image.dimensions(), expected.dimensions());
assert_eq!(image.into_raw(), expected.into_raw());
}
}
#[cfg(all(test, feature = "svg"))]
mod svg_tests {
use crate::render::svg::Color as SvgColor;
use crate::{EcLevel, QrCode, Version};
#[test]
fn test_annex_i_qr_as_svg() {
let code = QrCode::new(b"01234567").unwrap();
let image = code.render::<SvgColor>().build();
let expected = include_str!("test_annex_i_qr_as_svg.svg");
assert_eq!(&image, expected);
}
#[test]
fn test_annex_i_micro_qr_as_svg() {
let code = QrCode::with_version(b"01234567", Version::Micro(2), EcLevel::L).unwrap();
let image = code
.render()
.min_dimensions(200, 200)
.dark_color(SvgColor("#800000"))
.light_color(SvgColor("#ffff80"))
.build();
let expected = include_str!("test_annex_i_micro_qr_as_svg.svg");
assert_eq!(&image, expected);
}
}

679
src/optimize.rs Normal file
View file

@ -0,0 +1,679 @@
//! Find the optimal data mode sequence to encode a piece of data.
use crate::types::{Mode, Version};
use std::slice::Iter;
#[cfg(feature = "bench")]
extern crate test;
//------------------------------------------------------------------------------
//{{{ Segment
/// A segment of data committed to an encoding mode.
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct Segment {
/// The encoding mode of the segment of data.
pub mode: Mode,
/// The start index of the segment.
pub begin: usize,
/// The end index (exclusive) of the segment.
pub end: usize,
}
impl Segment {
/// Compute the number of bits (including the size of the mode indicator and
/// length bits) when this segment is encoded.
pub fn encoded_len(&self, version: Version) -> usize {
let byte_size = self.end - self.begin;
let chars_count = if self.mode == Mode::Kanji { byte_size / 2 } else { byte_size };
let mode_bits_count = version.mode_bits_count();
let length_bits_count = self.mode.length_bits_count(version);
let data_bits_count = self.mode.data_bits_count(chars_count);
mode_bits_count + length_bits_count + data_bits_count
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Parser
/// This iterator is basically equivalent to
///
/// ```ignore
/// data.map(|c| ExclCharSet::from_u8(*c))
/// .chain(Some(ExclCharSet::End).move_iter())
/// .enumerate()
/// ```
///
/// But the type is too hard to write, thus the new type.
///
struct EcsIter<I> {
base: I,
index: usize,
ended: bool,
}
impl<'a, I: Iterator<Item = &'a u8>> Iterator for EcsIter<I> {
type Item = (usize, ExclCharSet);
fn next(&mut self) -> Option<(usize, ExclCharSet)> {
if self.ended {
return None;
}
match self.base.next() {
None => {
self.ended = true;
Some((self.index, ExclCharSet::End))
}
Some(c) => {
let old_index = self.index;
self.index += 1;
Some((old_index, ExclCharSet::from_u8(*c)))
}
}
}
}
/// QR code data parser to classify the input into distinct segments.
pub struct Parser<'a> {
ecs_iter: EcsIter<Iter<'a, u8>>,
state: State,
begin: usize,
pending_single_byte: bool,
}
impl<'a> Parser<'a> {
/// Creates a new iterator which parse the data into segments that only
/// contains their exclusive subsets. No optimization is done at this point.
///
/// use qrcode::optimize::{Parser, Segment};
/// use qrcode::types::Mode::{Alphanumeric, Numeric, Byte};
///
/// let parse_res = Parser::new(b"ABC123abcd").collect::<Vec<Segment>>();
/// assert_eq!(parse_res, vec![Segment { mode: Alphanumeric, begin: 0, end: 3 },
/// Segment { mode: Numeric, begin: 3, end: 6 },
/// Segment { mode: Byte, begin: 6, end: 10 }]);
///
pub fn new(data: &[u8]) -> Parser {
Parser {
ecs_iter: EcsIter { base: data.iter(), index: 0, ended: false },
state: State::Init,
begin: 0,
pending_single_byte: false,
}
}
}
impl<'a> Iterator for Parser<'a> {
type Item = Segment;
fn next(&mut self) -> Option<Segment> {
if self.pending_single_byte {
self.pending_single_byte = false;
self.begin += 1;
return Some(Segment { mode: Mode::Byte, begin: self.begin - 1, end: self.begin });
}
loop {
let (i, ecs) = match self.ecs_iter.next() {
None => return None,
Some(a) => a,
};
let (next_state, action) = STATE_TRANSITION[self.state as usize + ecs as usize];
self.state = next_state;
let old_begin = self.begin;
let push_mode = match action {
Action::Idle => continue,
Action::Numeric => Mode::Numeric,
Action::Alpha => Mode::Alphanumeric,
Action::Byte => Mode::Byte,
Action::Kanji => Mode::Kanji,
Action::KanjiAndSingleByte => {
let next_begin = i - 1;
if self.begin == next_begin {
Mode::Byte
} else {
self.pending_single_byte = true;
self.begin = next_begin;
return Some(Segment { mode: Mode::Kanji, begin: old_begin, end: next_begin });
}
}
};
self.begin = i;
return Some(Segment { mode: push_mode, begin: old_begin, end: i });
}
}
}
#[cfg(test)]
mod parse_tests {
use crate::optimize::{Parser, Segment};
use crate::types::Mode;
fn parse(data: &[u8]) -> Vec<Segment> {
Parser::new(data).collect()
}
#[test]
fn test_parse_1() {
let segs = parse(b"01049123451234591597033130128%10ABC123");
assert_eq!(
segs,
vec![
Segment { mode: Mode::Numeric, begin: 0, end: 29 },
Segment { mode: Mode::Alphanumeric, begin: 29, end: 30 },
Segment { mode: Mode::Numeric, begin: 30, end: 32 },
Segment { mode: Mode::Alphanumeric, begin: 32, end: 35 },
Segment { mode: Mode::Numeric, begin: 35, end: 38 },
]
);
}
#[test]
fn test_parse_shift_jis_example_1() {
let segs = parse(b"\x82\xa0\x81\x41\x41\xb1\x81\xf0"); // "あ、AアÅ"
assert_eq!(
segs,
vec![
Segment { mode: Mode::Kanji, begin: 0, end: 4 },
Segment { mode: Mode::Alphanumeric, begin: 4, end: 5 },
Segment { mode: Mode::Byte, begin: 5, end: 6 },
Segment { mode: Mode::Kanji, begin: 6, end: 8 },
]
);
}
#[test]
fn test_parse_utf_8() {
// Mojibake?
let segs = parse(b"\xe3\x81\x82\xe3\x80\x81A\xef\xbd\xb1\xe2\x84\xab");
assert_eq!(
segs,
vec![
Segment { mode: Mode::Kanji, begin: 0, end: 4 },
Segment { mode: Mode::Byte, begin: 4, end: 5 },
Segment { mode: Mode::Kanji, begin: 5, end: 7 },
Segment { mode: Mode::Byte, begin: 7, end: 10 },
Segment { mode: Mode::Kanji, begin: 10, end: 12 },
Segment { mode: Mode::Byte, begin: 12, end: 13 },
]
);
}
#[test]
fn test_not_kanji_1() {
let segs = parse(b"\x81\x30");
assert_eq!(
segs,
vec![Segment { mode: Mode::Byte, begin: 0, end: 1 }, Segment { mode: Mode::Numeric, begin: 1, end: 2 },]
);
}
#[test]
fn test_not_kanji_2() {
// Note that it's implementation detail that the byte seq is split into
// two. Perhaps adjust the test to check for this.
let segs = parse(b"\xeb\xc0");
assert_eq!(
segs,
vec![Segment { mode: Mode::Byte, begin: 0, end: 1 }, Segment { mode: Mode::Byte, begin: 1, end: 2 },]
);
}
#[test]
fn test_not_kanji_3() {
let segs = parse(b"\x81\x7f");
assert_eq!(
segs,
vec![Segment { mode: Mode::Byte, begin: 0, end: 1 }, Segment { mode: Mode::Byte, begin: 1, end: 2 },]
);
}
#[test]
fn test_not_kanji_4() {
let segs = parse(b"\x81\x40\x81");
assert_eq!(
segs,
vec![Segment { mode: Mode::Kanji, begin: 0, end: 2 }, Segment { mode: Mode::Byte, begin: 2, end: 3 },]
);
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Optimizer
pub struct Optimizer<I> {
parser: I,
last_segment: Segment,
last_segment_size: usize,
version: Version,
ended: bool,
}
impl<I: Iterator<Item = Segment>> Optimizer<I> {
/// Optimize the segments by combining adjacent segments when possible.
///
/// Currently this method uses a greedy algorithm by combining segments from
/// left to right until the new segment is longer than before. This method
/// does *not* use Annex J from the ISO standard.
///
pub fn new(mut segments: I, version: Version) -> Self {
match segments.next() {
None => Self {
parser: segments,
last_segment: Segment { mode: Mode::Numeric, begin: 0, end: 0 },
last_segment_size: 0,
version,
ended: true,
},
Some(segment) => Self {
parser: segments,
last_segment: segment,
last_segment_size: segment.encoded_len(version),
version,
ended: false,
},
}
}
}
impl<'a> Parser<'a> {
pub fn optimize(self, version: Version) -> Optimizer<Parser<'a>> {
Optimizer::new(self, version)
}
}
impl<I: Iterator<Item = Segment>> Iterator for Optimizer<I> {
type Item = Segment;
fn next(&mut self) -> Option<Segment> {
if self.ended {
return None;
}
loop {
match self.parser.next() {
None => {
self.ended = true;
return Some(self.last_segment);
}
Some(segment) => {
let seg_size = segment.encoded_len(self.version);
let new_segment = Segment {
mode: self.last_segment.mode.max(segment.mode),
begin: self.last_segment.begin,
end: segment.end,
};
let new_size = new_segment.encoded_len(self.version);
if self.last_segment_size + seg_size >= new_size {
self.last_segment = new_segment;
self.last_segment_size = new_size;
} else {
let old_segment = self.last_segment;
self.last_segment = segment;
self.last_segment_size = seg_size;
return Some(old_segment);
}
}
}
}
}
}
/// Computes the total encoded length of all segments.
pub fn total_encoded_len(segments: &[Segment], version: Version) -> usize {
segments.iter().map(|seg| seg.encoded_len(version)).sum()
}
#[cfg(test)]
mod optimize_tests {
use crate::optimize::{total_encoded_len, Optimizer, Segment};
use crate::types::{Mode, Version};
fn test_optimization_result(given: Vec<Segment>, expected: Vec<Segment>, version: Version) {
let prev_len = total_encoded_len(&*given, version);
let opt_segs = Optimizer::new(given.iter().map(|seg| *seg), version).collect::<Vec<_>>();
let new_len = total_encoded_len(&*opt_segs, version);
if given != opt_segs {
assert!(prev_len > new_len, "{} > {}", prev_len, new_len);
}
assert!(
opt_segs == expected,
"Optimization gave something better: {} < {} ({:?})",
new_len,
total_encoded_len(&*expected, version),
opt_segs
);
}
#[test]
fn test_example_1() {
test_optimization_result(
vec![
Segment { mode: Mode::Alphanumeric, begin: 0, end: 3 },
Segment { mode: Mode::Numeric, begin: 3, end: 6 },
Segment { mode: Mode::Byte, begin: 6, end: 10 },
],
vec![
Segment { mode: Mode::Alphanumeric, begin: 0, end: 6 },
Segment { mode: Mode::Byte, begin: 6, end: 10 },
],
Version::Normal(1),
);
}
#[test]
fn test_example_2() {
test_optimization_result(
vec![
Segment { mode: Mode::Numeric, begin: 0, end: 29 },
Segment { mode: Mode::Alphanumeric, begin: 29, end: 30 },
Segment { mode: Mode::Numeric, begin: 30, end: 32 },
Segment { mode: Mode::Alphanumeric, begin: 32, end: 35 },
Segment { mode: Mode::Numeric, begin: 35, end: 38 },
],
vec![
Segment { mode: Mode::Numeric, begin: 0, end: 29 },
Segment { mode: Mode::Alphanumeric, begin: 29, end: 38 },
],
Version::Normal(9),
);
}
#[test]
fn test_example_3() {
test_optimization_result(
vec![
Segment { mode: Mode::Kanji, begin: 0, end: 4 },
Segment { mode: Mode::Alphanumeric, begin: 4, end: 5 },
Segment { mode: Mode::Byte, begin: 5, end: 6 },
Segment { mode: Mode::Kanji, begin: 6, end: 8 },
],
vec![Segment { mode: Mode::Byte, begin: 0, end: 8 }],
Version::Normal(1),
);
}
#[test]
fn test_example_4() {
test_optimization_result(
vec![Segment { mode: Mode::Kanji, begin: 0, end: 10 }, Segment { mode: Mode::Byte, begin: 10, end: 11 }],
vec![Segment { mode: Mode::Kanji, begin: 0, end: 10 }, Segment { mode: Mode::Byte, begin: 10, end: 11 }],
Version::Normal(1),
);
}
#[test]
fn test_annex_j_guideline_1a() {
test_optimization_result(
vec![
Segment { mode: Mode::Numeric, begin: 0, end: 3 },
Segment { mode: Mode::Alphanumeric, begin: 3, end: 4 },
],
vec![
Segment { mode: Mode::Numeric, begin: 0, end: 3 },
Segment { mode: Mode::Alphanumeric, begin: 3, end: 4 },
],
Version::Micro(2),
);
}
#[test]
fn test_annex_j_guideline_1b() {
test_optimization_result(
vec![
Segment { mode: Mode::Numeric, begin: 0, end: 2 },
Segment { mode: Mode::Alphanumeric, begin: 2, end: 4 },
],
vec![Segment { mode: Mode::Alphanumeric, begin: 0, end: 4 }],
Version::Micro(2),
);
}
#[test]
fn test_annex_j_guideline_1c() {
test_optimization_result(
vec![
Segment { mode: Mode::Numeric, begin: 0, end: 3 },
Segment { mode: Mode::Alphanumeric, begin: 3, end: 4 },
],
vec![Segment { mode: Mode::Alphanumeric, begin: 0, end: 4 }],
Version::Micro(3),
);
}
}
#[cfg(feature = "bench")]
#[bench]
fn bench_optimize(bencher: &mut test::Bencher) {
use crate::types::Version;
let data = b"QR\x83R\x81[\x83h\x81i\x83L\x83\x85\x81[\x83A\x81[\x83\x8b\x83R\x81[\x83h\x81j\
\x82\xc6\x82\xcd\x81A1994\x94N\x82\xc9\x83f\x83\x93\x83\\\x81[\x82\xcc\x8aJ\
\x94\xad\x95\x94\x96\xe5\x81i\x8c\xbb\x8d\xdd\x82\xcd\x95\xaa\x97\xa3\x82\xb5\x83f\
\x83\x93\x83\\\x81[\x83E\x83F\x81[\x83u\x81j\x82\xaa\x8aJ\x94\xad\x82\xb5\x82\xbd\
\x83}\x83g\x83\x8a\x83b\x83N\x83X\x8c^\x93\xf1\x8e\x9f\x8c\xb3\x83R\x81[\x83h\
\x82\xc5\x82\xa0\x82\xe9\x81B\x82\xc8\x82\xa8\x81AQR\x83R\x81[\x83h\x82\xc6\
\x82\xa2\x82\xa4\x96\xbc\x8f\xcc\x81i\x82\xa8\x82\xe6\x82\xd1\x92P\x8c\xea\x81j\
\x82\xcd\x83f\x83\x93\x83\\\x81[\x83E\x83F\x81[\x83u\x82\xcc\x93o\x98^\x8f\xa4\
\x95W\x81i\x91\xe64075066\x8d\x86\x81j\x82\xc5\x82\xa0\x82\xe9\x81BQR\x82\xcd\
Quick Response\x82\xc9\x97R\x97\x88\x82\xb5\x81A\x8d\x82\x91\xac\x93\xc7\x82\xdd\
\x8e\xe6\x82\xe8\x82\xaa\x82\xc5\x82\xab\x82\xe9\x82\xe6\x82\xa4\x82\xc9\x8aJ\
\x94\xad\x82\xb3\x82\xea\x82\xbd\x81B\x93\x96\x8f\x89\x82\xcd\x8e\xa9\x93\xae\
\x8e\xd4\x95\x94\x95i\x8dH\x8f\xea\x82\xe2\x94z\x91\x97\x83Z\x83\x93\x83^\x81[\
\x82\xc8\x82\xc7\x82\xc5\x82\xcc\x8eg\x97p\x82\xf0\x94O\x93\xaa\x82\xc9\x8aJ\
\x94\xad\x82\xb3\x82\xea\x82\xbd\x82\xaa\x81A\x8c\xbb\x8d\xdd\x82\xc5\x82\xcd\x83X\
\x83}\x81[\x83g\x83t\x83H\x83\x93\x82\xcc\x95\x81\x8by\x82\xc8\x82\xc7\x82\xc9\
\x82\xe6\x82\xe8\x93\xfa\x96{\x82\xc9\x8c\xc0\x82\xe7\x82\xb8\x90\xa2\x8aE\x93I\
\x82\xc9\x95\x81\x8by\x82\xb5\x82\xc4\x82\xa2\x82\xe9\x81B";
bencher.iter(|| Parser::new(data).optimize(Version::Normal(15)));
}
//}}}
//------------------------------------------------------------------------------
//{{{ Internal types and data for parsing
/// All values of `u8` can be split into 9 different character sets when
/// determining which encoding to use. This enum represents these groupings for
/// parsing purpose.
#[derive(Copy, Clone)]
enum ExclCharSet {
/// The end of string.
End = 0,
/// All symbols supported by the Alphanumeric encoding, i.e. space, `$`, `%`,
/// `*`, `+`, `-`, `.`, `/` and `:`.
Symbol = 1,
/// All numbers (09).
Numeric = 2,
/// All uppercase letters (AZ). These characters may also appear in the
/// second byte of a Shift JIS 2-byte encoding.
Alpha = 3,
/// The first byte of a Shift JIS 2-byte encoding, in the range 0x810x9f.
KanjiHi1 = 4,
/// The first byte of a Shift JIS 2-byte encoding, in the range 0xe00xea.
KanjiHi2 = 5,
/// The first byte of a Shift JIS 2-byte encoding, of value 0xeb. This is
/// different from the other two range that the second byte has a smaller
/// range.
KanjiHi3 = 6,
/// The second byte of a Shift JIS 2-byte encoding, in the range 0x400xbf,
/// excluding letters (covered by `Alpha`), 0x810x9f (covered by `KanjiHi1`),
/// and the invalid byte 0x7f.
KanjiLo1 = 7,
/// The second byte of a Shift JIS 2-byte encoding, in the range 0xc00xfc,
/// excluding the range 0xe00xeb (covered by `KanjiHi2` and `KanjiHi3`).
/// This half of byte-pair cannot appear as the second byte leaded by
/// `KanjiHi3`.
KanjiLo2 = 8,
/// Any other values not covered by the above character sets.
Byte = 9,
}
impl ExclCharSet {
/// Determines which character set a byte is in.
fn from_u8(c: u8) -> Self {
match c {
0x20 | 0x24 | 0x25 | 0x2a | 0x2b | 0x2d..=0x2f | 0x3a => ExclCharSet::Symbol,
0x30..=0x39 => ExclCharSet::Numeric,
0x41..=0x5a => ExclCharSet::Alpha,
0x81..=0x9f => ExclCharSet::KanjiHi1,
0xe0..=0xea => ExclCharSet::KanjiHi2,
0xeb => ExclCharSet::KanjiHi3,
0x40 | 0x5b..=0x7e | 0x80 | 0xa0..=0xbf => ExclCharSet::KanjiLo1,
0xc0..=0xdf | 0xec..=0xfc => ExclCharSet::KanjiLo2,
_ => ExclCharSet::Byte,
}
}
}
/// The current parsing state.
#[derive(Copy, Clone)]
enum State {
/// Just initialized.
Init = 0,
/// Inside a string that can be exclusively encoded as Numeric.
Numeric = 10,
/// Inside a string that can be exclusively encoded as Alphanumeric.
Alpha = 20,
/// Inside a string that can be exclusively encoded as 8-Bit Byte.
Byte = 30,
/// Just encountered the first byte of a Shift JIS 2-byte sequence of the
/// set `KanjiHi1` or `KanjiHi2`.
KanjiHi12 = 40,
/// Just encountered the first byte of a Shift JIS 2-byte sequence of the
/// set `KanjiHi3`.
KanjiHi3 = 50,
/// Inside a string that can be exclusively encoded as Kanji.
Kanji = 60,
}
/// What should the parser do after a state transition.
#[derive(Copy, Clone)]
enum Action {
/// The parser should do nothing.
Idle,
/// Push the current segment as a Numeric string, and reset the marks.
Numeric,
/// Push the current segment as an Alphanumeric string, and reset the marks.
Alpha,
/// Push the current segment as a 8-Bit Byte string, and reset the marks.
Byte,
/// Push the current segment as a Kanji string, and reset the marks.
Kanji,
/// Push the current segment excluding the last byte as a Kanji string, then
/// push the remaining single byte as a Byte string, and reset the marks.
KanjiAndSingleByte,
}
static STATE_TRANSITION: [(State, Action); 70] = [
// STATE_TRANSITION[current_state + next_character] == (next_state, what_to_do)
// Init state:
(State::Init, Action::Idle), // End
(State::Alpha, Action::Idle), // Symbol
(State::Numeric, Action::Idle), // Numeric
(State::Alpha, Action::Idle), // Alpha
(State::KanjiHi12, Action::Idle), // KanjiHi1
(State::KanjiHi12, Action::Idle), // KanjiHi2
(State::KanjiHi3, Action::Idle), // KanjiHi3
(State::Byte, Action::Idle), // KanjiLo1
(State::Byte, Action::Idle), // KanjiLo2
(State::Byte, Action::Idle), // Byte
// Numeric state:
(State::Init, Action::Numeric), // End
(State::Alpha, Action::Numeric), // Symbol
(State::Numeric, Action::Idle), // Numeric
(State::Alpha, Action::Numeric), // Alpha
(State::KanjiHi12, Action::Numeric), // KanjiHi1
(State::KanjiHi12, Action::Numeric), // KanjiHi2
(State::KanjiHi3, Action::Numeric), // KanjiHi3
(State::Byte, Action::Numeric), // KanjiLo1
(State::Byte, Action::Numeric), // KanjiLo2
(State::Byte, Action::Numeric), // Byte
// Alpha state:
(State::Init, Action::Alpha), // End
(State::Alpha, Action::Idle), // Symbol
(State::Numeric, Action::Alpha), // Numeric
(State::Alpha, Action::Idle), // Alpha
(State::KanjiHi12, Action::Alpha), // KanjiHi1
(State::KanjiHi12, Action::Alpha), // KanjiHi2
(State::KanjiHi3, Action::Alpha), // KanjiHi3
(State::Byte, Action::Alpha), // KanjiLo1
(State::Byte, Action::Alpha), // KanjiLo2
(State::Byte, Action::Alpha), // Byte
// Byte state:
(State::Init, Action::Byte), // End
(State::Alpha, Action::Byte), // Symbol
(State::Numeric, Action::Byte), // Numeric
(State::Alpha, Action::Byte), // Alpha
(State::KanjiHi12, Action::Byte), // KanjiHi1
(State::KanjiHi12, Action::Byte), // KanjiHi2
(State::KanjiHi3, Action::Byte), // KanjiHi3
(State::Byte, Action::Idle), // KanjiLo1
(State::Byte, Action::Idle), // KanjiLo2
(State::Byte, Action::Idle), // Byte
// KanjiHi12 state:
(State::Init, Action::KanjiAndSingleByte), // End
(State::Alpha, Action::KanjiAndSingleByte), // Symbol
(State::Numeric, Action::KanjiAndSingleByte), // Numeric
(State::Kanji, Action::Idle), // Alpha
(State::Kanji, Action::Idle), // KanjiHi1
(State::Kanji, Action::Idle), // KanjiHi2
(State::Kanji, Action::Idle), // KanjiHi3
(State::Kanji, Action::Idle), // KanjiLo1
(State::Kanji, Action::Idle), // KanjiLo2
(State::Byte, Action::KanjiAndSingleByte), // Byte
// KanjiHi3 state:
(State::Init, Action::KanjiAndSingleByte), // End
(State::Alpha, Action::KanjiAndSingleByte), // Symbol
(State::Numeric, Action::KanjiAndSingleByte), // Numeric
(State::Kanji, Action::Idle), // Alpha
(State::Kanji, Action::Idle), // KanjiHi1
(State::KanjiHi12, Action::KanjiAndSingleByte), // KanjiHi2
(State::KanjiHi3, Action::KanjiAndSingleByte), // KanjiHi3
(State::Kanji, Action::Idle), // KanjiLo1
(State::Byte, Action::KanjiAndSingleByte), // KanjiLo2
(State::Byte, Action::KanjiAndSingleByte), // Byte
// Kanji state:
(State::Init, Action::Kanji), // End
(State::Alpha, Action::Kanji), // Symbol
(State::Numeric, Action::Kanji), // Numeric
(State::Alpha, Action::Kanji), // Alpha
(State::KanjiHi12, Action::Idle), // KanjiHi1
(State::KanjiHi12, Action::Idle), // KanjiHi2
(State::KanjiHi3, Action::Idle), // KanjiHi3
(State::Byte, Action::Kanji), // KanjiLo1
(State::Byte, Action::Kanji), // KanjiLo2
(State::Byte, Action::Kanji), // Byte
];
//}}}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,742 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="Source to the Rust file `src/lib.rs`.">
<meta name="keywords" content="rust, rustlang, rust-lang">
<title>lib.rs.html -- source</title>
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content source"><pre class="line-numbers"><span id="1"> 1</span>
<span id="2"> 2</span>
<span id="3"> 3</span>
<span id="4"> 4</span>
<span id="5"> 5</span>
<span id="6"> 6</span>
<span id="7"> 7</span>
<span id="8"> 8</span>
<span id="9"> 9</span>
<span id="10"> 10</span>
<span id="11"> 11</span>
<span id="12"> 12</span>
<span id="13"> 13</span>
<span id="14"> 14</span>
<span id="15"> 15</span>
<span id="16"> 16</span>
<span id="17"> 17</span>
<span id="18"> 18</span>
<span id="19"> 19</span>
<span id="20"> 20</span>
<span id="21"> 21</span>
<span id="22"> 22</span>
<span id="23"> 23</span>
<span id="24"> 24</span>
<span id="25"> 25</span>
<span id="26"> 26</span>
<span id="27"> 27</span>
<span id="28"> 28</span>
<span id="29"> 29</span>
<span id="30"> 30</span>
<span id="31"> 31</span>
<span id="32"> 32</span>
<span id="33"> 33</span>
<span id="34"> 34</span>
<span id="35"> 35</span>
<span id="36"> 36</span>
<span id="37"> 37</span>
<span id="38"> 38</span>
<span id="39"> 39</span>
<span id="40"> 40</span>
<span id="41"> 41</span>
<span id="42"> 42</span>
<span id="43"> 43</span>
<span id="44"> 44</span>
<span id="45"> 45</span>
<span id="46"> 46</span>
<span id="47"> 47</span>
<span id="48"> 48</span>
<span id="49"> 49</span>
<span id="50"> 50</span>
<span id="51"> 51</span>
<span id="52"> 52</span>
<span id="53"> 53</span>
<span id="54"> 54</span>
<span id="55"> 55</span>
<span id="56"> 56</span>
<span id="57"> 57</span>
<span id="58"> 58</span>
<span id="59"> 59</span>
<span id="60"> 60</span>
<span id="61"> 61</span>
<span id="62"> 62</span>
<span id="63"> 63</span>
<span id="64"> 64</span>
<span id="65"> 65</span>
<span id="66"> 66</span>
<span id="67"> 67</span>
<span id="68"> 68</span>
<span id="69"> 69</span>
<span id="70"> 70</span>
<span id="71"> 71</span>
<span id="72"> 72</span>
<span id="73"> 73</span>
<span id="74"> 74</span>
<span id="75"> 75</span>
<span id="76"> 76</span>
<span id="77"> 77</span>
<span id="78"> 78</span>
<span id="79"> 79</span>
<span id="80"> 80</span>
<span id="81"> 81</span>
<span id="82"> 82</span>
<span id="83"> 83</span>
<span id="84"> 84</span>
<span id="85"> 85</span>
<span id="86"> 86</span>
<span id="87"> 87</span>
<span id="88"> 88</span>
<span id="89"> 89</span>
<span id="90"> 90</span>
<span id="91"> 91</span>
<span id="92"> 92</span>
<span id="93"> 93</span>
<span id="94"> 94</span>
<span id="95"> 95</span>
<span id="96"> 96</span>
<span id="97"> 97</span>
<span id="98"> 98</span>
<span id="99"> 99</span>
<span id="100">100</span>
<span id="101">101</span>
<span id="102">102</span>
<span id="103">103</span>
<span id="104">104</span>
<span id="105">105</span>
<span id="106">106</span>
<span id="107">107</span>
<span id="108">108</span>
<span id="109">109</span>
<span id="110">110</span>
<span id="111">111</span>
<span id="112">112</span>
<span id="113">113</span>
<span id="114">114</span>
<span id="115">115</span>
<span id="116">116</span>
<span id="117">117</span>
<span id="118">118</span>
<span id="119">119</span>
<span id="120">120</span>
<span id="121">121</span>
<span id="122">122</span>
<span id="123">123</span>
<span id="124">124</span>
<span id="125">125</span>
<span id="126">126</span>
<span id="127">127</span>
<span id="128">128</span>
<span id="129">129</span>
<span id="130">130</span>
<span id="131">131</span>
<span id="132">132</span>
<span id="133">133</span>
<span id="134">134</span>
<span id="135">135</span>
<span id="136">136</span>
<span id="137">137</span>
<span id="138">138</span>
<span id="139">139</span>
<span id="140">140</span>
<span id="141">141</span>
<span id="142">142</span>
<span id="143">143</span>
<span id="144">144</span>
<span id="145">145</span>
<span id="146">146</span>
<span id="147">147</span>
<span id="148">148</span>
<span id="149">149</span>
<span id="150">150</span>
<span id="151">151</span>
<span id="152">152</span>
<span id="153">153</span>
<span id="154">154</span>
<span id="155">155</span>
<span id="156">156</span>
<span id="157">157</span>
<span id="158">158</span>
<span id="159">159</span>
<span id="160">160</span>
<span id="161">161</span>
<span id="162">162</span>
<span id="163">163</span>
<span id="164">164</span>
<span id="165">165</span>
<span id="166">166</span>
<span id="167">167</span>
<span id="168">168</span>
<span id="169">169</span>
<span id="170">170</span>
<span id="171">171</span>
<span id="172">172</span>
<span id="173">173</span>
<span id="174">174</span>
<span id="175">175</span>
<span id="176">176</span>
<span id="177">177</span>
<span id="178">178</span>
<span id="179">179</span>
<span id="180">180</span>
<span id="181">181</span>
<span id="182">182</span>
<span id="183">183</span>
<span id="184">184</span>
<span id="185">185</span>
<span id="186">186</span>
<span id="187">187</span>
<span id="188">188</span>
<span id="189">189</span>
<span id="190">190</span>
<span id="191">191</span>
<span id="192">192</span>
<span id="193">193</span>
<span id="194">194</span>
<span id="195">195</span>
<span id="196">196</span>
<span id="197">197</span>
<span id="198">198</span>
<span id="199">199</span>
<span id="200">200</span>
<span id="201">201</span>
<span id="202">202</span>
<span id="203">203</span>
<span id="204">204</span>
<span id="205">205</span>
<span id="206">206</span>
<span id="207">207</span>
<span id="208">208</span>
<span id="209">209</span>
<span id="210">210</span>
<span id="211">211</span>
<span id="212">212</span>
<span id="213">213</span>
<span id="214">214</span>
<span id="215">215</span>
<span id="216">216</span>
<span id="217">217</span>
<span id="218">218</span>
<span id="219">219</span>
<span id="220">220</span>
<span id="221">221</span>
<span id="222">222</span>
<span id="223">223</span>
<span id="224">224</span>
<span id="225">225</span>
<span id="226">226</span>
<span id="227">227</span>
<span id="228">228</span>
<span id="229">229</span>
<span id="230">230</span>
<span id="231">231</span>
<span id="232">232</span>
<span id="233">233</span>
<span id="234">234</span>
<span id="235">235</span>
<span id="236">236</span>
<span id="237">237</span>
<span id="238">238</span>
<span id="239">239</span>
<span id="240">240</span>
<span id="241">241</span>
<span id="242">242</span>
<span id="243">243</span>
<span id="244">244</span>
<span id="245">245</span>
<span id="246">246</span>
<span id="247">247</span>
<span id="248">248</span>
<span id="249">249</span>
<span id="250">250</span>
<span id="251">251</span>
<span id="252">252</span>
<span id="253">253</span>
<span id="254">254</span>
<span id="255">255</span>
<span id="256">256</span>
<span id="257">257</span>
<span id="258">258</span>
<span id="259">259</span>
<span id="260">260</span>
<span id="261">261</span>
<span id="262">262</span>
<span id="263">263</span>
<span id="264">264</span>
<span id="265">265</span>
<span id="266">266</span>
<span id="267">267</span>
<span id="268">268</span>
<span id="269">269</span>
<span id="270">270</span>
<span id="271">271</span>
<span id="272">272</span>
<span id="273">273</span>
<span id="274">274</span>
<span id="275">275</span>
<span id="276">276</span>
<span id="277">277</span>
<span id="278">278</span>
<span id="279">279</span>
<span id="280">280</span>
<span id="281">281</span>
<span id="282">282</span>
<span id="283">283</span>
<span id="284">284</span>
<span id="285">285</span>
<span id="286">286</span>
<span id="287">287</span>
<span id="288">288</span>
<span id="289">289</span>
<span id="290">290</span>
<span id="291">291</span>
<span id="292">292</span>
<span id="293">293</span>
<span id="294">294</span>
<span id="295">295</span>
<span id="296">296</span>
<span id="297">297</span>
<span id="298">298</span>
<span id="299">299</span>
<span id="300">300</span>
<span id="301">301</span>
<span id="302">302</span>
<span id="303">303</span>
<span id="304">304</span>
<span id="305">305</span>
<span id="306">306</span>
<span id="307">307</span>
<span id="308">308</span>
<span id="309">309</span>
<span id="310">310</span>
<span id="311">311</span>
<span id="312">312</span>
<span id="313">313</span>
<span id="314">314</span>
<span id="315">315</span>
<span id="316">316</span>
</pre><pre class='rust '>
<span class='doccomment'>//! QRCode encoder</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! This crate provides a QR code and Micro QR code encoder for binary data.</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//! extern crate image;</span>
<span class='doccomment'>//! extern crate qrcode;</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! use image::GrayImage;</span>
<span class='doccomment'>//! use qrcode::QrCode;</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! # fn main() {</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! let code = QrCode::new(b&quot;Some content here.&quot;);</span>
<span class='doccomment'>//! match code {</span>
<span class='doccomment'>//! Err(err) =&gt; panic!(&quot;Failed to encode the QR code: {:?}&quot;, err),</span>
<span class='doccomment'>//! Ok(code) =&gt; {</span>
<span class='doccomment'>//! let image: GrayImage = code.render().min_width(100).to_image();</span>
<span class='doccomment'>//! // render `image`...</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//! }</span>
<span class='doccomment'>//!</span>
<span class='doccomment'>//! # }</span>
<span class='doccomment'>//! ```</span>
<span class='doccomment'>//!</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg_attr</span>(<span class='ident'>feature</span><span class='op'>=</span><span class='string'>&quot;bench&quot;</span>, <span class='ident'>feature</span>(<span class='ident'>test</span>))]</span> <span class='comment'>// Unstable libraries</span>
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span><span class='op'>=</span><span class='string'>&quot;bench&quot;</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>test</span>;
<span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>num_traits</span>;
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span><span class='op'>=</span><span class='string'>&quot;image&quot;</span>)]</span> <span class='kw'>extern</span> <span class='kw'>crate</span> <span class='ident'>image</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>ops</span>::<span class='ident'>Index</span>;
<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>types</span>;
<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>bits</span>;
<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>optimize</span>;
<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>ec</span>;
<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>canvas</span>;
<span class='kw'>pub</span> <span class='kw'>mod</span> <span class='ident'>render</span>;
<span class='kw'>pub</span> <span class='kw'>use</span> <span class='ident'>types</span>::{<span class='ident'>QrResult</span>, <span class='ident'>EcLevel</span>, <span class='ident'>Version</span>};
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span><span class='op'>=</span><span class='string'>&quot;image&quot;</span>)]</span> <span class='kw'>use</span> <span class='ident'>render</span>::{<span class='ident'>BlankAndWhitePixel</span>, <span class='ident'>Renderer</span>};
<span class='doccomment'>/// The encoded QR code symbol.</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Clone</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>QrCode</span> {
<span class='ident'>content</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>bool</span><span class='op'>&gt;</span>,
<span class='ident'>version</span>: <span class='ident'>Version</span>,
<span class='ident'>ec_level</span>: <span class='ident'>EcLevel</span>,
<span class='ident'>width</span>: <span class='ident'>usize</span>,
}
<span class='kw'>impl</span> <span class='ident'>QrCode</span> {
<span class='doccomment'>/// Constructs a new QR code which automatically encodes the given data.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// This method uses the &quot;medium&quot; error correction level and automatically</span>
<span class='doccomment'>/// chooses the smallest QR code.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::QrCode;</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// let code = QrCode::new(b&quot;Some data&quot;).unwrap();</span>
<span class='doccomment'>///</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span><span class='op'>&lt;</span><span class='ident'>D</span>: <span class='ident'>AsRef</span><span class='op'>&lt;</span>[<span class='ident'>u8</span>]<span class='op'>&gt;&gt;</span>(<span class='ident'>data</span>: <span class='ident'>D</span>) <span class='op'>-&gt;</span> <span class='ident'>QrResult</span><span class='op'>&lt;</span><span class='ident'>QrCode</span><span class='op'>&gt;</span> {
<span class='ident'>QrCode</span>::<span class='ident'>with_error_correction_level</span>(<span class='ident'>data</span>, <span class='ident'>EcLevel</span>::<span class='ident'>M</span>)
}
<span class='doccomment'>/// Constructs a new QR code which automatically encodes the given data at a</span>
<span class='doccomment'>/// specific error correction level.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// This method automatically chooses the smallest QR code.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::{QrCode, EcLevel};</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// let code = QrCode::with_error_correction_level(b&quot;Some data&quot;, EcLevel::H).unwrap();</span>
<span class='doccomment'>///</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_error_correction_level</span><span class='op'>&lt;</span><span class='ident'>D</span>: <span class='ident'>AsRef</span><span class='op'>&lt;</span>[<span class='ident'>u8</span>]<span class='op'>&gt;&gt;</span>(<span class='ident'>data</span>: <span class='ident'>D</span>, <span class='ident'>ec_level</span>: <span class='ident'>EcLevel</span>) <span class='op'>-&gt;</span> <span class='ident'>QrResult</span><span class='op'>&lt;</span><span class='ident'>QrCode</span><span class='op'>&gt;</span> {
<span class='kw'>let</span> <span class='ident'>bits</span> <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>bits</span>::<span class='ident'>encode_auto</span>(<span class='ident'>data</span>.<span class='ident'>as_ref</span>(), <span class='ident'>ec_level</span>));
<span class='ident'>QrCode</span>::<span class='ident'>with_bits</span>(<span class='ident'>bits</span>, <span class='ident'>ec_level</span>)
}
<span class='doccomment'>/// Constructs a new QR code for the given version and error correction</span>
<span class='doccomment'>/// level.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::{QrCode, Version, EcLevel};</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// let code = QrCode::with_version(b&quot;Some data&quot;, Version::Normal(5), EcLevel::M).unwrap();</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// This method can also be used to generate Micro QR code.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::{QrCode, Version, EcLevel};</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// let micro_code = QrCode::with_version(b&quot;123&quot;, Version::Micro(1), EcLevel::L).unwrap();</span>
<span class='doccomment'>///</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_version</span><span class='op'>&lt;</span><span class='ident'>D</span>: <span class='ident'>AsRef</span><span class='op'>&lt;</span>[<span class='ident'>u8</span>]<span class='op'>&gt;&gt;</span>(<span class='ident'>data</span>: <span class='ident'>D</span>, <span class='ident'>version</span>: <span class='ident'>Version</span>, <span class='ident'>ec_level</span>: <span class='ident'>EcLevel</span>) <span class='op'>-&gt;</span> <span class='ident'>QrResult</span><span class='op'>&lt;</span><span class='ident'>QrCode</span><span class='op'>&gt;</span> {
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>bits</span> <span class='op'>=</span> <span class='ident'>bits</span>::<span class='ident'>Bits</span>::<span class='ident'>new</span>(<span class='ident'>version</span>);
<span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>bits</span>.<span class='ident'>push_optimal_data</span>(<span class='ident'>data</span>.<span class='ident'>as_ref</span>()));
<span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>bits</span>.<span class='ident'>push_terminator</span>(<span class='ident'>ec_level</span>));
<span class='ident'>QrCode</span>::<span class='ident'>with_bits</span>(<span class='ident'>bits</span>, <span class='ident'>ec_level</span>)
}
<span class='doccomment'>/// Constructs a new QR code with encoded bits.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Use this method only if there are very special need to manipulate the</span>
<span class='doccomment'>/// raw bits before encoding. Some examples are:</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// * Encode data using specific character set with ECI</span>
<span class='doccomment'>/// * Use the FNC1 modes</span>
<span class='doccomment'>/// * Avoid the optimal segmentation algorithm</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// See the `Bits` structure for detail.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// #![allow(unused_must_use)]</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::{QrCode, Version, EcLevel};</span>
<span class='doccomment'>/// use qrcode::bits::Bits;</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// let mut bits = Bits::new(Version::Normal(1));</span>
<span class='doccomment'>/// bits.push_eci_designator(9);</span>
<span class='doccomment'>/// bits.push_byte_data(b&quot;\xca\xfe\xe4\xe9\xea\xe1\xf2 QR&quot;);</span>
<span class='doccomment'>/// bits.push_terminator(EcLevel::L);</span>
<span class='doccomment'>/// let qrcode = QrCode::with_bits(bits, EcLevel::L);</span>
<span class='doccomment'>///</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>with_bits</span>(<span class='ident'>bits</span>: <span class='ident'>bits</span>::<span class='ident'>Bits</span>, <span class='ident'>ec_level</span>: <span class='ident'>EcLevel</span>) <span class='op'>-&gt;</span> <span class='ident'>QrResult</span><span class='op'>&lt;</span><span class='ident'>QrCode</span><span class='op'>&gt;</span> {
<span class='kw'>let</span> <span class='ident'>version</span> <span class='op'>=</span> <span class='ident'>bits</span>.<span class='ident'>version</span>();
<span class='kw'>let</span> <span class='ident'>data</span> <span class='op'>=</span> <span class='ident'>bits</span>.<span class='ident'>into_bytes</span>();
<span class='kw'>let</span> (<span class='ident'>encoded_data</span>, <span class='ident'>ec_data</span>) <span class='op'>=</span> <span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>ec</span>::<span class='ident'>construct_codewords</span>(<span class='kw-2'>&amp;</span><span class='op'>*</span><span class='ident'>data</span>, <span class='ident'>version</span>, <span class='ident'>ec_level</span>));
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>canvas</span> <span class='op'>=</span> <span class='ident'>canvas</span>::<span class='ident'>Canvas</span>::<span class='ident'>new</span>(<span class='ident'>version</span>, <span class='ident'>ec_level</span>);
<span class='ident'>canvas</span>.<span class='ident'>draw_all_functional_patterns</span>();
<span class='ident'>canvas</span>.<span class='ident'>draw_data</span>(<span class='kw-2'>&amp;</span><span class='op'>*</span><span class='ident'>encoded_data</span>, <span class='kw-2'>&amp;</span><span class='op'>*</span><span class='ident'>ec_data</span>);
<span class='kw'>let</span> <span class='ident'>canvas</span> <span class='op'>=</span> <span class='ident'>canvas</span>.<span class='ident'>apply_best_mask</span>();
<span class='prelude-val'>Ok</span>(<span class='ident'>QrCode</span> {
<span class='ident'>content</span>: <span class='ident'>canvas</span>.<span class='ident'>to_bools</span>(),
<span class='ident'>version</span>: <span class='ident'>version</span>,
<span class='ident'>ec_level</span>: <span class='ident'>ec_level</span>,
<span class='ident'>width</span>: <span class='ident'>version</span>.<span class='ident'>width</span>() <span class='kw'>as</span> <span class='ident'>usize</span>,
})
}
<span class='doccomment'>/// Gets the version of this QR code.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>version</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>Version</span> {
<span class='self'>self</span>.<span class='ident'>version</span>
}
<span class='doccomment'>/// Gets the error correction level of this QR code.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>error_correction_level</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>EcLevel</span> {
<span class='self'>self</span>.<span class='ident'>ec_level</span>
}
<span class='doccomment'>/// Gets the number of modules per side, i.e. the width of this QR code.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// The width here does not contain the quiet zone paddings.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>width</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>usize</span> {
<span class='self'>self</span>.<span class='ident'>width</span>
}
<span class='doccomment'>/// Gets the maximum number of allowed erratic modules can be introduced</span>
<span class='doccomment'>/// before the data becomes corrupted. Note that errors should not be</span>
<span class='doccomment'>/// introduced to functional modules.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>max_allowed_errors</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>usize</span> {
<span class='ident'>ec</span>::<span class='ident'>max_allowed_errors</span>(<span class='self'>self</span>.<span class='ident'>version</span>, <span class='self'>self</span>.<span class='ident'>ec_level</span>).<span class='ident'>unwrap</span>()
}
<span class='doccomment'>/// Checks whether a module at coordinate (x, y) is a functional module or</span>
<span class='doccomment'>/// not.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_functional</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>x</span>: <span class='ident'>usize</span>, <span class='ident'>y</span>: <span class='ident'>usize</span>) <span class='op'>-&gt;</span> <span class='ident'>bool</span> {
<span class='ident'>canvas</span>::<span class='ident'>is_functional</span>(<span class='self'>self</span>.<span class='ident'>version</span>, <span class='self'>self</span>.<span class='ident'>version</span>.<span class='ident'>width</span>(), <span class='ident'>x</span> <span class='kw'>as</span> <span class='ident'>i16</span>, <span class='ident'>y</span> <span class='kw'>as</span> <span class='ident'>i16</span>)
}
<span class='doccomment'>/// Converts the QR code into a human-readable string. This is mainly for</span>
<span class='doccomment'>/// debugging only.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_debug_str</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>on_char</span>: <span class='ident'>char</span>, <span class='ident'>off_char</span>: <span class='ident'>char</span>) <span class='op'>-&gt;</span> <span class='ident'>String</span> {
<span class='kw'>let</span> <span class='ident'>width</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>width</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>k</span> <span class='op'>=</span> <span class='number'>0</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>res</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='ident'>width</span> <span class='op'>*</span> (<span class='ident'>width</span> <span class='op'>+</span> <span class='number'>1</span>));
<span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span> .. <span class='ident'>width</span> {
<span class='ident'>res</span>.<span class='ident'>push</span>(<span class='string'>&#39;\n&#39;</span>);
<span class='kw'>for</span> _ <span class='kw'>in</span> <span class='number'>0</span> .. <span class='ident'>width</span> {
<span class='ident'>res</span>.<span class='ident'>push</span>(<span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>content</span>[<span class='ident'>k</span>] { <span class='ident'>on_char</span> } <span class='kw'>else</span> { <span class='ident'>off_char</span> });
<span class='ident'>k</span> <span class='op'>+=</span> <span class='number'>1</span>;
}
}
<span class='ident'>res</span>
}
<span class='doccomment'>/// Converts the QR code to a vector of booleans. Each entry represents the</span>
<span class='doccomment'>/// color of the module, with &quot;true&quot; means dark and &quot;false&quot; means light.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_vec</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>bool</span><span class='op'>&gt;</span> {
<span class='self'>self</span>.<span class='ident'>content</span>.<span class='ident'>clone</span>()
}
<span class='doccomment'>/// Converts the QR code to a vector of booleans. Each entry represents the</span>
<span class='doccomment'>/// color of the module, with &quot;true&quot; means dark and &quot;false&quot; means light.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>into_vec</span>(<span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>bool</span><span class='op'>&gt;</span> {
<span class='self'>self</span>.<span class='ident'>content</span>
}
<span class='doccomment'>/// Renders the QR code into an image. The result is an image builder, which</span>
<span class='doccomment'>/// you may do some additional configuration before copying it into a</span>
<span class='doccomment'>/// concrete image.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// # Examples</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// ```</span>
<span class='doccomment'>/// # extern crate image;</span>
<span class='doccomment'>/// # extern crate qrcode;</span>
<span class='doccomment'>/// # use qrcode::QrCode;</span>
<span class='doccomment'>/// # use image::Rgb;</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// let image = QrCode::new(b&quot;hello&quot;).unwrap()</span>
<span class='doccomment'>/// .render()</span>
<span class='doccomment'>/// .dark_color(Rgb { data: [0, 0, 128] })</span>
<span class='doccomment'>/// .light_color(Rgb { data: [224, 224, 224] }) // adjust colors</span>
<span class='doccomment'>/// .quiet_zone(false) // disable quiet zone (white border)</span>
<span class='doccomment'>/// .min_width(300) // sets minimum image size</span>
<span class='doccomment'>/// .to_image();</span>
<span class='doccomment'>/// ```</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Note: the `image` crate itself also provides method to rotate the image,</span>
<span class='doccomment'>/// or overlay a logo on top of the QR code.</span>
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>feature</span><span class='op'>=</span><span class='string'>&quot;image&quot;</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>render</span><span class='op'>&lt;</span><span class='ident'>P</span>: <span class='ident'>BlankAndWhitePixel</span> <span class='op'>+</span> <span class='lifetime'>&#39;static</span><span class='op'>&gt;</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>Renderer</span><span class='op'>&lt;</span><span class='ident'>P</span><span class='op'>&gt;</span> {
<span class='kw'>let</span> <span class='ident'>quiet_zone</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>version</span>.<span class='ident'>is_micro</span>() { <span class='number'>2</span> } <span class='kw'>else</span> { <span class='number'>4</span> };
<span class='ident'>Renderer</span>::<span class='ident'>new</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>.<span class='ident'>content</span>, <span class='self'>self</span>.<span class='ident'>width</span>, <span class='ident'>quiet_zone</span>)
}
}
<span class='kw'>impl</span> <span class='ident'>Index</span><span class='op'>&lt;</span>(<span class='ident'>usize</span>, <span class='ident'>usize</span>)<span class='op'>&gt;</span> <span class='kw'>for</span> <span class='ident'>QrCode</span> {
<span class='kw'>type</span> <span class='ident'>Output</span> <span class='op'>=</span> <span class='ident'>bool</span>;
<span class='kw'>fn</span> <span class='ident'>index</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, (<span class='ident'>x</span>, <span class='ident'>y</span>): (<span class='ident'>usize</span>, <span class='ident'>usize</span>)) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='ident'>bool</span> {
<span class='kw'>let</span> <span class='ident'>index</span> <span class='op'>=</span> <span class='ident'>y</span> <span class='op'>*</span> <span class='self'>self</span>.<span class='ident'>width</span> <span class='op'>+</span> <span class='ident'>x</span>;
<span class='kw-2'>&amp;</span><span class='self'>self</span>.<span class='ident'>content</span>[<span class='ident'>index</span>]
}
}
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span>
<span class='kw'>mod</span> <span class='ident'>tests</span> {
<span class='kw'>use</span> {<span class='ident'>QrCode</span>, <span class='ident'>Version</span>, <span class='ident'>EcLevel</span>};
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_annex_i_qr</span>() {
<span class='comment'>// This uses the ISO Annex I as test vector.</span>
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>with_version</span>(<span class='string'>b&quot;01234567&quot;</span>, <span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>), <span class='ident'>EcLevel</span>::<span class='ident'>M</span>).<span class='ident'>unwrap</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span><span class='op'>*</span><span class='ident'>code</span>.<span class='ident'>to_debug_str</span>(<span class='string'>&#39;#&#39;</span>, <span class='string'>&#39;.&#39;</span>), <span class='string'>&quot;\n\
#######..#.##.#######\n\
#.....#..####.#.....#\n\
#.###.#.#.....#.###.#\n\
#.###.#.##....#.###.#\n\
#.###.#.#.###.#.###.#\n\
#.....#.#...#.#.....#\n\
#######.#.#.#.#######\n\
........#..##........\n\
#.#####..#..#.#####..\n\
...#.#.##.#.#..#.##..\n\
..#...##.#.#.#..#####\n\
....#....#.....####..\n\
...######..#.#..#....\n\
........#.#####..##..\n\
#######..##.#.##.....\n\
#.....#.#.#####...#.#\n\
#.###.#.#...#..#.##..\n\
#.###.#.##..#..#.....\n\
#.###.#.#.##.#..#.#..\n\
#.....#........##.##.\n\
#######.####.#..#.#..&quot;</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_annex_i_micro_qr</span>() {
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>with_version</span>(<span class='string'>b&quot;01234567&quot;</span>, <span class='ident'>Version</span>::<span class='ident'>Micro</span>(<span class='number'>2</span>), <span class='ident'>EcLevel</span>::<span class='ident'>L</span>).<span class='ident'>unwrap</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span><span class='op'>*</span><span class='ident'>code</span>.<span class='ident'>to_debug_str</span>(<span class='string'>&#39;#&#39;</span>, <span class='string'>&#39;.&#39;</span>), <span class='string'>&quot;\n\
#######.#.#.#\n\
#.....#.###.#\n\
#.###.#..##.#\n\
#.###.#..####\n\
#.###.#.###..\n\
#.....#.#...#\n\
#######..####\n\
.........##..\n\
##.#....#...#\n\
.##.#.#.#.#.#\n\
###..#######.\n\
...#.#....##.\n\
###.#..##.###&quot;</span>);
}
}
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>all</span>(<span class='ident'>test</span>, <span class='ident'>feature</span><span class='op'>=</span><span class='string'>&quot;image&quot;</span>))]</span>
<span class='kw'>mod</span> <span class='ident'>image_tests</span> {
<span class='kw'>use</span> <span class='ident'>image</span>::{<span class='ident'>GrayImage</span>, <span class='ident'>Rgb</span>, <span class='ident'>load_from_memory</span>};
<span class='kw'>use</span> {<span class='ident'>QrCode</span>, <span class='ident'>Version</span>, <span class='ident'>EcLevel</span>};
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_annex_i_qr_as_image</span>() {
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>new</span>(<span class='string'>b&quot;01234567&quot;</span>).<span class='ident'>unwrap</span>();
<span class='kw'>let</span> <span class='ident'>image</span>: <span class='ident'>GrayImage</span> <span class='op'>=</span> <span class='ident'>code</span>.<span class='ident'>render</span>().<span class='ident'>to_image</span>();
<span class='kw'>let</span> <span class='ident'>expected</span> <span class='op'>=</span> <span class='ident'>load_from_memory</span>(<span class='macro'>include_bytes</span><span class='macro'>!</span>(<span class='string'>&quot;test_annex_i_qr_as_image.png&quot;</span>)).<span class='ident'>unwrap</span>().<span class='ident'>to_luma</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>dimensions</span>(), <span class='ident'>expected</span>.<span class='ident'>dimensions</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>into_raw</span>(), <span class='ident'>expected</span>.<span class='ident'>into_raw</span>());
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_annex_i_micro_qr_as_image</span>() {
<span class='kw'>let</span> <span class='ident'>code</span> <span class='op'>=</span> <span class='ident'>QrCode</span>::<span class='ident'>with_version</span>(<span class='string'>b&quot;01234567&quot;</span>, <span class='ident'>Version</span>::<span class='ident'>Micro</span>(<span class='number'>2</span>), <span class='ident'>EcLevel</span>::<span class='ident'>L</span>).<span class='ident'>unwrap</span>();
<span class='kw'>let</span> <span class='ident'>image</span> <span class='op'>=</span> <span class='ident'>code</span>.<span class='ident'>render</span>().<span class='ident'>min_width</span>(<span class='number'>200</span>)
.<span class='ident'>dark_color</span>(<span class='ident'>Rgb</span> { <span class='ident'>data</span>: [<span class='number'>128</span>, <span class='number'>0</span>, <span class='number'>0</span>] })
.<span class='ident'>light_color</span>(<span class='ident'>Rgb</span> { <span class='ident'>data</span>: [<span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>128</span>] })
.<span class='ident'>to_image</span>();
<span class='kw'>let</span> <span class='ident'>expected</span> <span class='op'>=</span> <span class='ident'>load_from_memory</span>(<span class='macro'>include_bytes</span><span class='macro'>!</span>(<span class='string'>&quot;test_annex_i_micro_qr_as_image.png&quot;</span>)).<span class='ident'>unwrap</span>().<span class='ident'>to_rgb</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>dimensions</span>(), <span class='ident'>expected</span>.<span class='ident'>dimensions</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>into_raw</span>(), <span class='ident'>expected</span>.<span class='ident'>into_raw</span>());
}
}
</pre>
</section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../../jquery.js"></script>
<script src="../../../main.js"></script>
<script defer src="../../../search-index.js"></script>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -1,554 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="Source to the Rust file `src/render.rs`.">
<meta name="keywords" content="rust, rustlang, rust-lang">
<title>render.rs.html -- source</title>
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content source"><pre class="line-numbers"><span id="1"> 1</span>
<span id="2"> 2</span>
<span id="3"> 3</span>
<span id="4"> 4</span>
<span id="5"> 5</span>
<span id="6"> 6</span>
<span id="7"> 7</span>
<span id="8"> 8</span>
<span id="9"> 9</span>
<span id="10"> 10</span>
<span id="11"> 11</span>
<span id="12"> 12</span>
<span id="13"> 13</span>
<span id="14"> 14</span>
<span id="15"> 15</span>
<span id="16"> 16</span>
<span id="17"> 17</span>
<span id="18"> 18</span>
<span id="19"> 19</span>
<span id="20"> 20</span>
<span id="21"> 21</span>
<span id="22"> 22</span>
<span id="23"> 23</span>
<span id="24"> 24</span>
<span id="25"> 25</span>
<span id="26"> 26</span>
<span id="27"> 27</span>
<span id="28"> 28</span>
<span id="29"> 29</span>
<span id="30"> 30</span>
<span id="31"> 31</span>
<span id="32"> 32</span>
<span id="33"> 33</span>
<span id="34"> 34</span>
<span id="35"> 35</span>
<span id="36"> 36</span>
<span id="37"> 37</span>
<span id="38"> 38</span>
<span id="39"> 39</span>
<span id="40"> 40</span>
<span id="41"> 41</span>
<span id="42"> 42</span>
<span id="43"> 43</span>
<span id="44"> 44</span>
<span id="45"> 45</span>
<span id="46"> 46</span>
<span id="47"> 47</span>
<span id="48"> 48</span>
<span id="49"> 49</span>
<span id="50"> 50</span>
<span id="51"> 51</span>
<span id="52"> 52</span>
<span id="53"> 53</span>
<span id="54"> 54</span>
<span id="55"> 55</span>
<span id="56"> 56</span>
<span id="57"> 57</span>
<span id="58"> 58</span>
<span id="59"> 59</span>
<span id="60"> 60</span>
<span id="61"> 61</span>
<span id="62"> 62</span>
<span id="63"> 63</span>
<span id="64"> 64</span>
<span id="65"> 65</span>
<span id="66"> 66</span>
<span id="67"> 67</span>
<span id="68"> 68</span>
<span id="69"> 69</span>
<span id="70"> 70</span>
<span id="71"> 71</span>
<span id="72"> 72</span>
<span id="73"> 73</span>
<span id="74"> 74</span>
<span id="75"> 75</span>
<span id="76"> 76</span>
<span id="77"> 77</span>
<span id="78"> 78</span>
<span id="79"> 79</span>
<span id="80"> 80</span>
<span id="81"> 81</span>
<span id="82"> 82</span>
<span id="83"> 83</span>
<span id="84"> 84</span>
<span id="85"> 85</span>
<span id="86"> 86</span>
<span id="87"> 87</span>
<span id="88"> 88</span>
<span id="89"> 89</span>
<span id="90"> 90</span>
<span id="91"> 91</span>
<span id="92"> 92</span>
<span id="93"> 93</span>
<span id="94"> 94</span>
<span id="95"> 95</span>
<span id="96"> 96</span>
<span id="97"> 97</span>
<span id="98"> 98</span>
<span id="99"> 99</span>
<span id="100">100</span>
<span id="101">101</span>
<span id="102">102</span>
<span id="103">103</span>
<span id="104">104</span>
<span id="105">105</span>
<span id="106">106</span>
<span id="107">107</span>
<span id="108">108</span>
<span id="109">109</span>
<span id="110">110</span>
<span id="111">111</span>
<span id="112">112</span>
<span id="113">113</span>
<span id="114">114</span>
<span id="115">115</span>
<span id="116">116</span>
<span id="117">117</span>
<span id="118">118</span>
<span id="119">119</span>
<span id="120">120</span>
<span id="121">121</span>
<span id="122">122</span>
<span id="123">123</span>
<span id="124">124</span>
<span id="125">125</span>
<span id="126">126</span>
<span id="127">127</span>
<span id="128">128</span>
<span id="129">129</span>
<span id="130">130</span>
<span id="131">131</span>
<span id="132">132</span>
<span id="133">133</span>
<span id="134">134</span>
<span id="135">135</span>
<span id="136">136</span>
<span id="137">137</span>
<span id="138">138</span>
<span id="139">139</span>
<span id="140">140</span>
<span id="141">141</span>
<span id="142">142</span>
<span id="143">143</span>
<span id="144">144</span>
<span id="145">145</span>
<span id="146">146</span>
<span id="147">147</span>
<span id="148">148</span>
<span id="149">149</span>
<span id="150">150</span>
<span id="151">151</span>
<span id="152">152</span>
<span id="153">153</span>
<span id="154">154</span>
<span id="155">155</span>
<span id="156">156</span>
<span id="157">157</span>
<span id="158">158</span>
<span id="159">159</span>
<span id="160">160</span>
<span id="161">161</span>
<span id="162">162</span>
<span id="163">163</span>
<span id="164">164</span>
<span id="165">165</span>
<span id="166">166</span>
<span id="167">167</span>
<span id="168">168</span>
<span id="169">169</span>
<span id="170">170</span>
<span id="171">171</span>
<span id="172">172</span>
<span id="173">173</span>
<span id="174">174</span>
<span id="175">175</span>
<span id="176">176</span>
<span id="177">177</span>
<span id="178">178</span>
<span id="179">179</span>
<span id="180">180</span>
<span id="181">181</span>
<span id="182">182</span>
<span id="183">183</span>
<span id="184">184</span>
<span id="185">185</span>
<span id="186">186</span>
<span id="187">187</span>
<span id="188">188</span>
<span id="189">189</span>
<span id="190">190</span>
<span id="191">191</span>
<span id="192">192</span>
<span id="193">193</span>
<span id="194">194</span>
<span id="195">195</span>
<span id="196">196</span>
<span id="197">197</span>
<span id="198">198</span>
<span id="199">199</span>
<span id="200">200</span>
<span id="201">201</span>
<span id="202">202</span>
<span id="203">203</span>
<span id="204">204</span>
<span id="205">205</span>
<span id="206">206</span>
<span id="207">207</span>
<span id="208">208</span>
<span id="209">209</span>
<span id="210">210</span>
<span id="211">211</span>
<span id="212">212</span>
<span id="213">213</span>
<span id="214">214</span>
<span id="215">215</span>
<span id="216">216</span>
<span id="217">217</span>
<span id="218">218</span>
<span id="219">219</span>
<span id="220">220</span>
<span id="221">221</span>
<span id="222">222</span>
</pre><pre class='rust '>
<span class='doccomment'>//! Render a QR code into image.</span>
<span class='attribute'>#<span class='op'>!</span>[<span class='ident'>cfg</span>(<span class='ident'>feature</span><span class='op'>=</span><span class='string'>&quot;image&quot;</span>)]</span>
<span class='kw'>use</span> <span class='ident'>image</span>::{<span class='ident'>Pixel</span>, <span class='ident'>Rgb</span>, <span class='ident'>Rgba</span>, <span class='ident'>Luma</span>, <span class='ident'>LumaA</span>, <span class='ident'>Primitive</span>, <span class='ident'>ImageBuffer</span>};
<span class='doccomment'>/// A pixel which can support black and white colors.</span>
<span class='kw'>pub</span> <span class='kw'>trait</span> <span class='ident'>BlankAndWhitePixel</span>: <span class='ident'>Pixel</span> {
<span class='kw'>fn</span> <span class='ident'>black_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span>;
<span class='kw'>fn</span> <span class='ident'>white_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span>;
}
<span class='kw'>impl</span><span class='op'>&lt;</span><span class='ident'>S</span>: <span class='ident'>Primitive</span> <span class='op'>+</span> <span class='lifetime'>&#39;static</span><span class='op'>&gt;</span> <span class='ident'>BlankAndWhitePixel</span> <span class='kw'>for</span> <span class='ident'>Rgb</span><span class='op'>&lt;</span><span class='ident'>S</span><span class='op'>&gt;</span> {
<span class='kw'>fn</span> <span class='ident'>black_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>Rgb</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>zero</span>(); <span class='number'>3</span>] }
}
<span class='kw'>fn</span> <span class='ident'>white_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>Rgb</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>max_value</span>(); <span class='number'>3</span>] }
}
}
<span class='kw'>impl</span><span class='op'>&lt;</span><span class='ident'>S</span>: <span class='ident'>Primitive</span> <span class='op'>+</span> <span class='lifetime'>&#39;static</span><span class='op'>&gt;</span> <span class='ident'>BlankAndWhitePixel</span> <span class='kw'>for</span> <span class='ident'>Rgba</span><span class='op'>&lt;</span><span class='ident'>S</span><span class='op'>&gt;</span> {
<span class='kw'>fn</span> <span class='ident'>black_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>Rgba</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>zero</span>(), <span class='ident'>S</span>::<span class='ident'>zero</span>(), <span class='ident'>S</span>::<span class='ident'>zero</span>(), <span class='ident'>S</span>::<span class='ident'>max_value</span>()] }
}
<span class='kw'>fn</span> <span class='ident'>white_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>Rgba</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>max_value</span>(); <span class='number'>4</span>] }
}
}
<span class='kw'>impl</span><span class='op'>&lt;</span><span class='ident'>S</span>: <span class='ident'>Primitive</span> <span class='op'>+</span> <span class='lifetime'>&#39;static</span><span class='op'>&gt;</span> <span class='ident'>BlankAndWhitePixel</span> <span class='kw'>for</span> <span class='ident'>Luma</span><span class='op'>&lt;</span><span class='ident'>S</span><span class='op'>&gt;</span> {
<span class='kw'>fn</span> <span class='ident'>black_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>Luma</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>zero</span>()] }
}
<span class='kw'>fn</span> <span class='ident'>white_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>Luma</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>max_value</span>()] }
}
}
<span class='kw'>impl</span><span class='op'>&lt;</span><span class='ident'>S</span>: <span class='ident'>Primitive</span> <span class='op'>+</span> <span class='lifetime'>&#39;static</span><span class='op'>&gt;</span> <span class='ident'>BlankAndWhitePixel</span> <span class='kw'>for</span> <span class='ident'>LumaA</span><span class='op'>&lt;</span><span class='ident'>S</span><span class='op'>&gt;</span> {
<span class='kw'>fn</span> <span class='ident'>black_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>LumaA</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>zero</span>(), <span class='ident'>S</span>::<span class='ident'>max_value</span>()] }
}
<span class='kw'>fn</span> <span class='ident'>white_color</span>() <span class='op'>-&gt;</span> <span class='self'>Self</span> {
<span class='ident'>LumaA</span> { <span class='ident'>data</span>: [<span class='ident'>S</span>::<span class='ident'>max_value</span>(); <span class='number'>2</span>] }
}
}
<span class='doccomment'>/// A QR code renderer. This is a builder type which converts a bool-vector into</span>
<span class='doccomment'>/// an image.</span>
<span class='kw'>pub</span> <span class='kw'>struct</span> <span class='ident'>Renderer</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='ident'>P</span>: <span class='ident'>BlankAndWhitePixel</span><span class='op'>&gt;</span> {
<span class='ident'>content</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;a</span> [<span class='ident'>bool</span>],
<span class='ident'>modules_count</span>: <span class='ident'>u32</span>, <span class='comment'>// &lt;- we call it `modules_count` here to avoid ambiguity of `width`.</span>
<span class='ident'>quiet_zone</span>: <span class='ident'>u32</span>,
<span class='ident'>module_size</span>: <span class='ident'>u32</span>,
<span class='ident'>dark_color</span>: <span class='ident'>P</span>,
<span class='ident'>light_color</span>: <span class='ident'>P</span>,
<span class='ident'>has_quiet_zone</span>: <span class='ident'>bool</span>,
}
<span class='kw'>impl</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='ident'>P</span>: <span class='ident'>BlankAndWhitePixel</span> <span class='op'>+</span> <span class='lifetime'>&#39;static</span><span class='op'>&gt;</span> <span class='ident'>Renderer</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='ident'>P</span><span class='op'>&gt;</span> {
<span class='doccomment'>/// Creates a new renderer.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>content</span>: <span class='kw-2'>&amp;</span><span class='lifetime'>&#39;a</span> [<span class='ident'>bool</span>], <span class='ident'>modules_count</span>: <span class='ident'>usize</span>, <span class='ident'>quiet_zone</span>: <span class='ident'>u32</span>) <span class='op'>-&gt;</span> <span class='ident'>Renderer</span><span class='op'>&lt;</span><span class='lifetime'>&#39;a</span>, <span class='ident'>P</span><span class='op'>&gt;</span> {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>modules_count</span> <span class='op'>*</span> <span class='ident'>modules_count</span> <span class='op'>==</span> <span class='ident'>content</span>.<span class='ident'>len</span>());
<span class='ident'>Renderer</span> {
<span class='ident'>content</span>: <span class='ident'>content</span>,
<span class='ident'>modules_count</span>: <span class='ident'>modules_count</span> <span class='kw'>as</span> <span class='ident'>u32</span>,
<span class='ident'>quiet_zone</span>: <span class='ident'>quiet_zone</span>,
<span class='ident'>module_size</span>: <span class='number'>8</span>,
<span class='ident'>dark_color</span>: <span class='ident'>P</span>::<span class='ident'>black_color</span>(),
<span class='ident'>light_color</span>: <span class='ident'>P</span>::<span class='ident'>white_color</span>(),
<span class='ident'>has_quiet_zone</span>: <span class='boolvalue'>true</span>,
}
}
<span class='doccomment'>/// Sets color of a dark module. Default is opaque black.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>dark_color</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>color</span>: <span class='ident'>P</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>Self</span> {
<span class='self'>self</span>.<span class='ident'>dark_color</span> <span class='op'>=</span> <span class='ident'>color</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets color of a light module. Default is opaque white.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>light_color</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>color</span>: <span class='ident'>P</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>Self</span> {
<span class='self'>self</span>.<span class='ident'>light_color</span> <span class='op'>=</span> <span class='ident'>color</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Whether to include the quiet zone in the generated image.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>quiet_zone</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>has_quiet_zone</span>: <span class='ident'>bool</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>Self</span> {
<span class='self'>self</span>.<span class='ident'>has_quiet_zone</span> <span class='op'>=</span> <span class='ident'>has_quiet_zone</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets the size of each module in pixels. Default is 8px.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>module_size</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>size</span>: <span class='ident'>u32</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>Self</span> {
<span class='self'>self</span>.<span class='ident'>module_size</span> <span class='op'>=</span> <span class='ident'>size</span>;
<span class='self'>self</span>
}
<span class='doccomment'>/// Sets the minimal total image width (and thus height) in pixels,</span>
<span class='doccomment'>/// including the quiet zone if applicable. The renderer will try to find</span>
<span class='doccomment'>/// the dimension as small as possible, such that each module in the QR code</span>
<span class='doccomment'>/// has uniform size (no distortion).</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// For instance, a version 1 QR code has 19 modules across including the</span>
<span class='doccomment'>/// quiet zone. If we request an image of width ≥200px, we get that each</span>
<span class='doccomment'>/// module&#39;s size should be 11px, so the actual image size will be 209px.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>min_width</span>(<span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>self</span>, <span class='ident'>width</span>: <span class='ident'>u32</span>) <span class='op'>-&gt;</span> <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='self'>Self</span> {
<span class='kw'>let</span> <span class='ident'>quiet_zone</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>has_quiet_zone</span> { <span class='number'>2</span> } <span class='kw'>else</span> { <span class='number'>0</span> } <span class='op'>*</span> <span class='self'>self</span>.<span class='ident'>quiet_zone</span>;
<span class='kw'>let</span> <span class='ident'>width_in_modules</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>modules_count</span> <span class='op'>+</span> <span class='ident'>quiet_zone</span>;
<span class='kw'>let</span> <span class='ident'>module_size</span> <span class='op'>=</span> (<span class='ident'>width</span> <span class='op'>+</span> <span class='ident'>width_in_modules</span> <span class='op'>-</span> <span class='number'>1</span>) <span class='op'>/</span> <span class='ident'>width_in_modules</span>;
<span class='self'>self</span>.<span class='ident'>module_size</span>(<span class='ident'>module_size</span>)
}
<span class='doccomment'>/// Renders the QR code into an image.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>to_image</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>ImageBuffer</span><span class='op'>&lt;</span><span class='ident'>P</span>, <span class='ident'>Vec</span><span class='op'>&lt;</span><span class='ident'>P</span>::<span class='ident'>Subpixel</span><span class='op'>&gt;&gt;</span> {
<span class='kw'>let</span> <span class='ident'>w</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>modules_count</span>;
<span class='kw'>let</span> <span class='ident'>qz</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>has_quiet_zone</span> { <span class='self'>self</span>.<span class='ident'>quiet_zone</span> } <span class='kw'>else</span> { <span class='number'>0</span> };
<span class='kw'>let</span> <span class='ident'>width</span> <span class='op'>=</span> <span class='ident'>w</span> <span class='op'>+</span> <span class='number'>2</span> <span class='op'>*</span> <span class='ident'>qz</span>;
<span class='kw'>let</span> <span class='ident'>ms</span> <span class='op'>=</span> <span class='self'>self</span>.<span class='ident'>module_size</span>;
<span class='kw'>let</span> <span class='ident'>real_width</span> <span class='op'>=</span> <span class='ident'>width</span> <span class='op'>*</span> <span class='ident'>ms</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>image</span> <span class='op'>=</span> <span class='ident'>ImageBuffer</span>::<span class='ident'>new</span>(<span class='ident'>real_width</span>, <span class='ident'>real_width</span>);
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>i</span> <span class='op'>=</span> <span class='number'>0</span>;
<span class='kw'>for</span> <span class='ident'>y</span> <span class='kw'>in</span> <span class='number'>0</span> .. <span class='ident'>width</span> {
<span class='kw'>for</span> <span class='ident'>x</span> <span class='kw'>in</span> <span class='number'>0</span> .. <span class='ident'>width</span> {
<span class='kw'>let</span> <span class='ident'>color</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='ident'>qz</span> <span class='op'>&lt;=</span> <span class='ident'>x</span> <span class='op'>&amp;&amp;</span> <span class='ident'>x</span> <span class='op'>&lt;</span> <span class='ident'>w</span> <span class='op'>+</span> <span class='ident'>qz</span> <span class='op'>&amp;&amp;</span> <span class='ident'>qz</span> <span class='op'>&lt;=</span> <span class='ident'>y</span> <span class='op'>&amp;&amp;</span> <span class='ident'>y</span> <span class='op'>&lt;</span> <span class='ident'>w</span> <span class='op'>+</span> <span class='ident'>qz</span> {
<span class='kw'>let</span> <span class='ident'>c</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='self'>self</span>.<span class='ident'>content</span>[<span class='ident'>i</span>] { <span class='self'>self</span>.<span class='ident'>dark_color</span> } <span class='kw'>else</span> { <span class='self'>self</span>.<span class='ident'>light_color</span> };
<span class='ident'>i</span> <span class='op'>+=</span> <span class='number'>1</span>;
<span class='ident'>c</span>
} <span class='kw'>else</span> {
<span class='self'>self</span>.<span class='ident'>light_color</span>
};
<span class='kw'>for</span> <span class='ident'>yy</span> <span class='kw'>in</span> <span class='ident'>y</span> <span class='op'>*</span> <span class='ident'>ms</span> .. (<span class='ident'>y</span> <span class='op'>+</span> <span class='number'>1</span>) <span class='op'>*</span> <span class='ident'>ms</span> {
<span class='kw'>for</span> <span class='ident'>xx</span> <span class='kw'>in</span> <span class='ident'>x</span> <span class='op'>*</span> <span class='ident'>ms</span> .. (<span class='ident'>x</span> <span class='op'>+</span> <span class='number'>1</span>) <span class='op'>*</span> <span class='ident'>ms</span> {
<span class='ident'>image</span>.<span class='ident'>put_pixel</span>(<span class='ident'>xx</span>, <span class='ident'>yy</span>, <span class='ident'>color</span>);
}
}
}
}
<span class='ident'>image</span>
}
}
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span>
<span class='kw'>mod</span> <span class='ident'>render_tests</span> {
<span class='kw'>use</span> <span class='ident'>render</span>::<span class='ident'>Renderer</span>;
<span class='kw'>use</span> <span class='ident'>image</span>::{<span class='ident'>Luma</span>, <span class='ident'>Rgba</span>};
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_render_luma8_unsized</span>() {
<span class='kw'>let</span> <span class='ident'>image</span> <span class='op'>=</span> <span class='ident'>Renderer</span>::<span class='op'>&lt;</span><span class='ident'>Luma</span><span class='op'>&lt;</span><span class='ident'>u8</span><span class='op'>&gt;&gt;</span>::<span class='ident'>new</span>(<span class='kw-2'>&amp;</span>[
<span class='boolvalue'>false</span>, <span class='boolvalue'>true</span>, <span class='boolvalue'>true</span>,
<span class='boolvalue'>true</span>, <span class='boolvalue'>false</span>, <span class='boolvalue'>false</span>,
<span class='boolvalue'>false</span>, <span class='boolvalue'>true</span>, <span class='boolvalue'>false</span>,
], <span class='number'>3</span>, <span class='number'>1</span>).<span class='ident'>module_size</span>(<span class='number'>1</span>).<span class='ident'>to_image</span>();
<span class='kw'>let</span> <span class='ident'>expected</span> <span class='op'>=</span> [
<span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>255</span>,
<span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>255</span>,
<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>255</span>,
<span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>255</span>, <span class='number'>255</span>,
<span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>255</span>, <span class='number'>255</span>,
];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>into_raw</span>(), <span class='ident'>expected</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_render_rgba_unsized</span>() {
<span class='kw'>let</span> <span class='ident'>image</span> <span class='op'>=</span> <span class='ident'>Renderer</span>::<span class='op'>&lt;</span><span class='ident'>Rgba</span><span class='op'>&lt;</span><span class='ident'>u8</span><span class='op'>&gt;&gt;</span>::<span class='ident'>new</span>(<span class='kw-2'>&amp;</span>[
<span class='boolvalue'>false</span>, <span class='boolvalue'>true</span>,
<span class='boolvalue'>true</span>, <span class='boolvalue'>true</span>,
], <span class='number'>2</span>, <span class='number'>1</span>).<span class='ident'>module_size</span>(<span class='number'>1</span>).<span class='ident'>to_image</span>();
<span class='kw'>let</span> <span class='ident'>expected</span>: <span class='kw-2'>&amp;</span>[<span class='ident'>u8</span>] <span class='op'>=</span> <span class='kw-2'>&amp;</span>[
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>into_raw</span>(), <span class='ident'>expected</span>);
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_render_resized</span>() {
<span class='kw'>let</span> <span class='ident'>image</span> <span class='op'>=</span> <span class='ident'>Renderer</span>::<span class='op'>&lt;</span><span class='ident'>Luma</span><span class='op'>&lt;</span><span class='ident'>u8</span><span class='op'>&gt;&gt;</span>::<span class='ident'>new</span>(<span class='kw-2'>&amp;</span>[
<span class='boolvalue'>true</span>, <span class='boolvalue'>false</span>,
<span class='boolvalue'>false</span>, <span class='boolvalue'>true</span>,
], <span class='number'>2</span>, <span class='number'>1</span>).<span class='ident'>min_width</span>(<span class='number'>10</span>).<span class='ident'>to_image</span>();
<span class='kw'>let</span> <span class='ident'>expected</span>: <span class='kw-2'>&amp;</span>[<span class='ident'>u8</span>] <span class='op'>=</span> <span class='kw-2'>&amp;</span>[
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>0</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
<span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>, <span class='number'>255</span>,<span class='number'>255</span>,<span class='number'>255</span>,
];
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>dimensions</span>(), (<span class='number'>12</span>, <span class='number'>12</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>image</span>.<span class='ident'>into_raw</span>(), <span class='ident'>expected</span>);
}
}
</pre>
</section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../../jquery.js"></script>
<script src="../../../main.js"></script>
<script defer src="../../../search-index.js"></script>
</body>
</html>

View file

@ -1,674 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<meta name="description" content="Source to the Rust file `src/types.rs`.">
<meta name="keywords" content="rust, rustlang, rust-lang">
<title>types.rs.html -- source</title>
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content source"><pre class="line-numbers"><span id="1"> 1</span>
<span id="2"> 2</span>
<span id="3"> 3</span>
<span id="4"> 4</span>
<span id="5"> 5</span>
<span id="6"> 6</span>
<span id="7"> 7</span>
<span id="8"> 8</span>
<span id="9"> 9</span>
<span id="10"> 10</span>
<span id="11"> 11</span>
<span id="12"> 12</span>
<span id="13"> 13</span>
<span id="14"> 14</span>
<span id="15"> 15</span>
<span id="16"> 16</span>
<span id="17"> 17</span>
<span id="18"> 18</span>
<span id="19"> 19</span>
<span id="20"> 20</span>
<span id="21"> 21</span>
<span id="22"> 22</span>
<span id="23"> 23</span>
<span id="24"> 24</span>
<span id="25"> 25</span>
<span id="26"> 26</span>
<span id="27"> 27</span>
<span id="28"> 28</span>
<span id="29"> 29</span>
<span id="30"> 30</span>
<span id="31"> 31</span>
<span id="32"> 32</span>
<span id="33"> 33</span>
<span id="34"> 34</span>
<span id="35"> 35</span>
<span id="36"> 36</span>
<span id="37"> 37</span>
<span id="38"> 38</span>
<span id="39"> 39</span>
<span id="40"> 40</span>
<span id="41"> 41</span>
<span id="42"> 42</span>
<span id="43"> 43</span>
<span id="44"> 44</span>
<span id="45"> 45</span>
<span id="46"> 46</span>
<span id="47"> 47</span>
<span id="48"> 48</span>
<span id="49"> 49</span>
<span id="50"> 50</span>
<span id="51"> 51</span>
<span id="52"> 52</span>
<span id="53"> 53</span>
<span id="54"> 54</span>
<span id="55"> 55</span>
<span id="56"> 56</span>
<span id="57"> 57</span>
<span id="58"> 58</span>
<span id="59"> 59</span>
<span id="60"> 60</span>
<span id="61"> 61</span>
<span id="62"> 62</span>
<span id="63"> 63</span>
<span id="64"> 64</span>
<span id="65"> 65</span>
<span id="66"> 66</span>
<span id="67"> 67</span>
<span id="68"> 68</span>
<span id="69"> 69</span>
<span id="70"> 70</span>
<span id="71"> 71</span>
<span id="72"> 72</span>
<span id="73"> 73</span>
<span id="74"> 74</span>
<span id="75"> 75</span>
<span id="76"> 76</span>
<span id="77"> 77</span>
<span id="78"> 78</span>
<span id="79"> 79</span>
<span id="80"> 80</span>
<span id="81"> 81</span>
<span id="82"> 82</span>
<span id="83"> 83</span>
<span id="84"> 84</span>
<span id="85"> 85</span>
<span id="86"> 86</span>
<span id="87"> 87</span>
<span id="88"> 88</span>
<span id="89"> 89</span>
<span id="90"> 90</span>
<span id="91"> 91</span>
<span id="92"> 92</span>
<span id="93"> 93</span>
<span id="94"> 94</span>
<span id="95"> 95</span>
<span id="96"> 96</span>
<span id="97"> 97</span>
<span id="98"> 98</span>
<span id="99"> 99</span>
<span id="100">100</span>
<span id="101">101</span>
<span id="102">102</span>
<span id="103">103</span>
<span id="104">104</span>
<span id="105">105</span>
<span id="106">106</span>
<span id="107">107</span>
<span id="108">108</span>
<span id="109">109</span>
<span id="110">110</span>
<span id="111">111</span>
<span id="112">112</span>
<span id="113">113</span>
<span id="114">114</span>
<span id="115">115</span>
<span id="116">116</span>
<span id="117">117</span>
<span id="118">118</span>
<span id="119">119</span>
<span id="120">120</span>
<span id="121">121</span>
<span id="122">122</span>
<span id="123">123</span>
<span id="124">124</span>
<span id="125">125</span>
<span id="126">126</span>
<span id="127">127</span>
<span id="128">128</span>
<span id="129">129</span>
<span id="130">130</span>
<span id="131">131</span>
<span id="132">132</span>
<span id="133">133</span>
<span id="134">134</span>
<span id="135">135</span>
<span id="136">136</span>
<span id="137">137</span>
<span id="138">138</span>
<span id="139">139</span>
<span id="140">140</span>
<span id="141">141</span>
<span id="142">142</span>
<span id="143">143</span>
<span id="144">144</span>
<span id="145">145</span>
<span id="146">146</span>
<span id="147">147</span>
<span id="148">148</span>
<span id="149">149</span>
<span id="150">150</span>
<span id="151">151</span>
<span id="152">152</span>
<span id="153">153</span>
<span id="154">154</span>
<span id="155">155</span>
<span id="156">156</span>
<span id="157">157</span>
<span id="158">158</span>
<span id="159">159</span>
<span id="160">160</span>
<span id="161">161</span>
<span id="162">162</span>
<span id="163">163</span>
<span id="164">164</span>
<span id="165">165</span>
<span id="166">166</span>
<span id="167">167</span>
<span id="168">168</span>
<span id="169">169</span>
<span id="170">170</span>
<span id="171">171</span>
<span id="172">172</span>
<span id="173">173</span>
<span id="174">174</span>
<span id="175">175</span>
<span id="176">176</span>
<span id="177">177</span>
<span id="178">178</span>
<span id="179">179</span>
<span id="180">180</span>
<span id="181">181</span>
<span id="182">182</span>
<span id="183">183</span>
<span id="184">184</span>
<span id="185">185</span>
<span id="186">186</span>
<span id="187">187</span>
<span id="188">188</span>
<span id="189">189</span>
<span id="190">190</span>
<span id="191">191</span>
<span id="192">192</span>
<span id="193">193</span>
<span id="194">194</span>
<span id="195">195</span>
<span id="196">196</span>
<span id="197">197</span>
<span id="198">198</span>
<span id="199">199</span>
<span id="200">200</span>
<span id="201">201</span>
<span id="202">202</span>
<span id="203">203</span>
<span id="204">204</span>
<span id="205">205</span>
<span id="206">206</span>
<span id="207">207</span>
<span id="208">208</span>
<span id="209">209</span>
<span id="210">210</span>
<span id="211">211</span>
<span id="212">212</span>
<span id="213">213</span>
<span id="214">214</span>
<span id="215">215</span>
<span id="216">216</span>
<span id="217">217</span>
<span id="218">218</span>
<span id="219">219</span>
<span id="220">220</span>
<span id="221">221</span>
<span id="222">222</span>
<span id="223">223</span>
<span id="224">224</span>
<span id="225">225</span>
<span id="226">226</span>
<span id="227">227</span>
<span id="228">228</span>
<span id="229">229</span>
<span id="230">230</span>
<span id="231">231</span>
<span id="232">232</span>
<span id="233">233</span>
<span id="234">234</span>
<span id="235">235</span>
<span id="236">236</span>
<span id="237">237</span>
<span id="238">238</span>
<span id="239">239</span>
<span id="240">240</span>
<span id="241">241</span>
<span id="242">242</span>
<span id="243">243</span>
<span id="244">244</span>
<span id="245">245</span>
<span id="246">246</span>
<span id="247">247</span>
<span id="248">248</span>
<span id="249">249</span>
<span id="250">250</span>
<span id="251">251</span>
<span id="252">252</span>
<span id="253">253</span>
<span id="254">254</span>
<span id="255">255</span>
<span id="256">256</span>
<span id="257">257</span>
<span id="258">258</span>
<span id="259">259</span>
<span id="260">260</span>
<span id="261">261</span>
<span id="262">262</span>
<span id="263">263</span>
<span id="264">264</span>
<span id="265">265</span>
<span id="266">266</span>
<span id="267">267</span>
<span id="268">268</span>
<span id="269">269</span>
<span id="270">270</span>
<span id="271">271</span>
<span id="272">272</span>
<span id="273">273</span>
<span id="274">274</span>
<span id="275">275</span>
<span id="276">276</span>
<span id="277">277</span>
<span id="278">278</span>
<span id="279">279</span>
<span id="280">280</span>
<span id="281">281</span>
<span id="282">282</span>
</pre><pre class='rust '>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>default</span>::<span class='ident'>Default</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>cmp</span>::{<span class='ident'>PartialOrd</span>, <span class='ident'>Ordering</span>};
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>fmt</span>::{<span class='ident'>Display</span>, <span class='ident'>Formatter</span>, <span class='ident'>Error</span>};
<span class='comment'>//------------------------------------------------------------------------------</span>
<span class='comment'>//{{{ QrResult</span>
<span class='doccomment'>/// `QrError` encodes the error encountered when generating a QR code.</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>QrError</span> {
<span class='doccomment'>/// The data is too long to encode into a QR code for the given version.</span>
<span class='ident'>DataTooLong</span>,
<span class='doccomment'>/// The provided version / error correction level combination is invalid.</span>
<span class='ident'>InvalidVersion</span>,
<span class='doccomment'>/// Some characters in the data cannot be supported by the provided QR code</span>
<span class='doccomment'>/// version.</span>
<span class='ident'>UnsupportedCharacterSet</span>,
<span class='doccomment'>/// The provided ECI designator is invalid. A valid designator should be</span>
<span class='doccomment'>/// between 0 and 999999.</span>
<span class='ident'>InvalidEciDesignator</span>,
<span class='doccomment'>/// A character not belonging to the character set is found.</span>
<span class='ident'>InvalidCharacter</span>,
}
<span class='kw'>impl</span> <span class='ident'>Display</span> <span class='kw'>for</span> <span class='ident'>QrError</span> {
<span class='kw'>fn</span> <span class='ident'>fmt</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>fmt</span>: <span class='kw-2'>&amp;</span><span class='kw-2'>mut</span> <span class='ident'>Formatter</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Result</span><span class='op'>&lt;</span>(), <span class='ident'>Error</span><span class='op'>&gt;</span> {
<span class='kw'>let</span> <span class='ident'>msg</span> <span class='op'>=</span> <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>QrError</span>::<span class='ident'>DataTooLong</span> <span class='op'>=&gt;</span> <span class='string'>&quot;data too long&quot;</span>,
<span class='ident'>QrError</span>::<span class='ident'>InvalidVersion</span> <span class='op'>=&gt;</span> <span class='string'>&quot;invalid version&quot;</span>,
<span class='ident'>QrError</span>::<span class='ident'>UnsupportedCharacterSet</span> <span class='op'>=&gt;</span> <span class='string'>&quot;unsupported character set&quot;</span>,
<span class='ident'>QrError</span>::<span class='ident'>InvalidEciDesignator</span> <span class='op'>=&gt;</span> <span class='string'>&quot;invalid ECI designator&quot;</span>,
<span class='ident'>QrError</span>::<span class='ident'>InvalidCharacter</span> <span class='op'>=&gt;</span> <span class='string'>&quot;invalid character&quot;</span>,
};
<span class='ident'>fmt</span>.<span class='ident'>write_str</span>(<span class='ident'>msg</span>)
}
}
<span class='doccomment'>/// `QrResult` is a convenient alias for a QR code generation result.</span>
<span class='kw'>pub</span> <span class='kw'>type</span> <span class='ident'>QrResult</span><span class='op'>&lt;</span><span class='ident'>T</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='prelude-ty'>Result</span><span class='op'>&lt;</span><span class='ident'>T</span>, <span class='ident'>QrError</span><span class='op'>&gt;</span>;
<span class='comment'>//}}}</span>
<span class='comment'>//------------------------------------------------------------------------------</span>
<span class='comment'>//{{{ Error correction level</span>
<span class='doccomment'>/// The error correction level. It allows the original information be recovered</span>
<span class='doccomment'>/// even if parts of the code is damaged.</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Copy</span>, <span class='ident'>Clone</span>, <span class='ident'>PartialOrd</span>, <span class='ident'>Ord</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>EcLevel</span> {
<span class='doccomment'>/// Low error correction. Allows up to 7% of wrong blocks.</span>
<span class='ident'>L</span> <span class='op'>=</span> <span class='number'>0</span>,
<span class='doccomment'>/// Medium error correction (default). Allows up to 15% of wrong blocks.</span>
<span class='ident'>M</span> <span class='op'>=</span> <span class='number'>1</span>,
<span class='doccomment'>/// &quot;Quartile&quot; error correction. Allows up to 25% of wrong blocks.</span>
<span class='ident'>Q</span> <span class='op'>=</span> <span class='number'>2</span>,
<span class='doccomment'>/// High error correction. Allows up to 30% of wrong blocks.</span>
<span class='ident'>H</span> <span class='op'>=</span> <span class='number'>3</span>,
}
<span class='comment'>//}}}</span>
<span class='comment'>//------------------------------------------------------------------------------</span>
<span class='comment'>//{{{ Version</span>
<span class='doccomment'>/// In QR code terminology, `Version` means the size of the generated image.</span>
<span class='doccomment'>/// Larger version means the size of code is larger, and therefore can carry</span>
<span class='doccomment'>/// more information.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// The smallest version is `Version::Normal(1)` of size 21×21, and the largest</span>
<span class='doccomment'>/// is `Version::Normal(40)` of size 177×177.</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Version</span> {
<span class='doccomment'>/// A normal QR code version. The parameter should be between 1 and 40.</span>
<span class='ident'>Normal</span>(<span class='ident'>i16</span>),
<span class='doccomment'>/// A Micro QR code version. The parameter should be between 1 and 4.</span>
<span class='ident'>Micro</span>(<span class='ident'>i16</span>),
}
<span class='kw'>impl</span> <span class='ident'>Version</span> {
<span class='doccomment'>/// Get the number of &quot;modules&quot; on each size of the QR code, i.e. the width</span>
<span class='doccomment'>/// and height of the code.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>width</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>i16</span> {
<span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='ident'>v</span>) <span class='op'>=&gt;</span> <span class='ident'>v</span> <span class='op'>*</span> <span class='number'>4</span> <span class='op'>+</span> <span class='number'>17</span>,
<span class='ident'>Version</span>::<span class='ident'>Micro</span>(<span class='ident'>v</span>) <span class='op'>=&gt;</span> <span class='ident'>v</span> <span class='op'>*</span> <span class='number'>2</span> <span class='op'>+</span> <span class='number'>9</span>,
}
}
<span class='doccomment'>/// Obtains an object from a hard-coded table.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// The table must be a 44×4 array. The outer array represents the content</span>
<span class='doccomment'>/// for each version. The first 40 entry corresponds to QR code versions 1</span>
<span class='doccomment'>/// to 40, and the last 4 corresponds to Micro QR code version 1 to 4. The</span>
<span class='doccomment'>/// inner array represents the content in each error correction level, in</span>
<span class='doccomment'>/// the order [L, M, Q, H].</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// If the entry compares equal to the default value of T, this method</span>
<span class='doccomment'>/// returns `Err(QrError::InvalidVersion)`.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>fetch</span><span class='op'>&lt;</span><span class='ident'>T</span><span class='op'>&gt;</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>ec_level</span>: <span class='ident'>EcLevel</span>, <span class='ident'>table</span>: <span class='kw-2'>&amp;</span>[[<span class='ident'>T</span>; <span class='number'>4</span>]]) <span class='op'>-&gt;</span> <span class='ident'>QrResult</span><span class='op'>&lt;</span><span class='ident'>T</span><span class='op'>&gt;</span>
<span class='kw'>where</span> <span class='ident'>T</span>: <span class='ident'>PartialEq</span> <span class='op'>+</span> <span class='ident'>Default</span> <span class='op'>+</span> <span class='ident'>Copy</span>
{
<span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='ident'>v</span> @ <span class='number'>1</span>...<span class='number'>40</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Ok</span>(<span class='ident'>table</span>[<span class='ident'>v</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>-</span> <span class='number'>1</span>][<span class='ident'>ec_level</span> <span class='kw'>as</span> <span class='ident'>usize</span>]),
<span class='ident'>Version</span>::<span class='ident'>Micro</span>(<span class='ident'>v</span> @ <span class='number'>1</span>...<span class='number'>4</span>) <span class='op'>=&gt;</span> {
<span class='kw'>let</span> <span class='ident'>obj</span> <span class='op'>=</span> <span class='ident'>table</span>[<span class='ident'>v</span> <span class='kw'>as</span> <span class='ident'>usize</span> <span class='op'>+</span> <span class='number'>39</span>][<span class='ident'>ec_level</span> <span class='kw'>as</span> <span class='ident'>usize</span>];
<span class='kw'>if</span> <span class='ident'>obj</span> <span class='op'>!=</span> <span class='ident'>Default</span>::<span class='ident'>default</span>() {
<span class='prelude-val'>Ok</span>(<span class='ident'>obj</span>)
} <span class='kw'>else</span> {
<span class='prelude-val'>Err</span>(<span class='ident'>QrError</span>::<span class='ident'>InvalidVersion</span>)
}
}
_ <span class='op'>=&gt;</span> <span class='prelude-val'>Err</span>(<span class='ident'>QrError</span>::<span class='ident'>InvalidVersion</span>)
}
}
<span class='doccomment'>/// The number of bits needed to encode the mode indicator.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>mode_bits_count</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>usize</span> {
<span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Version</span>::<span class='ident'>Micro</span>(<span class='ident'>a</span>) <span class='op'>=&gt;</span> (<span class='ident'>a</span> <span class='op'>-</span> <span class='number'>1</span>) <span class='kw'>as</span> <span class='ident'>usize</span>,
_ <span class='op'>=&gt;</span> <span class='number'>4</span>,
}
}
<span class='doccomment'>/// Checks whether is version refers to a Micro QR code.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>is_micro</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>) <span class='op'>-&gt;</span> <span class='ident'>bool</span> {
<span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Version</span>::<span class='ident'>Normal</span>(_) <span class='op'>=&gt;</span> <span class='boolvalue'>false</span>,
<span class='ident'>Version</span>::<span class='ident'>Micro</span>(_) <span class='op'>=&gt;</span> <span class='boolvalue'>true</span>,
}
}
}
<span class='comment'>//}}}</span>
<span class='comment'>//------------------------------------------------------------------------------</span>
<span class='comment'>//{{{ Mode indicator</span>
<span class='doccomment'>/// The mode indicator, which specifies the character set of the encoded data.</span>
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Debug</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Eq</span>, <span class='ident'>Copy</span>, <span class='ident'>Clone</span>)]</span>
<span class='kw'>pub</span> <span class='kw'>enum</span> <span class='ident'>Mode</span> {
<span class='doccomment'>/// The data contains only characters 0 to 9.</span>
<span class='ident'>Numeric</span>,
<span class='doccomment'>/// The data contains only uppercase letters (AZ), numbers (09) and a few</span>
<span class='doccomment'>/// punctuations marks (space, `$`, `%`, `*`, `+`, `-`, `.`, `/`, `:`).</span>
<span class='ident'>Alphanumeric</span>,
<span class='doccomment'>/// The data contains arbitrary binary data.</span>
<span class='ident'>Byte</span>,
<span class='doccomment'>/// The data contains Shift-JIS-encoded double-byte text.</span>
<span class='ident'>Kanji</span>,
}
<span class='kw'>impl</span> <span class='ident'>Mode</span> {
<span class='doccomment'>/// Computes the number of bits needed to encode the data length.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::types::{Version, Mode};</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// assert_eq!(Mode::Numeric.length_bits_count(Version::Normal(1)), 10);</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// This method will return `Err(QrError::UnsupportedCharacterSet)` if the</span>
<span class='doccomment'>/// mode is not supported in the given version.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>length_bits_count</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>version</span>: <span class='ident'>Version</span>) <span class='op'>-&gt;</span> <span class='ident'>usize</span> {
<span class='kw'>match</span> <span class='ident'>version</span> {
<span class='ident'>Version</span>::<span class='ident'>Micro</span>(<span class='ident'>a</span>) <span class='op'>=&gt;</span> {
<span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>a</span> <span class='kw'>as</span> <span class='ident'>usize</span>;
<span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Mode</span>::<span class='ident'>Numeric</span> <span class='op'>=&gt;</span> <span class='number'>2</span> <span class='op'>+</span> <span class='ident'>a</span>,
<span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span> <span class='op'>|</span> <span class='ident'>Mode</span>::<span class='ident'>Byte</span> <span class='op'>=&gt;</span> <span class='number'>1</span> <span class='op'>+</span> <span class='ident'>a</span>,
<span class='ident'>Mode</span>::<span class='ident'>Kanji</span> <span class='op'>=&gt;</span> <span class='ident'>a</span>,
}
}
<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>1</span>...<span class='number'>9</span>) <span class='op'>=&gt;</span> <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Mode</span>::<span class='ident'>Numeric</span> <span class='op'>=&gt;</span> <span class='number'>10</span>,
<span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span> <span class='op'>=&gt;</span> <span class='number'>9</span>,
<span class='ident'>Mode</span>::<span class='ident'>Byte</span> <span class='op'>=&gt;</span> <span class='number'>8</span>,
<span class='ident'>Mode</span>::<span class='ident'>Kanji</span> <span class='op'>=&gt;</span> <span class='number'>8</span>,
},
<span class='ident'>Version</span>::<span class='ident'>Normal</span>(<span class='number'>10</span>...<span class='number'>26</span>) <span class='op'>=&gt;</span> <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Mode</span>::<span class='ident'>Numeric</span> <span class='op'>=&gt;</span> <span class='number'>12</span>,
<span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span> <span class='op'>=&gt;</span> <span class='number'>11</span>,
<span class='ident'>Mode</span>::<span class='ident'>Byte</span> <span class='op'>=&gt;</span> <span class='number'>16</span>,
<span class='ident'>Mode</span>::<span class='ident'>Kanji</span> <span class='op'>=&gt;</span> <span class='number'>10</span>,
},
<span class='ident'>Version</span>::<span class='ident'>Normal</span>(_) <span class='op'>=&gt;</span> <span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Mode</span>::<span class='ident'>Numeric</span> <span class='op'>=&gt;</span> <span class='number'>14</span>,
<span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span> <span class='op'>=&gt;</span> <span class='number'>13</span>,
<span class='ident'>Mode</span>::<span class='ident'>Byte</span> <span class='op'>=&gt;</span> <span class='number'>16</span>,
<span class='ident'>Mode</span>::<span class='ident'>Kanji</span> <span class='op'>=&gt;</span> <span class='number'>12</span>,
},
}
}
<span class='doccomment'>/// Computes the number of bits needed to some data of a given raw length.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::types::Mode;</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// assert_eq!(Mode::Numeric.data_bits_count(7), 24);</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// Note that in Kanji mode, the `raw_data_len` is the number of Kanjis,</span>
<span class='doccomment'>/// i.e. half the total size of bytes.</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>data_bits_count</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>raw_data_len</span>: <span class='ident'>usize</span>) <span class='op'>-&gt;</span> <span class='ident'>usize</span> {
<span class='kw'>match</span> <span class='op'>*</span><span class='self'>self</span> {
<span class='ident'>Mode</span>::<span class='ident'>Numeric</span> <span class='op'>=&gt;</span> (<span class='ident'>raw_data_len</span> <span class='op'>*</span> <span class='number'>10</span> <span class='op'>+</span> <span class='number'>2</span>) <span class='op'>/</span> <span class='number'>3</span>,
<span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span> <span class='op'>=&gt;</span> (<span class='ident'>raw_data_len</span> <span class='op'>*</span> <span class='number'>11</span> <span class='op'>+</span> <span class='number'>1</span>) <span class='op'>/</span> <span class='number'>2</span>,
<span class='ident'>Mode</span>::<span class='ident'>Byte</span> <span class='op'>=&gt;</span> <span class='ident'>raw_data_len</span> <span class='op'>*</span> <span class='number'>8</span>,
<span class='ident'>Mode</span>::<span class='ident'>Kanji</span> <span class='op'>=&gt;</span> <span class='ident'>raw_data_len</span> <span class='op'>*</span> <span class='number'>13</span>,
}
}
<span class='doccomment'>/// Find the lowest common mode which both modes are compatible with.</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// use qrcode::types::Mode;</span>
<span class='doccomment'>///</span>
<span class='doccomment'>/// let a = Mode::Numeric;</span>
<span class='doccomment'>/// let b = Mode::Kanji;</span>
<span class='doccomment'>/// let c = a.max(b);</span>
<span class='doccomment'>/// assert!(a &lt;= c);</span>
<span class='doccomment'>/// assert!(b &lt;= c);</span>
<span class='doccomment'>///</span>
<span class='kw'>pub</span> <span class='kw'>fn</span> <span class='ident'>max</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='ident'>Mode</span>) <span class='op'>-&gt;</span> <span class='ident'>Mode</span> {
<span class='kw'>match</span> <span class='self'>self</span>.<span class='ident'>partial_cmp</span>(<span class='kw-2'>&amp;</span><span class='ident'>other</span>) {
<span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Less</span>) <span class='op'>|</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Equal</span>) <span class='op'>=&gt;</span> <span class='ident'>other</span>,
<span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Greater</span>) <span class='op'>=&gt;</span> <span class='op'>*</span><span class='self'>self</span>,
<span class='prelude-val'>None</span> <span class='op'>=&gt;</span> <span class='ident'>Mode</span>::<span class='ident'>Byte</span>,
}
}
}
<span class='kw'>impl</span> <span class='ident'>PartialOrd</span> <span class='kw'>for</span> <span class='ident'>Mode</span> {
<span class='doccomment'>/// Defines a partial ordering between modes. If `a &lt;= b`, then `b` contains</span>
<span class='doccomment'>/// a superset of all characters supported by `a`.</span>
<span class='kw'>fn</span> <span class='ident'>partial_cmp</span>(<span class='kw-2'>&amp;</span><span class='self'>self</span>, <span class='ident'>other</span>: <span class='kw-2'>&amp;</span><span class='ident'>Mode</span>) <span class='op'>-&gt;</span> <span class='prelude-ty'>Option</span><span class='op'>&lt;</span><span class='ident'>Ordering</span><span class='op'>&gt;</span> {
<span class='kw'>match</span> (<span class='op'>*</span><span class='self'>self</span>, <span class='op'>*</span><span class='ident'>other</span>) {
(<span class='ident'>Mode</span>::<span class='ident'>Numeric</span>, <span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Less</span>),
(<span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span>, <span class='ident'>Mode</span>::<span class='ident'>Numeric</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Greater</span>),
(<span class='ident'>Mode</span>::<span class='ident'>Numeric</span>, <span class='ident'>Mode</span>::<span class='ident'>Byte</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Less</span>),
(<span class='ident'>Mode</span>::<span class='ident'>Byte</span>, <span class='ident'>Mode</span>::<span class='ident'>Numeric</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Greater</span>),
(<span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span>, <span class='ident'>Mode</span>::<span class='ident'>Byte</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Less</span>),
(<span class='ident'>Mode</span>::<span class='ident'>Byte</span>, <span class='ident'>Mode</span>::<span class='ident'>Alphanumeric</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Greater</span>),
(<span class='ident'>Mode</span>::<span class='ident'>Kanji</span>, <span class='ident'>Mode</span>::<span class='ident'>Byte</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Less</span>),
(<span class='ident'>Mode</span>::<span class='ident'>Byte</span>, <span class='ident'>Mode</span>::<span class='ident'>Kanji</span>) <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Greater</span>),
(<span class='ident'>a</span>, <span class='ident'>b</span>) <span class='kw'>if</span> <span class='ident'>a</span> <span class='op'>==</span> <span class='ident'>b</span> <span class='op'>=&gt;</span> <span class='prelude-val'>Some</span>(<span class='ident'>Ordering</span>::<span class='ident'>Equal</span>),
_ <span class='op'>=&gt;</span> <span class='prelude-val'>None</span>,
}
}
}
<span class='attribute'>#[<span class='ident'>cfg</span>(<span class='ident'>test</span>)]</span>
<span class='kw'>mod</span> <span class='ident'>mode_tests</span> {
<span class='kw'>use</span> <span class='ident'>types</span>::<span class='ident'>Mode</span>::{<span class='ident'>Numeric</span>, <span class='ident'>Alphanumeric</span>, <span class='ident'>Byte</span>, <span class='ident'>Kanji</span>};
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_mode_order</span>() {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Numeric</span> <span class='op'>&lt;</span> <span class='ident'>Alphanumeric</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>Byte</span> <span class='op'>&gt;</span> <span class='ident'>Kanji</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span>(<span class='ident'>Numeric</span> <span class='op'>&lt;</span> <span class='ident'>Kanji</span>));
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span>(<span class='ident'>Numeric</span> <span class='op'>&gt;=</span> <span class='ident'>Kanji</span>));
}
<span class='attribute'>#[<span class='ident'>test</span>]</span>
<span class='kw'>fn</span> <span class='ident'>test_max</span>() {
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Byte</span>.<span class='ident'>max</span>(<span class='ident'>Kanji</span>), <span class='ident'>Byte</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Numeric</span>.<span class='ident'>max</span>(<span class='ident'>Alphanumeric</span>), <span class='ident'>Alphanumeric</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Alphanumeric</span>.<span class='ident'>max</span>(<span class='ident'>Alphanumeric</span>), <span class='ident'>Alphanumeric</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Numeric</span>.<span class='ident'>max</span>(<span class='ident'>Kanji</span>), <span class='ident'>Byte</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Kanji</span>.<span class='ident'>max</span>(<span class='ident'>Numeric</span>), <span class='ident'>Byte</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Alphanumeric</span>.<span class='ident'>max</span>(<span class='ident'>Numeric</span>), <span class='ident'>Alphanumeric</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>Kanji</span>.<span class='ident'>max</span>(<span class='ident'>Kanji</span>), <span class='ident'>Kanji</span>);
}
}
<span class='comment'>//}}}</span>
</pre>
</section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../../";
window.currentCrate = "qrcode";
window.playgroundUrl = "";
</script>
<script src="../../../jquery.js"></script>
<script src="../../../main.js"></script>
<script defer src="../../../search-index.js"></script>
</body>
</html>

150
src/render/image.rs Normal file
View file

@ -0,0 +1,150 @@
#![cfg(feature="image")]
use crate::render::{Canvas, Pixel};
use crate::types::Color;
use image::{ImageBuffer, Luma, LumaA, Pixel as ImagePixel, Primitive, Rgb, Rgba};
macro_rules! impl_pixel_for_image_pixel {
($p:ident<$s:ident>: $c:pat => $d:expr) => {
impl<$s: Primitive + 'static> Pixel for $p<$s> {
type Image = ImageBuffer<Self, Vec<S>>;
type Canvas = (Self, Self::Image);
fn default_color(color: Color) -> Self {
match color.select($s::zero(), $s::max_value()) {
$c => $p($d),
}
}
}
};
}
impl_pixel_for_image_pixel! { Luma<S>: p => [p] }
impl_pixel_for_image_pixel! { LumaA<S>: p => [p, S::max_value()] }
impl_pixel_for_image_pixel! { Rgb<S>: p => [p, p, p] }
impl_pixel_for_image_pixel! { Rgba<S>: p => [p, p, p, S::max_value()] }
impl<P: ImagePixel + 'static> Canvas for (P, ImageBuffer<P, Vec<P::Subpixel>>) {
type Pixel = P;
type Image = ImageBuffer<P, Vec<P::Subpixel>>;
fn new(width: u32, height: u32, dark_pixel: P, light_pixel: P) -> Self {
(dark_pixel, ImageBuffer::from_pixel(width, height, light_pixel))
}
fn draw_dark_pixel(&mut self, x: u32, y: u32) {
self.1.put_pixel(x, y, self.0);
}
fn into_image(self) -> ImageBuffer<P, Vec<P::Subpixel>> {
self.1
}
}
#[cfg(test)]
mod render_tests {
use crate::render::Renderer;
use crate::types::Color;
use image::{Luma, Rgba};
#[test]
fn test_render_luma8_unsized() {
let image = Renderer::<Luma<u8>>::new(
&[
Color::Light,
Color::Dark,
Color::Dark,
//
Color::Dark,
Color::Light,
Color::Light,
//
Color::Light,
Color::Dark,
Color::Light,
],
3,
1,
)
.module_dimensions(1, 1)
.build();
#[rustfmt::skip]
let expected = [
255, 255, 255, 255, 255,
255, 255, 0, 0, 255,
255, 0, 255, 255, 255,
255, 255, 0, 255, 255,
255, 255, 255, 255, 255,
];
assert_eq!(image.into_raw(), expected);
}
#[test]
fn test_render_rgba_unsized() {
let image = Renderer::<Rgba<u8>>::new(&[Color::Light, Color::Dark, Color::Dark, Color::Dark], 2, 1)
.module_dimensions(1, 1)
.build();
#[rustfmt::skip]
let expected: &[u8] = &[
255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255,
255,255,255,255, 255,255,255,255, 0, 0, 0,255, 255,255,255,255,
255,255,255,255, 0, 0, 0,255, 0, 0, 0,255, 255,255,255,255,
255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255,
];
assert_eq!(image.into_raw(), expected);
}
#[test]
fn test_render_resized_min() {
let image = Renderer::<Luma<u8>>::new(&[Color::Dark, Color::Light, Color::Light, Color::Dark], 2, 1)
.min_dimensions(10, 10)
.build();
#[rustfmt::skip]
let expected: &[u8] = &[
255,255,255, 255,255,255, 255,255,255, 255,255,255,
255,255,255, 255,255,255, 255,255,255, 255,255,255,
255,255,255, 255,255,255, 255,255,255, 255,255,255,
255,255,255, 0, 0, 0, 255,255,255, 255,255,255,
255,255,255, 0, 0, 0, 255,255,255, 255,255,255,
255,255,255, 0, 0, 0, 255,255,255, 255,255,255,
255,255,255, 255,255,255, 0, 0, 0, 255,255,255,
255,255,255, 255,255,255, 0, 0, 0, 255,255,255,
255,255,255, 255,255,255, 0, 0, 0, 255,255,255,
255,255,255, 255,255,255, 255,255,255, 255,255,255,
255,255,255, 255,255,255, 255,255,255, 255,255,255,
255,255,255, 255,255,255, 255,255,255, 255,255,255,
];
assert_eq!(image.dimensions(), (12, 12));
assert_eq!(image.into_raw(), expected);
}
#[test]
fn test_render_resized_max() {
let image = Renderer::<Luma<u8>>::new(&[Color::Dark, Color::Light, Color::Light, Color::Dark], 2, 1)
.max_dimensions(10, 5)
.build();
#[rustfmt::skip]
let expected: &[u8] = &[
255,255, 255,255, 255,255, 255,255,
255,255, 0, 0, 255,255, 255,255,
255,255, 255,255, 0, 0, 255,255,
255,255, 255,255, 255,255, 255,255,
];
assert_eq!(image.dimensions(), (8, 4));
assert_eq!(image.into_raw(), expected);
}
}

191
src/render/mod.rs Normal file
View file

@ -0,0 +1,191 @@
//! Render a QR code into image.
use crate::cast::As;
use crate::types::Color;
use std::cmp::max;
pub mod image;
pub mod string;
pub mod svg;
pub mod unicode;
//------------------------------------------------------------------------------
//{{{ Pixel trait
/// Abstraction of an image pixel.
pub trait Pixel: Copy + Sized {
/// Type of the finalized image.
type Image: Sized + 'static;
/// The type that stores an intermediate buffer before finalizing to a
/// concrete image
type Canvas: Canvas<Pixel = Self, Image = Self::Image>;
/// Obtains the default module size. The result must be at least 1×1.
fn default_unit_size() -> (u32, u32) {
(8, 8)
}
/// Obtains the default pixel color when a module is dark or light.
fn default_color(color: Color) -> Self;
}
/// Rendering canvas of a QR code image.
pub trait Canvas: Sized {
type Pixel: Sized;
type Image: Sized;
/// Constructs a new canvas of the given dimensions.
fn new(width: u32, height: u32, dark_pixel: Self::Pixel, light_pixel: Self::Pixel) -> Self;
/// Draws a single dark pixel at the (x, y) coordinate.
fn draw_dark_pixel(&mut self, x: u32, y: u32);
fn draw_dark_rect(&mut self, left: u32, top: u32, width: u32, height: u32) {
for y in top..(top + height) {
for x in left..(left + width) {
self.draw_dark_pixel(x, y);
}
}
}
/// Finalize the canvas to a real image.
fn into_image(self) -> Self::Image;
}
//}}}
//------------------------------------------------------------------------------
//{{{ Renderer
/// A QR code renderer. This is a builder type which converts a bool-vector into
/// an image.
pub struct Renderer<'a, P: Pixel> {
content: &'a [Color],
modules_count: u32, // <- we call it `modules_count` here to avoid ambiguity of `width`.
quiet_zone: u32,
module_size: (u32, u32),
dark_color: P,
light_color: P,
has_quiet_zone: bool,
}
impl<'a, P: Pixel> Renderer<'a, P> {
/// Creates a new renderer.
pub fn new(content: &'a [Color], modules_count: usize, quiet_zone: u32) -> Renderer<'a, P> {
assert!(modules_count * modules_count == content.len());
Renderer {
content,
modules_count: modules_count.as_u32(),
quiet_zone,
module_size: P::default_unit_size(),
dark_color: P::default_color(Color::Dark),
light_color: P::default_color(Color::Light),
has_quiet_zone: true,
}
}
/// Sets color of a dark module. Default is opaque black.
pub fn dark_color(&mut self, color: P) -> &mut Self {
self.dark_color = color;
self
}
/// Sets color of a light module. Default is opaque white.
pub fn light_color(&mut self, color: P) -> &mut Self {
self.light_color = color;
self
}
/// Whether to include the quiet zone in the generated image.
pub fn quiet_zone(&mut self, has_quiet_zone: bool) -> &mut Self {
self.has_quiet_zone = has_quiet_zone;
self
}
/// Sets the size of each module in pixels. Default is 8px.
#[deprecated(since = "0.4.0", note = "use `.module_dimensions(width, width)` instead")]
pub fn module_size(&mut self, width: u32) -> &mut Self {
self.module_dimensions(width, width)
}
/// Sets the size of each module in pixels. Default is 8×8.
pub fn module_dimensions(&mut self, width: u32, height: u32) -> &mut Self {
self.module_size = (max(width, 1), max(height, 1));
self
}
#[deprecated(since = "0.4.0", note = "use `.min_dimensions(width, width)` instead")]
pub fn min_width(&mut self, width: u32) -> &mut Self {
self.min_dimensions(width, width)
}
/// Sets the minimum total image size in pixels, including the quiet zone if
/// applicable. The renderer will try to find the dimension as small as
/// possible, such that each module in the QR code has uniform size (no
/// distortion).
///
/// For instance, a version 1 QR code has 19 modules across including the
/// quiet zone. If we request an image of size ≥200×200, we get that each
/// module's size should be 11×11, so the actual image size will be 209×209.
pub fn min_dimensions(&mut self, width: u32, height: u32) -> &mut Self {
let quiet_zone = if self.has_quiet_zone { 2 } else { 0 } * self.quiet_zone;
let width_in_modules = self.modules_count + quiet_zone;
let unit_width = (width + width_in_modules - 1) / width_in_modules;
let unit_height = (height + width_in_modules - 1) / width_in_modules;
self.module_dimensions(unit_width, unit_height)
}
/// Sets the maximum total image size in pixels, including the quiet zone if
/// applicable. The renderer will try to find the dimension as large as
/// possible, such that each module in the QR code has uniform size (no
/// distortion).
///
/// For instance, a version 1 QR code has 19 modules across including the
/// quiet zone. If we request an image of size ≤200×200, we get that each
/// module's size should be 10×10, so the actual image size will be 190×190.
///
/// The module size is at least 1×1, so if the restriction is too small, the
/// final image *can* be larger than the input.
pub fn max_dimensions(&mut self, width: u32, height: u32) -> &mut Self {
let quiet_zone = if self.has_quiet_zone { 2 } else { 0 } * self.quiet_zone;
let width_in_modules = self.modules_count + quiet_zone;
let unit_width = width / width_in_modules;
let unit_height = height / width_in_modules;
self.module_dimensions(unit_width, unit_height)
}
/// Renders the QR code into an image.
#[deprecated(since = "0.4.0", note = "renamed to `.build()` to de-emphasize the image connection")]
pub fn to_image(&self) -> P::Image {
self.build()
}
/// Renders the QR code into an image.
pub fn build(&self) -> P::Image {
let w = self.modules_count;
let qz = if self.has_quiet_zone { self.quiet_zone } else { 0 };
let width = w + 2 * qz;
let (mw, mh) = self.module_size;
let real_width = width * mw;
let real_height = width * mh;
let mut canvas = P::Canvas::new(real_width, real_height, self.dark_color, self.light_color);
let mut i = 0;
for y in 0..width {
for x in 0..width {
if qz <= x && x < w + qz && qz <= y && y < w + qz {
if self.content[i] != Color::Light {
canvas.draw_dark_rect(x * mw, y * mh, mw, mh);
}
i += 1;
}
}
}
canvas.into_image()
}
}
//}}}

121
src/render/string.rs Normal file
View file

@ -0,0 +1,121 @@
//! String rendering support.
use crate::cast::As;
use crate::render::{Canvas as RenderCanvas, Pixel};
use crate::types::Color;
pub trait Element: Copy {
fn default_color(color: Color) -> Self;
fn strlen(self) -> usize;
fn append_to_string(self, string: &mut String);
}
impl Element for char {
fn default_color(color: Color) -> Self {
color.select('\u{2588}', ' ')
}
fn strlen(self) -> usize {
self.len_utf8()
}
fn append_to_string(self, string: &mut String) {
string.push(self)
}
}
impl<'a> Element for &'a str {
fn default_color(color: Color) -> Self {
color.select("\u{2588}", " ")
}
fn strlen(self) -> usize {
self.len()
}
fn append_to_string(self, string: &mut String) {
string.push_str(self)
}
}
#[doc(hidden)]
pub struct Canvas<P: Element> {
buffer: Vec<P>,
width: usize,
dark_pixel: P,
dark_cap_inc: isize,
capacity: isize,
}
impl<P: Element> Pixel for P {
type Canvas = Canvas<Self>;
type Image = String;
fn default_unit_size() -> (u32, u32) {
(1, 1)
}
fn default_color(color: Color) -> Self {
<Self as Element>::default_color(color)
}
}
impl<P: Element> RenderCanvas for Canvas<P> {
type Pixel = P;
type Image = String;
fn new(width: u32, height: u32, dark_pixel: P, light_pixel: P) -> Self {
let width = width.as_usize();
let height = height.as_isize();
let dark_cap = dark_pixel.strlen().as_isize();
let light_cap = light_pixel.strlen().as_isize();
Self {
buffer: vec![light_pixel; width * height.as_usize()],
width,
dark_pixel,
dark_cap_inc: dark_cap - light_cap,
capacity: light_cap * width.as_isize() * height + (height - 1),
}
}
fn draw_dark_pixel(&mut self, x: u32, y: u32) {
let x = x.as_usize();
let y = y.as_usize();
self.capacity += self.dark_cap_inc;
self.buffer[x + y * self.width] = self.dark_pixel;
}
fn into_image(self) -> String {
let mut result = String::with_capacity(self.capacity.as_usize());
for (i, pixel) in self.buffer.into_iter().enumerate() {
if i != 0 && i % self.width == 0 {
result.push('\n');
}
pixel.append_to_string(&mut result);
}
result
}
}
#[test]
fn test_render_to_string() {
use crate::render::Renderer;
let colors = &[Color::Dark, Color::Light, Color::Light, Color::Dark];
let image: String = Renderer::<char>::new(colors, 2, 1).build();
assert_eq!(&image, " \n \u{2588} \n \u{2588} \n ");
let image2 = Renderer::new(colors, 2, 1).light_color("A").dark_color("!B!").module_dimensions(2, 2).build();
assert_eq!(
&image2,
"AAAAAAAA\n\
AAAAAAAA\n\
AA!B!!B!AAAA\n\
AA!B!!B!AAAA\n\
AAAA!B!!B!AA\n\
AAAA!B!!B!AA\n\
AAAAAAAA\n\
AAAAAAAA"
);
}

76
src/render/svg.rs Normal file
View file

@ -0,0 +1,76 @@
//! SVG rendering support.
//!
//! # Example
//!
//! ```
//! use qrcode::QrCode;
//! use qrcode::render::svg;
//!
//! let code = QrCode::new(b"Hello").unwrap();
//! let svg_xml = code.render::<svg::Color>().build();
//! println!("{}", svg_xml);
#![cfg(feature="svg")]
use std::fmt::Write;
use std::marker::PhantomData;
use crate::render::{Canvas as RenderCanvas, Pixel};
use crate::types::Color as ModuleColor;
/// An SVG color.
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Color<'a>(pub &'a str);
impl<'a> Pixel for Color<'a> {
type Canvas = Canvas<'a>;
type Image = String;
fn default_color(color: ModuleColor) -> Self {
Color(color.select("#000", "#fff"))
}
}
#[doc(hidden)]
pub struct Canvas<'a> {
svg: String,
marker: PhantomData<Color<'a>>,
}
impl<'a> RenderCanvas for Canvas<'a> {
type Pixel = Color<'a>;
type Image = String;
fn new(width: u32, height: u32, dark_pixel: Color<'a>, light_pixel: Color<'a>) -> Self {
Canvas {
svg: format!(
concat!(
r#"<?xml version="1.0" standalone="yes"?>"#,
r#"<svg xmlns="http://www.w3.org/2000/svg""#,
r#" version="1.1" width="{w}" height="{h}""#,
r#" viewBox="0 0 {w} {h}" shape-rendering="crispEdges">"#,
r#"<rect x="0" y="0" width="{w}" height="{h}" fill="{bg}"/>"#,
r#"<path fill="{fg}" d=""#,
),
w = width,
h = height,
fg = dark_pixel.0,
bg = light_pixel.0
),
marker: PhantomData,
}
}
fn draw_dark_pixel(&mut self, x: u32, y: u32) {
self.draw_dark_rect(x, y, 1, 1)
}
fn draw_dark_rect(&mut self, left: u32, top: u32, width: u32, height: u32) {
write!(self.svg, "M{l} {t}h{w}v{h}H{l}V{t}", l = left, t = top, w = width, h = height).unwrap();
}
fn into_image(mut self) -> String {
self.svg.push_str(r#""/></svg>"#);
self.svg
}
}

141
src/render/unicode.rs Normal file
View file

@ -0,0 +1,141 @@
//! UTF-8 rendering, with 2 pixels per symbol.
use crate::render::{Canvas as RenderCanvas, Color, Pixel};
const CODEPAGE: [&str; 4] = [" ", "\u{2584}", "\u{2580}", "\u{2588}"];
#[derive(Copy, Clone, PartialEq)]
pub enum Dense1x2 {
Dark,
Light,
}
impl Pixel for Dense1x2 {
type Image = String;
type Canvas = Canvas1x2;
fn default_color(color: Color) -> Dense1x2 {
color.select(Dense1x2::Dark, Dense1x2::Light)
}
fn default_unit_size() -> (u32, u32) {
(1, 1)
}
}
impl Dense1x2 {
fn value(self) -> u8 {
match self {
Dense1x2::Dark => 1,
Dense1x2::Light => 0,
}
}
fn parse_2_bits(sym: u8) -> &'static str {
CODEPAGE[usize::from(sym)]
}
}
pub struct Canvas1x2 {
canvas: Vec<u8>,
width: u32,
dark_pixel: u8,
}
impl RenderCanvas for Canvas1x2 {
type Pixel = Dense1x2;
type Image = String;
fn new(width: u32, height: u32, dark_pixel: Dense1x2, light_pixel: Dense1x2) -> Self {
let a = vec![light_pixel.value(); (width * height) as usize];
Canvas1x2 { width, canvas: a, dark_pixel: dark_pixel.value() }
}
fn draw_dark_pixel(&mut self, x: u32, y: u32) {
self.canvas[(x + y * self.width) as usize] = self.dark_pixel;
}
fn into_image(self) -> String {
self.canvas
// Chopping array into 1-line sized fragments
.chunks_exact(self.width as usize)
.collect::<Vec<&[u8]>>()
// And then glueing every 2 lines.
.chunks(2)
.map(|rows| {
{
// Then zipping those 2 lines together into a single 2-bit number list.
if rows.len() == 2 {
rows[0].iter().zip(rows[1]).map(|(top, bot)| (top * 2 + bot)).collect::<Vec<u8>>()
} else {
rows[0].iter().map(|top| (top * 2)).collect::<Vec<u8>>()
}
}
.into_iter()
// Mapping those 2-bit numbers to corresponding pixels.
.map(Dense1x2::parse_2_bits)
.collect::<Vec<&str>>()
.concat()
})
.collect::<Vec<String>>()
.join("\n")
}
}
#[test]
fn test_render_to_utf8_string() {
use crate::render::Renderer;
let colors = &[Color::Dark, Color::Light, Color::Light, Color::Dark];
let image: String = Renderer::<Dense1x2>::new(colors, 2, 1).build();
assert_eq!(&image, "\n");
let image2 = Renderer::<Dense1x2>::new(colors, 2, 1).module_dimensions(2, 2).build();
assert_eq!(&image2, " \n ██ \n ██ \n ");
}
#[test]
fn integration_render_utf8_1x2() {
use crate::render::unicode::Dense1x2;
use crate::{EcLevel, QrCode, Version};
let code = QrCode::with_version(b"09876542", Version::Micro(2), EcLevel::L).unwrap();
let image = code.render::<Dense1x2>().module_dimensions(1, 1).build();
assert_eq!(
image,
String::new()
+ " \n"
+ " █▀▀▀▀▀█ ▀ █ ▀ \n"
+ " █ ███ █ ▀ █ \n"
+ " █ ▀▀▀ █ ▀█ █ \n"
+ " ▀▀▀▀▀▀▀ ▄▀▀ █ \n"
+ " ▀█ ▀▀▀▀▀██▀▀▄ \n"
+ " ▀███▄ ▀▀ █ ██ \n"
+ " ▀▀▀ ▀ ▀▀ ▀ ▀ \n"
+ " "
)
}
#[test]
fn integration_render_utf8_1x2_inverted() {
use crate::render::unicode::Dense1x2;
use crate::{EcLevel, QrCode, Version};
let code = QrCode::with_version(b"12345678", Version::Micro(2), EcLevel::L).unwrap();
let image = code
.render::<Dense1x2>()
.dark_color(Dense1x2::Light)
.light_color(Dense1x2::Dark)
.module_dimensions(1, 1)
.build();
assert_eq!(
image,
"█████████████████\n\
\n\
\n\
\n\
\n\
\n\
\n\
\n\
"
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

View file

@ -0,0 +1 @@
<?xml version="1.0" standalone="yes"?><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="204" height="204" viewBox="0 0 204 204" shape-rendering="crispEdges"><rect x="0" y="0" width="204" height="204" fill="#ffff80"/><path fill="#800000" d="M24 24h12v12H24V24M36 24h12v12H36V24M48 24h12v12H48V24M60 24h12v12H60V24M72 24h12v12H72V24M84 24h12v12H84V24M96 24h12v12H96V24M120 24h12v12H120V24M144 24h12v12H144V24M168 24h12v12H168V24M24 36h12v12H24V36M96 36h12v12H96V36M120 36h12v12H120V36M132 36h12v12H132V36M144 36h12v12H144V36M168 36h12v12H168V36M24 48h12v12H24V48M48 48h12v12H48V48M60 48h12v12H60V48M72 48h12v12H72V48M96 48h12v12H96V48M132 48h12v12H132V48M144 48h12v12H144V48M168 48h12v12H168V48M24 60h12v12H24V60M48 60h12v12H48V60M60 60h12v12H60V60M72 60h12v12H72V60M96 60h12v12H96V60M132 60h12v12H132V60M144 60h12v12H144V60M156 60h12v12H156V60M168 60h12v12H168V60M24 72h12v12H24V72M48 72h12v12H48V72M60 72h12v12H60V72M72 72h12v12H72V72M96 72h12v12H96V72M120 72h12v12H120V72M132 72h12v12H132V72M144 72h12v12H144V72M24 84h12v12H24V84M96 84h12v12H96V84M120 84h12v12H120V84M168 84h12v12H168V84M24 96h12v12H24V96M36 96h12v12H36V96M48 96h12v12H48V96M60 96h12v12H60V96M72 96h12v12H72V96M84 96h12v12H84V96M96 96h12v12H96V96M132 96h12v12H132V96M144 96h12v12H144V96M156 96h12v12H156V96M168 96h12v12H168V96M132 108h12v12H132V108M144 108h12v12H144V108M24 120h12v12H24V120M36 120h12v12H36V120M60 120h12v12H60V120M120 120h12v12H120V120M168 120h12v12H168V120M36 132h12v12H36V132M48 132h12v12H48V132M72 132h12v12H72V132M96 132h12v12H96V132M120 132h12v12H120V132M144 132h12v12H144V132M168 132h12v12H168V132M24 144h12v12H24V144M36 144h12v12H36V144M48 144h12v12H48V144M84 144h12v12H84V144M96 144h12v12H96V144M108 144h12v12H108V144M120 144h12v12H120V144M132 144h12v12H132V144M144 144h12v12H144V144M156 144h12v12H156V144M60 156h12v12H60V156M84 156h12v12H84V156M144 156h12v12H144V156M156 156h12v12H156V156M24 168h12v12H24V168M36 168h12v12H36V168M48 168h12v12H48V168M72 168h12v12H72V168M108 168h12v12H108V168M120 168h12v12H120V168M144 168h12v12H144V168M156 168h12v12H156V168M168 168h12v12H168V168"/></svg>

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

View file

@ -0,0 +1 @@
<?xml version="1.0" standalone="yes"?><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="232" height="232" viewBox="0 0 232 232" shape-rendering="crispEdges"><rect x="0" y="0" width="232" height="232" fill="#fff"/><path fill="#000" d="M32 32h8v8H32V32M40 32h8v8H40V32M48 32h8v8H48V32M56 32h8v8H56V32M64 32h8v8H64V32M72 32h8v8H72V32M80 32h8v8H80V32M104 32h8v8H104V32M120 32h8v8H120V32M128 32h8v8H128V32M144 32h8v8H144V32M152 32h8v8H152V32M160 32h8v8H160V32M168 32h8v8H168V32M176 32h8v8H176V32M184 32h8v8H184V32M192 32h8v8H192V32M32 40h8v8H32V40M80 40h8v8H80V40M104 40h8v8H104V40M112 40h8v8H112V40M120 40h8v8H120V40M128 40h8v8H128V40M144 40h8v8H144V40M192 40h8v8H192V40M32 48h8v8H32V48M48 48h8v8H48V48M56 48h8v8H56V48M64 48h8v8H64V48M80 48h8v8H80V48M96 48h8v8H96V48M144 48h8v8H144V48M160 48h8v8H160V48M168 48h8v8H168V48M176 48h8v8H176V48M192 48h8v8H192V48M32 56h8v8H32V56M48 56h8v8H48V56M56 56h8v8H56V56M64 56h8v8H64V56M80 56h8v8H80V56M96 56h8v8H96V56M104 56h8v8H104V56M144 56h8v8H144V56M160 56h8v8H160V56M168 56h8v8H168V56M176 56h8v8H176V56M192 56h8v8H192V56M32 64h8v8H32V64M48 64h8v8H48V64M56 64h8v8H56V64M64 64h8v8H64V64M80 64h8v8H80V64M96 64h8v8H96V64M112 64h8v8H112V64M120 64h8v8H120V64M128 64h8v8H128V64M144 64h8v8H144V64M160 64h8v8H160V64M168 64h8v8H168V64M176 64h8v8H176V64M192 64h8v8H192V64M32 72h8v8H32V72M80 72h8v8H80V72M96 72h8v8H96V72M128 72h8v8H128V72M144 72h8v8H144V72M192 72h8v8H192V72M32 80h8v8H32V80M40 80h8v8H40V80M48 80h8v8H48V80M56 80h8v8H56V80M64 80h8v8H64V80M72 80h8v8H72V80M80 80h8v8H80V80M96 80h8v8H96V80M112 80h8v8H112V80M128 80h8v8H128V80M144 80h8v8H144V80M152 80h8v8H152V80M160 80h8v8H160V80M168 80h8v8H168V80M176 80h8v8H176V80M184 80h8v8H184V80M192 80h8v8H192V80M96 88h8v8H96V88M120 88h8v8H120V88M128 88h8v8H128V88M32 96h8v8H32V96M48 96h8v8H48V96M56 96h8v8H56V96M64 96h8v8H64V96M72 96h8v8H72V96M80 96h8v8H80V96M104 96h8v8H104V96M128 96h8v8H128V96M144 96h8v8H144V96M152 96h8v8H152V96M160 96h8v8H160V96M168 96h8v8H168V96M176 96h8v8H176V96M56 104h8v8H56V104M72 104h8v8H72V104M88 104h8v8H88V104M96 104h8v8H96V104M112 104h8v8H112V104M128 104h8v8H128V104M152 104h8v8H152V104M168 104h8v8H168V104M176 104h8v8H176V104M48 112h8v8H48V112M80 112h8v8H80V112M88 112h8v8H88V112M104 112h8v8H104V112M120 112h8v8H120V112M136 112h8v8H136V112M160 112h8v8H160V112M168 112h8v8H168V112M176 112h8v8H176V112M184 112h8v8H184V112M192 112h8v8H192V112M64 120h8v8H64V120M104 120h8v8H104V120M152 120h8v8H152V120M160 120h8v8H160V120M168 120h8v8H168V120M176 120h8v8H176V120M56 128h8v8H56V128M64 128h8v8H64V128M72 128h8v8H72V128M80 128h8v8H80V128M88 128h8v8H88V128M96 128h8v8H96V128M120 128h8v8H120V128M136 128h8v8H136V128M160 128h8v8H160V128M96 136h8v8H96V136M112 136h8v8H112V136M120 136h8v8H120V136M128 136h8v8H128V136M136 136h8v8H136V136M144 136h8v8H144V136M168 136h8v8H168V136M176 136h8v8H176V136M32 144h8v8H32V144M40 144h8v8H40V144M48 144h8v8H48V144M56 144h8v8H56V144M64 144h8v8H64V144M72 144h8v8H72V144M80 144h8v8H80V144M104 144h8v8H104V144M112 144h8v8H112V144M128 144h8v8H128V144M144 144h8v8H144V144M152 144h8v8H152V144M32 152h8v8H32V152M80 152h8v8H80V152M96 152h8v8H96V152M112 152h8v8H112V152M120 152h8v8H120V152M128 152h8v8H128V152M136 152h8v8H136V152M144 152h8v8H144V152M176 152h8v8H176V152M192 152h8v8H192V152M32 160h8v8H32V160M48 160h8v8H48V160M56 160h8v8H56V160M64 160h8v8H64V160M80 160h8v8H80V160M96 160h8v8H96V160M128 160h8v8H128V160M152 160h8v8H152V160M168 160h8v8H168V160M176 160h8v8H176V160M32 168h8v8H32V168M48 168h8v8H48V168M56 168h8v8H56V168M64 168h8v8H64V168M80 168h8v8H80V168M96 168h8v8H96V168M104 168h8v8H104V168M128 168h8v8H128V168M152 168h8v8H152V168M32 176h8v8H32V176M48 176h8v8H48V176M56 176h8v8H56V176M64 176h8v8H64V176M80 176h8v8H80V176M96 176h8v8H96V176M112 176h8v8H112V176M120 176h8v8H120V176M136 176h8v8H136V176M160 176h8v8H160V176M176 176h8v8H176V176M32 184h8v8H32V184M80 184h8v8H80V184M152 184h8v8H152V184M160 184h8v8H160V184M176 184h8v8H176V184M184 184h8v8H184V184M32 192h8v8H32V192M40 192h8v8H40V192M48 192h8v8H48V192M56 192h8v8H56V192M64 192h8v8H64V192M72 192h8v8H72V192M80 192h8v8H80V192M96 192h8v8H96V192M104 192h8v8H104V192M112 192h8v8H112V192M120 192h8v8H120V192M136 192h8v8H136V192M160 192h8v8H160V192M176 192h8v8H176V192"/></svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

328
src/types.rs Normal file
View file

@ -0,0 +1,328 @@
use crate::cast::As;
use std::cmp::{Ordering, PartialOrd};
use std::default::Default;
use std::fmt::{Display, Error, Formatter};
use std::ops::Not;
//------------------------------------------------------------------------------
//{{{ QrResult
/// `QrError` encodes the error encountered when generating a QR code.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum QrError {
/// The data is too long to encode into a QR code for the given version.
DataTooLong,
/// The provided version / error correction level combination is invalid.
InvalidVersion,
/// Some characters in the data cannot be supported by the provided QR code
/// version.
UnsupportedCharacterSet,
/// The provided ECI designator is invalid. A valid designator should be
/// between 0 and 999999.
InvalidEciDesignator,
/// A character not belonging to the character set is found.
InvalidCharacter,
}
impl Display for QrError {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
let msg = match *self {
QrError::DataTooLong => "data too long",
QrError::InvalidVersion => "invalid version",
QrError::UnsupportedCharacterSet => "unsupported character set",
QrError::InvalidEciDesignator => "invalid ECI designator",
QrError::InvalidCharacter => "invalid character",
};
fmt.write_str(msg)
}
}
impl ::std::error::Error for QrError {}
/// `QrResult` is a convenient alias for a QR code generation result.
pub type QrResult<T> = Result<T, QrError>;
//}}}
//------------------------------------------------------------------------------
//{{{ Color
/// The color of a module.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum Color {
/// The module is light colored.
Light,
/// The module is dark colored.
Dark,
}
impl Color {
/// Selects a value according to color of the module. Equivalent to
/// `if self != Color::Light { dark } else { light }`.
///
/// # Examples
///
/// ```rust
/// # use qrcode::types::Color;
/// assert_eq!(Color::Light.select(1, 0), 0);
/// assert_eq!(Color::Dark.select("black", "white"), "black");
/// ```
pub fn select<T>(self, dark: T, light: T) -> T {
match self {
Color::Light => light,
Color::Dark => dark,
}
}
}
impl Not for Color {
type Output = Self;
fn not(self) -> Self {
match self {
Color::Light => Color::Dark,
Color::Dark => Color::Light,
}
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Error correction level
/// The error correction level. It allows the original information be recovered
/// even if parts of the code is damaged.
#[derive(Debug, PartialEq, Eq, Copy, Clone, PartialOrd, Ord)]
pub enum EcLevel {
/// Low error correction. Allows up to 7% of wrong blocks.
L = 0,
/// Medium error correction (default). Allows up to 15% of wrong blocks.
M = 1,
/// "Quartile" error correction. Allows up to 25% of wrong blocks.
Q = 2,
/// High error correction. Allows up to 30% of wrong blocks.
H = 3,
}
//}}}
//------------------------------------------------------------------------------
//{{{ Version
/// In QR code terminology, `Version` means the size of the generated image.
/// Larger version means the size of code is larger, and therefore can carry
/// more information.
///
/// The smallest version is `Version::Normal(1)` of size 21×21, and the largest
/// is `Version::Normal(40)` of size 177×177.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum Version {
/// A normal QR code version. The parameter should be between 1 and 40.
Normal(i16),
/// A Micro QR code version. The parameter should be between 1 and 4.
Micro(i16),
}
impl Version {
/// Get the number of "modules" on each size of the QR code, i.e. the width
/// and height of the code.
pub fn width(self) -> i16 {
match self {
Version::Normal(v) => v * 4 + 17,
Version::Micro(v) => v * 2 + 9,
}
}
/// Obtains an object from a hard-coded table.
///
/// The table must be a 44×4 array. The outer array represents the content
/// for each version. The first 40 entry corresponds to QR code versions 1
/// to 40, and the last 4 corresponds to Micro QR code version 1 to 4. The
/// inner array represents the content in each error correction level, in
/// the order [L, M, Q, H].
///
/// # Errors
///
/// If the entry compares equal to the default value of `T`, this method
/// returns `Err(QrError::InvalidVersion)`.
pub fn fetch<T>(self, ec_level: EcLevel, table: &[[T; 4]]) -> QrResult<T>
where
T: PartialEq + Default + Copy,
{
match self {
Version::Normal(v @ 1..=40) => {
return Ok(table[(v - 1).as_usize()][ec_level as usize]);
}
Version::Micro(v @ 1..=4) => {
let obj = table[(v + 39).as_usize()][ec_level as usize];
if obj != T::default() {
return Ok(obj);
}
}
_ => {}
}
Err(QrError::InvalidVersion)
}
/// The number of bits needed to encode the mode indicator.
pub fn mode_bits_count(self) -> usize {
match self {
Version::Micro(a) => (a - 1).as_usize(),
_ => 4,
}
}
/// Checks whether is version refers to a Micro QR code.
pub fn is_micro(self) -> bool {
match self {
Version::Normal(_) => false,
Version::Micro(_) => true,
}
}
}
//}}}
//------------------------------------------------------------------------------
//{{{ Mode indicator
/// The mode indicator, which specifies the character set of the encoded data.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum Mode {
/// The data contains only characters 0 to 9.
Numeric,
/// The data contains only uppercase letters (AZ), numbers (09) and a few
/// punctuations marks (space, `$`, `%`, `*`, `+`, `-`, `.`, `/`, `:`).
Alphanumeric,
/// The data contains arbitrary binary data.
Byte,
/// The data contains Shift-JIS-encoded double-byte text.
Kanji,
}
impl Mode {
/// Computes the number of bits needed to encode the data length.
///
/// use qrcode::types::{Version, Mode};
///
/// assert_eq!(Mode::Numeric.length_bits_count(Version::Normal(1)), 10);
///
/// This method will return `Err(QrError::UnsupportedCharacterSet)` if the
/// mode is not supported in the given version.
pub fn length_bits_count(self, version: Version) -> usize {
match version {
Version::Micro(a) => {
let a = a.as_usize();
match self {
Mode::Numeric => 2 + a,
Mode::Alphanumeric | Mode::Byte => 1 + a,
Mode::Kanji => a,
}
}
Version::Normal(1..=9) => match self {
Mode::Numeric => 10,
Mode::Alphanumeric => 9,
Mode::Byte | Mode::Kanji => 8,
},
Version::Normal(10..=26) => match self {
Mode::Numeric => 12,
Mode::Alphanumeric => 11,
Mode::Byte => 16,
Mode::Kanji => 10,
},
Version::Normal(_) => match self {
Mode::Numeric => 14,
Mode::Alphanumeric => 13,
Mode::Byte => 16,
Mode::Kanji => 12,
},
}
}
/// Computes the number of bits needed to some data of a given raw length.
///
/// use qrcode::types::Mode;
///
/// assert_eq!(Mode::Numeric.data_bits_count(7), 24);
///
/// Note that in Kanji mode, the `raw_data_len` is the number of Kanjis,
/// i.e. half the total size of bytes.
pub fn data_bits_count(self, raw_data_len: usize) -> usize {
match self {
Mode::Numeric => (raw_data_len * 10 + 2) / 3,
Mode::Alphanumeric => (raw_data_len * 11 + 1) / 2,
Mode::Byte => raw_data_len * 8,
Mode::Kanji => raw_data_len * 13,
}
}
/// Find the lowest common mode which both modes are compatible with.
///
/// use qrcode::types::Mode;
///
/// let a = Mode::Numeric;
/// let b = Mode::Kanji;
/// let c = a.max(b);
/// assert!(a <= c);
/// assert!(b <= c);
///
pub fn max(self, other: Self) -> Self {
match self.partial_cmp(&other) {
Some(Ordering::Less) | Some(Ordering::Equal) => other,
Some(Ordering::Greater) => self,
None => Mode::Byte,
}
}
}
impl PartialOrd for Mode {
/// Defines a partial ordering between modes. If `a <= b`, then `b` contains
/// a superset of all characters supported by `a`.
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (*self, *other) {
(Mode::Numeric, Mode::Alphanumeric)
| (Mode::Numeric, Mode::Byte)
| (Mode::Alphanumeric, Mode::Byte)
| (Mode::Kanji, Mode::Byte) => Some(Ordering::Less),
(Mode::Alphanumeric, Mode::Numeric)
| (Mode::Byte, Mode::Numeric)
| (Mode::Byte, Mode::Alphanumeric)
| (Mode::Byte, Mode::Kanji) => Some(Ordering::Greater),
(a, b) if a == b => Some(Ordering::Equal),
_ => None,
}
}
}
#[cfg(test)]
mod mode_tests {
use crate::types::Mode::{Alphanumeric, Byte, Kanji, Numeric};
#[test]
fn test_mode_order() {
assert!(Numeric < Alphanumeric);
assert!(Byte > Kanji);
assert!(!(Numeric < Kanji));
assert!(!(Numeric >= Kanji));
}
#[test]
fn test_max() {
assert_eq!(Byte.max(Kanji), Byte);
assert_eq!(Numeric.max(Alphanumeric), Alphanumeric);
assert_eq!(Alphanumeric.max(Alphanumeric), Alphanumeric);
assert_eq!(Numeric.max(Kanji), Byte);
assert_eq!(Kanji.max(Numeric), Byte);
assert_eq!(Alphanumeric.max(Numeric), Alphanumeric);
assert_eq!(Kanji.max(Kanji), Kanji);
}
}
//}}}