Skip to content

use embedded_hal::digital::ErrorKind for mocked digital pins #129

@2bndy5

Description

@2bndy5

I find it weird that eh1::MockError only has an Io variant for an std::io::ErrorKind. Because most embedded rust cannot use std::io in production code, the tested scenario is unlikely to ever occur. IMHO, it would make more sense to allow eh1::digital::Transaction::with_error() to accept embedded_hal::digital::ErrorKind parameter type. This should be especially useful for measuring coverage of an embedded driver lib that wraps embedded_hal::*::ErrorKind into a custom Error type.

Would it be feasible to let eh1::digital::Transaction::with_error() accept embedded_hal::digital::ErrorKind parameter type?

Caution

This would break backward compatibility downstream because MockError is a different type. Adding more variants to the MockError enum wouldn't cover code that (for example)

use embedded_hal::digital::ErrorKind as OutputPinError;

impl From<OutputPinError> for CustomError<OutputPinError> {
    fn from(value: OutputPinError) -> Self {
        CustomError::DigitalOutError(value)
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions