3Hren / 3Hren/msgpack-rust

`serialize_i64` not writing an int64 msgpack type when value fits into something smaller

Open
#326 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.4k
Forks
162
PR merge metrics
No merged PRs in 30d

Description

I am trying to use `[serde(serialize_with = "myfunc")]` to serialize a `std::time::Duration` type, where `myfunc` is defined as:

```
fn myfunc(duration: &std::time::Duration, serializer: S) -> Result
where
S: Serializer,
{
serializer.serialize_i64(duration.as_millis() as i64)
}
```

When I attempt to serialize the struct with a Duration value of 256 using `to_vec_named()`, the serialized msgpack contains [cd, 1, 0] for the value.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.