pub struct CrousBytes(pub Vec<u8>);Expand description
Newtype wrapper for Vec<u8> that serializes as Value::Bytes (binary blob).
Use this instead of Vec<u8> when you want the raw-bytes wire encoding.
Plain Vec<u8> encodes as an array of unsigned integers via the generic
Vec<T: Crous> impl.
§Example
use crous_core::{Crous, CrousBytes, Value};
let blob = CrousBytes(vec![0xDE, 0xAD, 0xBE, 0xEF]);
assert!(matches!(blob.to_crous_value(), Value::Bytes(_)));
let arr: Vec<u8> = vec![1, 2, 3];
// Vec<u8> uses the generic Vec<T> impl → Array of UInts
assert!(matches!(arr.to_crous_value(), Value::Array(_)));Tuple Fields§
§0: Vec<u8>Implementations§
Trait Implementations§
Source§impl AsRef<[u8]> for CrousBytes
impl AsRef<[u8]> for CrousBytes
Source§impl Clone for CrousBytes
impl Clone for CrousBytes
Source§fn clone(&self) -> CrousBytes
fn clone(&self) -> CrousBytes
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Crous for CrousBytes
impl Crous for CrousBytes
Source§fn to_crous_value(&self) -> Value
fn to_crous_value(&self) -> Value
Convert this value to an owned
Value for encoding.Source§fn from_crous_value(value: &Value) -> Result<Self>
fn from_crous_value(value: &Value) -> Result<Self>
Construct this type from a decoded
Value.Source§fn schema_fingerprint() -> u64
fn schema_fingerprint() -> u64
A stable fingerprint (XXH64) of this type’s schema.
Used for schema-on-write validation.
Source§fn to_crous_bytes(&self) -> Result<Vec<u8>>
fn to_crous_bytes(&self) -> Result<Vec<u8>>
Encode this value directly to Crous binary bytes. Read more
Source§fn from_crous_bytes(data: &[u8]) -> Result<Self>
fn from_crous_bytes(data: &[u8]) -> Result<Self>
Decode from Crous binary bytes using default limits.
Source§impl Debug for CrousBytes
impl Debug for CrousBytes
Source§impl From<CrousBytes> for Vec<u8>
impl From<CrousBytes> for Vec<u8>
Source§fn from(b: CrousBytes) -> Self
fn from(b: CrousBytes) -> Self
Converts to this type from the input type.
Source§impl Hash for CrousBytes
impl Hash for CrousBytes
Source§impl PartialEq for CrousBytes
impl PartialEq for CrousBytes
impl Eq for CrousBytes
impl StructuralPartialEq for CrousBytes
Auto Trait Implementations§
impl Freeze for CrousBytes
impl RefUnwindSafe for CrousBytes
impl Send for CrousBytes
impl Sync for CrousBytes
impl Unpin for CrousBytes
impl UnsafeUnpin for CrousBytes
impl UnwindSafe for CrousBytes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more