Closed dfreese closed 1 year ago
Thanks for the PR, but overall I'm inclined to reject this patch. I've left a longer explanation at https://github.com/lucab/libsystemd-rs/issues/127#issuecomment-1354424545, including a possible alternative approach.
I've updated this to remove anyhow and implement an internal Context
that implements the expected formatting. I've added a SdResult
helper as well. This is only implemented in logging. Let me know if you'd rather it be adopted throughout the library more broadly in a single PR or have other concerns.
Looks good to me, feel free to squash everything into a single commit and I'll merge it.
I'm fine to have it only applied to the logging
module for the moment, we can add the rest incrementally and new logic can already start using the context helpers.
Squashed. Thanks for reviewing.
This adds a Context trait, as well as implementations of it for Result and Optional to help consolidate the map_err(|e| format!(...)) logic that is used to provide propagate error information. This is inspired by anyhow, but returns SdError instead to keep the API surface of the library to a single struct within the library.