Skip to main content

ProtoEncoder

Struct ProtoEncoder 

Source
pub struct ProtoEncoder<I, A, M> { /* private fields */ }
Expand description

The encoder of messages

Implementations§

Source§

impl<I, A, B> ProtoEncoder<I, A, B>
where I: Data + 'static, A: Data + 'static, B: AsRef<[Message<I, A>]> + Send + Sync + 'static,

Source

pub async fn blocking_encode<RT>( self, ) -> impl Iterator<Item = Result<Payload, ProtoEncoderError>> + 'static
where RT: RuntimeLite,

Encodes the messages.

Source§

impl<I, A, B> ProtoEncoder<I, A, B>
where I: Data, A: Data, B: AsRef<[Message<I, A>]> + Send + Sync,

Source

pub fn rayon_encode( &self, ) -> impl ParallelIterator<Item = Result<Payload, ProtoEncoderError>> + Debug

Encodes the messages.

Source§

impl<I, A> ProtoEncoder<I, A, &'static [u8]>

Source

pub const fn new(max_payload_size: usize) -> ProtoEncoder<I, A, &'static [u8]>

Creates a new messages encoder.

Source§

impl<I, A, M> ProtoEncoder<I, A, M>

Source

pub fn into_messages(self) -> M

Consumes the encoder and returns the messages.

Source

pub fn messages(&self) -> &M

Returns the messages in the encoder.

Source

pub fn with_overhead(self, overhead: usize) -> ProtoEncoder<I, A, M>

Feeds the overhead for this encoder.

Source

pub fn overhead(&self) -> usize

Returns the overhead of the encoder.

Source

pub fn with_messages<NB>(self, msgs: NB) -> ProtoEncoder<I, A, NB>
where I: Data, A: Data, NB: AsRef<[Message<I, A>]>,

Feeds the encoder with messages.

Source§

impl<I, A, M> ProtoEncoder<I, A, M>

Source

pub fn with_label(self, label: Label) -> ProtoEncoder<I, A, M>

Feeds the encoder with a label.

Source

pub const fn with_checksum( self, checksum: ChecksumAlgorithm, ) -> ProtoEncoder<I, A, M>

Available on crate features crc32 or murmur3 or xxhash32 or xxhash3 or xxhash64 only.

Feeds the encoder with a checksum algorithm.

Source

pub const fn maybe_checksum( &mut self, checksum: Option<ChecksumAlgorithm>, ) -> &mut ProtoEncoder<I, A, M>

Available on crate features crc32 or murmur3 or xxhash32 or xxhash3 or xxhash64 only.

Feeds or clear the checksum related settings for the encoder.

Source

pub const fn without_checksum(self) -> ProtoEncoder<I, A, M>

Available on crate features crc32 or murmur3 or xxhash32 or xxhash3 or xxhash64 only.

Clears the checksum related settings.

Source

pub const fn with_compression( self, compress: CompressAlgorithm, ) -> ProtoEncoder<I, A, M>

Available on crate features brotli or lz4 or snappy or zstd only.

Feeds the encoder with a compression algorithm.

Source

pub const fn maybe_compression( &mut self, compress: Option<CompressAlgorithm>, ) -> &mut ProtoEncoder<I, A, M>

Available on crate features brotli or lz4 or snappy or zstd only.

Feeds or clear the compression related settings for the encoder.

Source

pub const fn without_compression(self) -> ProtoEncoder<I, A, M>

Available on crate features brotli or lz4 or snappy or zstd only.

Clears the compression related settings.

Source

pub const fn with_compression_threshold( self, compression_threshold: usize, ) -> ProtoEncoder<I, A, M>

Available on crate features brotli or lz4 or snappy or zstd only.

Feeds the encoder with a minimum compression size.

If the payload size is less than this value, the encoder will not compress the payload.

Default is 512 bytes. The minimum value is 32 bytes.

Source

pub const fn with_encryption( self, algo: EncryptionAlgorithm, key: SecretKey, ) -> ProtoEncoder<I, A, M>

Available on crate feature encryption only.

Feeds the encoder with an encryption algorithm.

Source

pub const fn set_encryption( &mut self, algo: EncryptionAlgorithm, key: SecretKey, ) -> &mut ProtoEncoder<I, A, M>

Available on crate feature encryption only.

Feeds the encoder with an encryption algorithm.

Source

pub const fn maybe_encryption( self, encrypt: Option<(EncryptionAlgorithm, SecretKey)>, ) -> ProtoEncoder<I, A, M>

Available on crate feature encryption only.

Feeds or clear the encryption related settings for the encoder.

Source

pub const fn without_encryption(self) -> ProtoEncoder<I, A, M>

Available on crate feature encryption only.

Clears the encryption related settings.

Source§

impl<I, A, M> ProtoEncoder<I, A, M>
where I: Data, A: Data, M: AsRef<[Message<I, A>]>,

Source

pub fn hint(&self) -> Result<ProtoHint, ProtoEncoderError>

Returns the hint of how the encoder should process the messages.

Source

pub fn hint_with_size( &self, input_size: usize, ) -> Result<ProtoHint, ProtoEncoderError>

Returns the hint of how the encoder should process the input size data.

Source

pub fn encode( &self, ) -> impl Iterator<Item = Result<Payload, ProtoEncoderError>> + Debug

Encodes the messages.

Auto Trait Implementations§

§

impl<I, A, M> Freeze for ProtoEncoder<I, A, M>
where M: Freeze,

§

impl<I, A, M> RefUnwindSafe for ProtoEncoder<I, A, M>

§

impl<I, A, M> Send for ProtoEncoder<I, A, M>
where M: Send, I: Send, A: Send,

§

impl<I, A, M> Sync for ProtoEncoder<I, A, M>
where M: Sync, I: Sync, A: Sync,

§

impl<I, A, M> Unpin for ProtoEncoder<I, A, M>
where M: Unpin, I: Unpin, A: Unpin,

§

impl<I, A, M> UnsafeUnpin for ProtoEncoder<I, A, M>
where M: UnsafeUnpin,

§

impl<I, A, M> UnwindSafe for ProtoEncoder<I, A, M>
where M: UnwindSafe, I: UnwindSafe, A: UnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more