Skip to content

Cancellation safety of Read::read and Write::write in embedded-io-async #719

@ivmarkov

Description

@ivmarkov

The current documentation of the read and write methods in e-hal async leaves the cancellation safety explicitly down to implementors:

I wonder whether "encouraged" and "leave it down to implementers to document" is good enough though?
Tokio - in contrast - is pretty explicit about that:

I wonder whether we actually need two pairs of traits instead? I.e. for Read:

  • ReadNonCancelSafe (let's leave the name bike-shedding as well as whether the non-cancel safe or the cancel-safe variant shall be named Read for later, shall we?) - with the current Read semantics and the "encouragement" paragraph replaced with an explicit "read is NOT cancel safe"
  • Read - with an enforced cancellation-safe semantics, just like AsyncReadExt from tokio?

This way, implementations users that do care about cancellation safety would demand Read.
Those that don't might require the weaker ReadNonCancelSafe.

(This all in the context of stabilizing embedded-io-async.)

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