Trait U8Array

Source
pub trait U8Array: Sized {
    // Required methods
    fn new() -> Self;
    fn new_with(_: u8) -> Self;
    fn from_slice(_: &[u8]) -> Self;
    fn len() -> usize;
    fn as_slice(&self) -> &[u8] ;
    fn as_mut(&mut self) -> &mut [u8] ;

    // Provided method
    fn clone(&self) -> Self { ... }
}
Expand description

A trait for fixed size u8 array.

Required Methods§

Source

fn new() -> Self

Create a new array filled with all zeros.

Source

fn new_with(_: u8) -> Self

Create a new array filled with a same value.

Source

fn from_slice(_: &[u8]) -> Self

Create a new array from a slice.

§Panics

The slice must be of the same length.

Source

fn len() -> usize

Length of the array.

Source

fn as_slice(&self) -> &[u8]

As slice.

Source

fn as_mut(&mut self) -> &mut [u8]

As mutable slice.

Provided Methods§

Source

fn clone(&self) -> Self

Clone.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl U8Array for [u8; 32]

Source§

fn new() -> Self

Source§

fn new_with(x: u8) -> Self

Source§

fn from_slice(data: &[u8]) -> Self

Source§

fn len() -> usize

Source§

fn as_slice(&self) -> &[u8]

Source§

fn as_mut(&mut self) -> &mut [u8]

Source§

impl U8Array for [u8; 64]

Source§

fn new() -> Self

Source§

fn new_with(x: u8) -> Self

Source§

fn from_slice(data: &[u8]) -> Self

Source§

fn len() -> usize

Source§

fn as_slice(&self) -> &[u8]

Source§

fn as_mut(&mut self) -> &mut [u8]

Source§

impl U8Array for [u8; 128]

Source§

fn new() -> Self

Source§

fn new_with(x: u8) -> Self

Source§

fn from_slice(data: &[u8]) -> Self

Source§

fn len() -> usize

Source§

fn as_slice(&self) -> &[u8]

Source§

fn as_mut(&mut self) -> &mut [u8]

Implementors§