Skip to content

Add (optional) support for typesize #520

@inklesspen

Description

@inklesspen

typesize offers a trait to calculate the total memory size used by a type (including heap allocations). This can be important for caches; PaperCache uses typesize to determine how much memory a particular key or value uses; the Discord library serenity can optionally use it to track the size of its cached data, and so on.

While typesize includes optional implementations for some external libraries like arrayvec or url, it's currently impossible to fully implement TypeSize support for jiff from outside the jiff crate, because of how TimeZone pointers work.

I "implemented" support for most of jiff's core types in GnomedDev/typesize#10 (because for a wholly stack-based type the implementation can use default methods):

impl TypeSize for jiff::SignedDuration {}
impl TypeSize for jiff::Timestamp {}
// etc

However, the typesize dev would prefer to have the support be implemented in the jiff crate (which I can understand, since that will make it easier to keep up to date). And of course if we're going to have an implementation at all, it would be nice to support TimeZone.

If you're willing to accept a PR for this, I'd be happy to draft one.

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