pub trait AsSharedBytes {
// Required method
fn as_bytes_slice(&self) -> &[u8] ⓘ;
// Provided method
fn as_shared(&self) -> Option<Bytes> { ... }
}Expand description
A value a bytes field can encode from: every ProtoBytes
representation, plus the borrowed &[u8] that view types carry.
This exists so put_shared_bytes_field can serve the duck-typed
write_to bodies codegen shares between owned messages and views. The
borrowed form has no owned handle to share (as_shared
is None); a Rope sink can still capture it zero-copy
through its backing-buffer containment check.
Required Methods§
Sourcefn as_bytes_slice(&self) -> &[u8] ⓘ
fn as_bytes_slice(&self) -> &[u8] ⓘ
The value’s bytes.
Provided Methods§
A reference-counted handle to exactly the bytes of
as_bytes_slice, when one exists.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".