-
Notifications
You must be signed in to change notification settings - Fork 99
Conversation
Whoops, it seems like the |
The |
I am currently rewriting the value module. I think about always serialize values in canonical form. So this can be resolved later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
the methods Serializer::new, Serializer::packed and Serializer::new_with_options now take a writer that implements the local Write trait instead of std::io::Write. An std::io::Write now needs to be wrapped in an IoWrite to be passed to any of these functions. In most cases this should not be a problem, as the types for serde_cbor::to_vec and serde_cbor::to_writer still take std::io::Write.
Is it possible that they take Into<Write>
and io::Write
is convert by the called function?
src/error.rs
Outdated
where | ||
T: fmt::Display, | ||
{ | ||
// TODO propagate at least something |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should be done here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now we just set the code to ErrorCode::Custom
without any extra data on what caused the error. Ideally I would like to propagate the error message here, but that would only be possible if we could Box up the message. The next best thing would be to propagate part of the error, but I have no good ideas for how to do that at the moment.
src/error.rs
Outdated
where | ||
T: fmt::Display, | ||
{ | ||
// TODO propagate at least something |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
Btw can you please test no-std on Travis CI? |
I have tried to get it to work with |
Sure, I will add some tests for no-std mode. |
Didn't think about this. We can merge the PR as it is now. |
Great! I actually have a fix for serialization in a local branch we might also want to incorporate before merging? I should have time on Tuesday to push those changes and implement a few tests for no_std |
Ok.
wildarch <[email protected]> schrieb am So., 10. März 2019, 21:09:
… Great! I actually have a fix for serialization in a local branch we might
also want to incorporate before merging? I should have time on Tuesday to
push those changes and implement a few tests for no_std
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#96 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACpvWdh72vWjMSdItcpqiSFWpWelkVsqks5vVWZpgaJpZM4bT96I>
.
|
There are no tests for no_std mode yet.
Serialization and is now working on I think this should be fine to merge now 👍 |
Thanks a bunch for finishing this. I just tried to port my application over, which means that windowed_infinity will implement the unsealed Write trait -- but so far I failed with the next-release version as the Write trait only lives in the private write module. Did I miss a mechanism here, or is Write still actually sealed? If I did not miss any way of implementing Write as it is, that'd mean that the original way of sealing Read was superfluous (as users already can't implement the trait if you cant' name it), and the unsealing might become as easy as having a conditional |
My bad: the Write trait is exposed as |
@chrysn happy to help 😄. The |
If there were no reason to expose them then it might work, but seeing how it is exposed now (and can be used) leads me to think that it does make sense to implement the trait, if only to allow others to have their interfaces generic over it – so sealing probably needs to stay in some form (though I have #98 as a proposal for how it can stay in a way that works better with versioning). |
Resolves #79.
This builds on the efforts of @chrysn to implement
no_std
support. It also introduces a few things I needed when developing an embedded application based on this crate.Notable changes
std
feature that can be disabled forno_std
supportWrite
trait similar to the existingRead
, asstd::io::Write
is not available in core.SliceReadFixed
, similar toSliceRead
but using a mutable slice as a scratch buffer. This is useful inno_std
environments when the input slice is immutable (soMutSliceRead
is off the table).unsealed_read_write
(disabled by default) becomes available, which unseals theRead
andWrite
trait. This is useful inno_std
to implementRead
on a customFile
type.Public API Changes
the methods
Serializer::new
,Serializer::packed
andSerializer::new_with_options
now take a writer that implements the localWrite
trait instead ofstd::io::Write
. Anstd::io::Write
now needs to be wrapped in anIoWrite
to be passed to any of these functions. In most cases this should not be a problem, as the types forserde_cbor::to_vec
andserde_cbor::to_writer
still takestd::io::Write
.One possible alternative would be to make
new, packed, new_with_options
still takestd::io::Write
and add similar methods forWrite
.Papercuts
no_std
mode, deserialiation and serialiation errors are mapped to a generic error that removes all context.Read
andWrite
traits are duplicated for theunsealed_read_write
feature, this is not very DRY.