google / google/zerocopy

Support creating a `Ref` of a type that implements `TryFromBytes`

Open
#1,865 5 comments 1 reaction 1 assignee Claimed by @jswrenn View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
179
Avg merge
1d 19h
Merged PRs (30d)
29

Description

Support fallible constructors on `Ref` for types that implement `TryFromBytes`

For example, would like to be able to do something like the following:

```rust
#[derive(TryFromBytes)]
#[repr(u8)]
enum MyEnum {
V0 = 0,
V1 = 1,
}

let (enum_ref, remainder) = Ref::::try_from_prefix(bytes)?;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.