Skip to content

Can Bytes be combined with FromInto? #557

Answered by jonasbb
Theodus asked this question in Q&A
Discussion options

You must be logged in to vote

I am unsure what you actually want to achieve. It would help if you could extend your code snippet to a fully runnable example. Using FromInto like you suggest won't work, since Bytes itself cannot be serialized. It does not implement Serialize or Deserialize, which is required for FromInto.

From your snippet it seems what you want to have is this.

#[serde_as]
#[derive(Clone, Debug, serde::Deserialize)]
struct Test {
    #[serde_as(as = "FromInto<[u8; 5]>")]
    bytes: Wrapper,
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Theodus
Comment options

@jonasbb
Comment options

@Theodus
Comment options

Answer selected by Theodus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants