Skip to content

Shouldn't socket recv() promise in its doc allows a nicer API #501

Closed
@keepsimple1

Description

@keepsimple1

socket2/src/socket.rs

Lines 409 to 414 in c93cdcc

/// Normally casting a `&mut [u8]` to `&mut [MaybeUninit<u8>]` would be
/// unsound, as that allows us to write uninitialised bytes to the buffer.
/// However this implementation promises to not write uninitialised bytes to
/// the `buf`fer and passes it directly to `recv(2)` system call. This
/// promise ensures that this function can be called using a `buf`fer of
/// type `&mut [u8]`.

A friendly question: because of the above promise, is it true that this API could change its signature to accept buf: &mut [u8] ? That will be so much helpful! (The current API is useless for many code bases where unsafe is not allowed / or strongly discouraged).

(I noticed open issues like #366 , but it seems being there more than 1 year, when will it happen?) I'm a user of this crate and I think this current signature is really unnecessary hurdle for its users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions