Skip to content

Add Equatable Conformance to McuMgrTransportError #32

Open
@nathanblamires

Description

@nathanblamires

It would be good to make McuMgrTransportError conform to equatable, so developers can easily test if certain errors are occurring and act accordingly. We added an extension in our app to do this, but others may have the same need so it would be good if it was apart of the standard framework. See code below.

extension McuMgrTransportError: Equatable {

    public static func == (lhs: McuMgrTransportError, rhs: McuMgrTransportError) -> Bool {
        switch (lhs, rhs) {
        case (.connectionTimeout, .connectionTimeout): return true
        case (.connectionFailed, .connectionFailed): return true
        case (.disconnected, .disconnected): return true
        case (.sendTimeout, .sendTimeout): return true
        case (.sendFailed, .sendFailed): return true
        case let (.insufficientMtu(lhsMTU), .insufficientMtu(rhsMTU)): return lhsMTU == rhsMTU
        case (.badResponse, .badResponse): return true
        default: return false
        }
    }
}

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