Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallible serialization #1544

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

fallible serialization #1544

wants to merge 8 commits into from

Conversation

milyin
Copy link
Contributor

@milyin milyin commented Oct 17, 2024

  • z_try_serialize function added
  • trait TrySerialize added. The trait Serialize remains for infallible serialization
    • For basic types and containers which allows infallible serialization this trait is implemeted as TrySerialize<Error = Infallible>
    • The Serialize trait is implemeted automatically for all types which implements TrySerialize<Error = Infallible>
    • It's possible to implement Serialize explicitly for types which already implements TrySerialize<Error = ZSerializeError> or any other error. This is necessary for e.g. HashMap
  • fallible serialization of CString added: in demonstration purpose and may be for future use in zenoh-c

Copy link

PR missing one of the required labels: {'internal', 'documentation', 'new feature', 'bug', 'enhancement', 'breaking-change', 'dependencies'}

@milyin milyin requested a review from wyfo October 17, 2024 14:11
Copy link

PR missing one of the required labels: {'bug', 'dependencies', 'new feature', 'documentation', 'breaking-change', 'enhancement', 'internal'}

@milyin milyin added enhancement Existing things could work better new feature Something new is needed labels Oct 17, 2024
@milyin milyin requested a review from Mallets October 17, 2024 14:14
@@ -33,18 +35,58 @@ impl fmt::Display for ZDeserializeError {
}
impl std::error::Error for ZDeserializeError {}

fn default_serialize_n<T: Serialize>(slice: &[T], serializer: &mut ZSerializer) {
#[derive(Debug)]
pub struct ZSerializeError(String);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using a ZST as it is the case for deserialization?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a Box<dyn Error + Send + Sync>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a ZST ? About Box - yes, agree, fixing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it ZST for now

/// See [Zenoh serialization format RFC][1].
///
/// [1]: https://github.com/eclipse-zenoh/roadmap/blob/main/rfcs/ALL/Serialization.md#sequences
pub fn try_serialize_iter<T: TrySerialize, I: IntoIterator<Item = T>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no try_serialize method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@milyin milyin marked this pull request as draft October 17, 2024 16:39
@Mallets
Copy link
Member

Mallets commented Nov 29, 2024

@milyin At the end we decided to not include this PR in 1.0.0.
Therefore I believe it can be safely closed as no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Existing things could work better new feature Something new is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants