Skip to content

Enable derive (de)serialization of Box<str> #1336

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

Open
Sokom141 opened this issue Apr 29, 2025 · 3 comments · May be fixed by #1339
Open

Enable derive (de)serialization of Box<str> #1336

Sokom141 opened this issue Apr 29, 2025 · 3 comments · May be fixed by #1339
Assignees
Milestone

Comments

@Sokom141
Copy link

With a struct like the one in the following snippet:

struct Foo {
  field: Box<str>,
}

It is not possible to automatically derive SerializeValue and DeserializeValue but I do not see any reason way that is the case.

To me, after a very fast read of the relevant source code (Serialize, Deserialize), it seems like there is just a small code addition to support this use case.

If there is the need I would be open to implement this small change myself and open a PR. I think it would be really useful for my use case.

Thanks!

@wprzytula
Copy link
Collaborator

You're welcome to submit such PR :)

@Lorak-mmk
Copy link
Collaborator

If you do, maybe you could also cover Arc<str>? I see no reason to have support for Box, but not Arc.

@Sokom141 Sokom141 linked a pull request May 4, 2025 that will close this issue
8 tasks
@Lorak-mmk
Copy link
Collaborator

This turns out to be a bit more tricky. To sum up my comment:

  • SerializeValue should be implemented for str instead of &str.
  • SerializeValue should be implemented for Arc<T>
  • DeserializeValue should be implemented for Box<T> and Arc<T> - we need to verify that it allows using Box<str>
    The above is tightly coupled with solving Issue with type renaming in ser/deser errors. #1343

@wprzytula wprzytula added this to the 1.3.0 milestone May 8, 2025
@Lorak-mmk Lorak-mmk self-assigned this May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants