Skip to content

Expose the internal SimpleMessage struct and allow creating std::io::Errors with them #205

Closed
@dead-claudia

Description

@dead-claudia

Proposal

Problem statement

I'd like a way to define lightweight custom I/O errors that don't require allocation.

Motivation, use-cases

  1. Offer a way forward for future better #![no_std] compatibility for std::io::Errors
  2. Reduce generated code size for most common custom errors
  3. Avoid needing to allocate memory for the common case with custom errors.

For some prior art and additional motivation:

Solution sketches

  1. Expose the internal SimpleMessage struct as a way to provide lightweight errors along with an impl From<&'static SimpleMessage> for Error.
  2. Expose const_io_error! to simplify construction of SimpleMessage-based errors, and default its $kind to ErrorKind::Other if not given.

Links and related work

What happens now?

This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions