pub struct JsonValidator { /* private fields */ }Expand description
JSON validator with configurable constraints.
Handles incremental/streaming validation of JSON payloads and maintains internal state between chunk validations.
Instances should be created using JsonValidatorBuilder.
Implementations§
Source§impl JsonValidator
impl JsonValidator
Sourcepub fn validate_chunk(
&mut self,
chunk: &[u8],
end_of_stream: bool,
) -> Result<ValidationResult, ValidationError>
pub fn validate_chunk( &mut self, chunk: &[u8], end_of_stream: bool, ) -> Result<ValidationResult, ValidationError>
Validates a JSON chunk incrementally
This method can be called multiple times with different chunks of the same JSON. The validator maintains internal state to handle incremental validation and UTF-8 boundaries.
§Arguments
chunk- Bytes chunk to validate. Can be a fragment of the complete JSON.end_of_stream-trueif this is the last chunk of the stream,falseif there are more chunks pending.
§Returns
Ok(ValidationResult::Incomplete)- The chunk is valid but the JSON is incomplete.validate_chunk()should be called again with the next chunk.Ok(ValidationResult::Complete)- The JSON is complete and valid (only whenend_of_stream = true).Err(ValidationError)- Validation error (invalid JSON or constraint violation).
Auto Trait Implementations§
impl Freeze for JsonValidator
impl RefUnwindSafe for JsonValidator
impl Send for JsonValidator
impl Sync for JsonValidator
impl Unpin for JsonValidator
impl UnsafeUnpin for JsonValidator
impl UnwindSafe for JsonValidator
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
Source§impl<C, T> Extract<T> for Cwhere
T: FromContext<C>,
impl<C, T> Extract<T> for Cwhere
T: FromContext<C>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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