Skip to content

support for defmt #505

@BurntSushi

Description

@BurntSushi

Specifically, defmt helps with formatting values in embedded scenarios where core::fmt doesn't work as well. My understanding of the underlying value proposition is that it provides "deferred" formatting. That it, there is some wire protocol where an efficient representation of values is transferred to the host machine and it's the host machine that does the actual formatting.

This was brought up in #168:

I spent a couple of hours working on this today. At this point, defmt works with all public-facing structs and enums in jiff. However, it does not currently work when either the std feature or the alloc feature is enabled. (This is because defmt only implements on Format trait on alloc::core::Box<T> where T is Sized)

There is some value in making defmt compatible with alloc, but the lack of support should not be a blocker for now as most embedded devices do not have an allocator.

One important caveat: Supporting defmt comes with the trade-off that, if you ever want to take on a third-party dependancy for jiff, you will need to the upstream dependency to support defmt, or will need to create wrapper structs. I do see that you depend on very few third party dependencies, so this may not be an issue.

I’m still verifying that we don’t rely on core::fmt anywhere. The entire value proposition of defmt is to reduce compile-time code size and defer formatting until logs are rendered on a debugger. If any part of the code still uses core::fmt at runtime, that benefit is lost, and we are wasting out time.


btw, thanks for getting back to me so quickly, I cannot say how refreshing that is.
Thank you so much for this library!

Originally posted by @dickermoshe in #168

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions