Skip to content

fix: Socket2 RAW socket Type compile error out of scope E0599#1

Open
blisabda wants to merge 1 commit into
edejong-dbc:masterfrom
blisabda:fix-cargo
Open

fix: Socket2 RAW socket Type compile error out of scope E0599#1
blisabda wants to merge 1 commit into
edejong-dbc:masterfrom
blisabda:fix-cargo

Conversation

@blisabda

Copy link
Copy Markdown
  • Socket2 RAW socket Type need all features enabled

- Socket2 RAW socket Type need all features enabled
@blisabda

Copy link
Copy Markdown
Author

Rust compiler detecting 2 error E0599 with socket2::Type::RAW struct usage.

error[E0599]: no associated item named `RAW` found for struct `socket2::Type` in the current scope
   --> src/session.rs:135:59
    |
135 |         let send_socket = Socket::new(Domain::IPV4, Type::RAW, Some(Protocol::ICMPV4))?;
    |                                                           ^^^ associated item not found in `socket2::Type`

error[E0599]: no associated item named `RAW` found for struct `socket2::Type` in the current scope
   --> src/session.rs:138:59
    |
138 |         let recv_socket = Socket::new(Domain::IPV4, Type::RAW, Some(Protocol::ICMPV4))?;
    |                                                           ^^^ associated item not found in `socket2::Type`

To resolve the E0599 errors when using socket2::Type::RAW, we must enable all1 feature in the Cargo.toml since the RAW socket type is not included in the default build.

Reference:

    /// Type corresponding to `SOCK_RAW`.
    #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))]
    #[cfg_attr(
        docsrs,
        doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf")))))
    )]
    pub const RAW: Type = Type(sys::SOCK_RAW);

Footnotes

  1. https://github.com/rust-lang/socket2/blob/v0.5.x/src/lib.rs#L277-L283

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

Successfully merging this pull request may close these issues.

1 participant