Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR of URI #36

Closed
hasanAjsf opened this issue Sep 27, 2019 · 1 comment
Closed

QR of URI #36

hasanAjsf opened this issue Sep 27, 2019 · 1 comment

Comments

@hasanAjsf
Copy link

I wanted to make a QR for a file shared in Google drive, it gave me the below error:

C:\Users\hasan.DESKTOP-HU2FQ29\IdeaProjects\QR>cargo run
   Compiling QR v0.1.0 (C:\Users\hasan.DESKTOP-HU2FQ29\IdeaProjects\QR)
error[E0432]: unresolved import `image`
 --> src\main.rs:2:5
  |
2 | use image::Luma;
  |     ^^^^^ help: a similar path exists: `qrcode::image`

error[E0277]: arrays only have std trait implementations for lengths 0..=32
  --> src\main.rs:6:28
   |
6  |     let code = QrCode::new(b"https://drive.google.com/file/d/1K1AWqKrC4ZOgw7I0ToqbTz_b6-Leq4F2/view").unwrap();
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[u8; 70]`
   | 
  ::: C:\Users\hasan.DESKTOP-HU2FQ29\.cargo\registry\src\github.com-1ecc6299db9ec823\qrcode-0.11.0\src\lib.rs:86:19
   |
86 |     pub fn new<D: AsRef<[u8]>>(data: D) -> QrResult<Self> {
   |                   ----------- required by this bound in `qrcode::QrCode::new`
   |
   = note: required because of the requirements on the impl of `std::convert::AsRef<[u8]>` for `[u8; 70]`
   = note: required because of the requirements on the impl of `std::convert::AsRef<[u8]>` for `&[u8; 70]`

my code is simply:

use qrcode::QrCode;
use image::Luma;

fn main() {
    // Encode some data into bits.
    let code = QrCode::new(b"https://drive.google.com/file/d/1K1AWqKrC4ZOgw7I0ToqbTz_b6-Leq4F2/view").unwrap();

    // Render the bits into an image.
    let image = code.render::<Luma<u8>>().build();

    // Save the image.
    image.save("/tmp/qrcode.png").unwrap();
}
@kennytm
Copy link
Owner

kennytm commented Sep 28, 2019

Duplicate of #17. Use this:

QrCode::new(&b"https://drive.google.com/file/d/1K1AWqKrC4ZOgw7I0ToqbTz_b6-Leq4F2/view"[..])

@kennytm kennytm closed this as completed Sep 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants