Why can the compiler not find documented function in ioctls crate?

Viewed 54

I'm trying to use the functions of the ioctls crate. I added it to the Cargo.toml:

[dependencies]
ioctls = "0.6.1"

And I'm calling like this:

ioctls::spi_ioc_wr_max_speed_hz(fd, &speed);

but I get

error[E0425]: cannot find function `spi_ioc_wr_max_speed_hz` in crate `ioctls`
   --> src/w25q.rs:127:17
    |
127 |         ioctls::spi_ioc_wr_max_speed_hz(fd, &speed);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^ not found in `ioctls`

The function exists and is pub: https://docs.rs/ioctls/0.6.1/ioctls/fn.spi_ioc_wr_max_speed_hz.html

1 Answers

The documentation you see on docs.rs is built with a target toolchain and feature set in mind, usually the most common and/or extensive. And for most crates it doesn't matter, but for lower level utilities it can be misleading. You can change the target platform in the top bar (if generated by the crate author).

Many of the ioctls functions are only available for the x86_64 architecture. You can see the docs for the i686 architecture here to see more what you'd expect on ARM. I don't know enough about ioctls to advise a solution or workaround for this missing function.

In the future, if you'd like to see the exact docs to expect, generate and view them locally (with target architecture if not already set):

cargo doc --target armv7-unknown-linux-gnueabihf --open
Related