New to gtk and rust and trying to experiment with crate canrust

I have installed git, gtk3-rs, and “visual studio code” as an working environment, and had some success in building on the examples. I installed crate “canrust” to play with a canvas and when I tried to set-up a provided example the file “mod.rs” compilation generated the below result:

> Executing task: cargo run --package gtk-rs-examples --bin canvastests <

   Compiling canrust v1.3.3
error[E0412]: cannot find type `NoneError` in module `std::option`
   --> /home/greg/.cargo/registry/src/github.com-1ecc6299db9ec823/canrust-1.3.3/src/utils/mod.rs:169:28
    |
169 |     NoneError(std::option::NoneError),
    |                            ^^^^^^^^^ not found in `std::option`
    |
help: there is an enum variant `crate::utils::Error::NoneError`; try using the variant's enum
    |
169 |     NoneError(crate::utils::Error),
    |               ~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `NoneError` in module `std::option`
   --> /home/greg/.cargo/registry/src/github.com-1ecc6299db9ec823/canrust-1.3.3/src/utils/mod.rs:190:24
    |
190 | impl From<std::option::NoneError> for Error {
    |                        ^^^^^^^^^ not found in `std::option`
    |
help: there is an enum variant `crate::utils::Error::NoneError`; try using the variant's enum
    |
190 | impl From<crate::utils::Error> for Error {
    |           ~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `NoneError` in module `std::option`
   --> /home/greg/.cargo/registry/src/github.com-1ecc6299db9ec823/canrust-1.3.3/src/utils/mod.rs:191:33
    |
191 |     fn from(error: std::option::NoneError) -> Self {
    |                                 ^^^^^^^^^ not found in `std::option`
    |
help: there is an enum variant `crate::utils::Error::NoneError`; try using the variant's enum
    |
191 |     fn from(error: crate::utils::Error) -> Self {
    |                    ~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0412`.
error: could not compile `canrust` due to 3 previous errors
The terminal process "cargo 'run', '--package', 'gtk-rs-examples', '--bin', 'canvastests'" terminated with exit code: 101.

this is “Main.rs”

use canrust::canvas::{Canvas, Color}; 
use crate::utils::Error


fn main() { // Create a canvas:
    // size, name, background color
    let mut canvas = Canvas::new((800, 600), "Canvas", Color::WHITE);
     
    // create shapes:
    canvas.create_circle((1., 1.), 20., Color::BLACK, None, None);
    canvas.create_rectangle((20., 20.), (30., 80.), Color::BLACK, None, None);
    canvas.create_line((18., 20.), (18., 80.), 2., Color::RED, None, None);
    canvas.create_line((32., 20.), (32. 80.), 2., Color::RED, None, None);
     
    // call mainloop, objects will be rendered as long as the program is running
    canvas.mainloop()
}

could someone tell me what I am doing wrong??

Thanks in advance

That’s a bug in canrust and you best report it here. It’s using nightly-only API that does not even exist anymore nowadays (std::option::NoneError).

It also doesn’t look like canrust is very active. You might want to look at gtk::DrawingArea and cairo for some kind of drawing API.

Thank You sdoege

I will try your suggestions

Greg

Continuing the discussion from New to gtk and rust and trying to experiment with crate canrust:

Hi again; I am originally trained in the ancient languages (assembler for 386 and IBM 1680, or fortran) and I am having difficulties with the refinements of rust and gtk - A lot of what happens is hidden in the background.

I want to insert a .png into DrawingArea and my efforts leave me bewildered. My example:-

drawable(application, 1800, 1000, |_, cr| {
cr.set_source_rgb(200.0 / 255.0, 200.0 / 255.0, 200.0 / 255.0); //pleasant grey
cr.scale(100f64, 100f64);//starting scale

Pixbuf::from_file("/home/greg/terminals/normalterm.png");//.png file to test

cr.set_source_pixbuf(Pixbuf, 0f64, 0f64);// picture and location??

error: expected value , found struct ‘Pixbuf’ // how then do I specify the .png - this reports as “result”

I have tried setting let term = Pixbuf::from…, and putting term in cr.set… in place of Pixbuf, and lots of suggestions made by VSC rust analyser as well, and the rustbook has shed no light for me. Can someone assist with an understandable explanation of what I do wrong.

Greg

PS I have successfully built what I want in “Iconview” using a similar format

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.