use crate::FieldEvidence;
use facet_reflect::Span;
pub trait ProbeStream<'de> {
type Error;
fn next(&mut self) -> Result<Option<FieldEvidence<'de>>, Self::Error>;
}
pub trait FormatParser<'de> {
type Error;
type Probe<'a>: ProbeStream<'de, Error = Self::Error>
where
Self: 'a;
fn next_event(&mut self) -> Result<Option<crate::ParseEvent<'de>>, Self::Error>;
fn peek_event(&mut self) -> Result<Option<crate::ParseEvent<'de>>, Self::Error>;
fn skip_value(&mut self) -> Result<(), Self::Error>;
fn begin_probe(&mut self) -> Result<Self::Probe<'_>, Self::Error>;
fn capture_raw(&mut self) -> Result<Option<&'de str>, Self::Error> {
self.skip_value()?;
Ok(None)
}
fn raw_capture_shape(&self) -> Option<&'static facet_core::Shape> {
None
}
fn is_self_describing(&self) -> bool {
true }
fn hint_struct_fields(&mut self, _num_fields: usize) {
}
fn hint_scalar_type(&mut self, _hint: ScalarTypeHint) {
}
fn hint_sequence(&mut self) {
}
fn hint_array(&mut self, _len: usize) {
}
fn hint_option(&mut self) {
}
fn hint_map(&mut self) {
}
fn hint_dynamic_value(&mut self) {
}
fn hint_enum(&mut self, _variants: &[EnumVariantHint]) {
}
fn hint_opaque_scalar(
&mut self,
_type_identifier: &'static str,
_shape: &'static facet_core::Shape,
) -> bool {
false
}
fn current_span(&self) -> Option<Span> {
None
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct EnumVariantHint {
pub name: &'static str,
pub kind: facet_core::StructKind,
pub field_count: usize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScalarTypeHint {
Bool,
U8,
U16,
U32,
U64,
U128,
Usize,
I8,
I16,
I32,
I64,
I128,
Isize,
F32,
F64,
String,
Bytes,
Char,
}
#[cfg(feature = "jit")]
pub trait FormatJitParser<'de>: FormatParser<'de> {
type FormatJit: crate::jit::JitFormat;
fn jit_input(&self) -> &'de [u8];
fn jit_pos(&self) -> Option<usize>;
fn jit_set_pos(&mut self, pos: usize);
fn jit_format(&self) -> Self::FormatJit;
fn jit_error(&self, input: &'de [u8], error_pos: usize, error_code: i32) -> Self::Error;
}