Skip to content

Add CResult to extra types crate #63

@fredszaq

Description

@fredszaq

OK/KO type to be used as return type of extern(C) functions

Adding this should be a great opportunity to add some doc on a good pattern for error handling on a C API. (ie if the result was KO, then call a last_error function to get the actual error)

  • type definition
  • wrap function that takes a FnOnce returning a Resutl and returns OK or KO (and set last error in that case)
  • last_error function to get the last error, that should be exposed in the FFI by the user of the crate
  • document how to rename the struct in cbindgen. CResult makes a lot of sense in rust but not in C

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions