pub trait ChunkedUtf8Validator {
unsafe fn new() -> Self
where
Self: Sized;
unsafe fn update_from_chunks(&mut self, input: &[u8]);
unsafe fn finalize(
self,
remaining_input: Option<&[u8]>
) -> Result<(), Utf8Error>;
}
Expand description
Like Utf8Validator
this low-level API is for streaming validation of UTF-8 data.
It has additional restrictions imposed on how the input is passed in to allow
validation with as little overhead as possible.
To feed it data you need to call the Self::update_from_chunks()
method which takes slices which
have to be a multiple of 64 bytes long. The method will panic otherwise. There is
no way to find out if the input so far was valid UTF-8 during the validation. Only when
the validation is completed with the Self::finalize()
method the result of the validation is
returned.
The Self::finalize()
method can be fed the rest of the data. There is no restriction on the
data passed to it.
This implementation requires CPU SIMD features specified by the module it resides in.
It is undefined behavior to use it if the required CPU features are not available which
is why all trait methods are unsafe
.
Required methods
Creates a new validator.
Safety
This implementation requires CPU SIMD features specified by the module it resides in. It is undefined behavior to call it if the required CPU features are not available.
unsafe fn update_from_chunks(&mut self, input: &[u8])
unsafe fn update_from_chunks(&mut self, input: &[u8])
Updates the validator with remaining input if any. There is no restriction on the data provided.
Finishes the validation and returns Ok(())
if the input was valid UTF-8.
Errors
A basic::Utf8Error
is returned if the input was not valid UTF-8. No
further information about the location of the error is provided.
Safety
This implementation requires CPU SIMD features specified by the module it resides in. It is undefined behavior to call it if the required CPU features are not available.