Skip to main content

StaticByteBuffer

Struct StaticByteBuffer 

Source
pub struct StaticByteBuffer { /* private fields */ }
Expand description

Immutable owned byte buffer with Arc-based sharing. Send + Sync - can be safely shared across threads. Used for cryptographic keys and other immutable data.

Implementations§

Source§

impl StaticByteBuffer

Source

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

Create an owned buffer from a slice.

Source

pub fn from_array<const N: usize>(arr: &[u8; N]) -> Self

Create an owned buffer from a fixed-size array.

Source

pub fn empty(size: usize) -> Self

Create an empty owned buffer of given size (zeroed).

Trait Implementations§

Source§

impl AsRef<[u8]> for StaticByteBuffer

Source§

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

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl ByteBuffer for StaticByteBuffer

Source§

fn len(&self) -> usize

Returns the length of the current view in bytes.
Source§

fn get(&self, at: usize) -> &u8

Get byte at at index. Panics if out of bounds.
Source§

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

Get immutable slice of entire buffer.
Source§

fn slice_start(&self, start: usize) -> &[u8]

Get immutable slice from start offset to end.
Source§

fn slice_end(&self, end: usize) -> &[u8]

Get immutable slice from beginning to end offset.
Source§

fn slice_both(&self, start: usize, end: usize) -> &[u8]

Get immutable slice from start to end offset.
Source§

fn split(&self, divide: usize) -> (&[u8], &[u8])

Split into two immutable slices at divide point. Returns (left, right).
Source§

fn is_empty(&self) -> bool

Returns true if buffer length is zero.
Source§

impl Clone for StaticByteBuffer

Source§

fn clone(&self) -> StaticByteBuffer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StaticByteBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl Display for StaticByteBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl Eq for StaticByteBuffer

Source§

impl From<&StaticByteBuffer> for Vec<u8>

Source§

fn from(val: &StaticByteBuffer) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<&StaticByteBuffer> for [u8; N]

Source§

fn from(val: &StaticByteBuffer) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<&[u8; N]> for StaticByteBuffer

Source§

fn from(value: &[u8; N]) -> Self

Converts to this type from the input type.
Source§

impl From<&[u8]> for StaticByteBuffer

Source§

fn from(value: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<StaticByteBuffer> for Vec<u8>

Source§

fn from(val: StaticByteBuffer) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for StaticByteBuffer

Source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[u8; N]> for StaticByteBuffer

Source§

fn from(value: [u8; N]) -> Self

Converts to this type from the input type.
Source§

impl Hash for StaticByteBuffer

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IdentityType for StaticByteBuffer

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

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

Source§

fn length() -> usize

Source§

impl PartialEq for StaticByteBuffer

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Send for StaticByteBuffer

Source§

impl ServerConnectionHandler<StaticByteBuffer> for DefaultServerConnectionHandler

Source§

fn generate(&self, _initial_data: &[u8]) -> StaticByteBuffer

Derive a client session identity from the client’s decrypted initial data bytes.
Source§

fn initial_data(&self, _identity: &StaticByteBuffer) -> StaticByteBuffer

Produce initial data to include in the server handshake response for the given identity.
Source§

fn verify_version(&self, version_bytes: &[u8]) -> bool

Check whether the client version (from the handshake tailer ID field) is compatible. Returns true if the handshake should proceed, false if it should be rejected. Implementations are responsible for any logging before returning.
Source§

impl Sync for StaticByteBuffer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V