Skip to main content

JsonErrorData

Struct JsonErrorData 

Source
pub struct JsonErrorData {
    pub msg: String,
    pub doc: Option<String>,
    pub pos: usize,
    pub lineno: usize,
    pub colno: usize,
}
Expand description

Structured fields of a json.JSONDecodeError, mirroring CPython’s msg / doc / pos / lineno / colno exception attributes.

As with UnicodeErrorData, the payload exists so host bindings can construct a real json.JSONDecodeError instead of falling back to a plain ValueError; sandboxed code never sees these fields. lineno/colno are carried explicitly rather than recomputed from doc because doc may be absent (see JsonErrorData::MAX_DOC_LEN).

Fields§

§msg: String

The bare error message, without the : line N column M (char K) suffix the formatted exception message carries.

§doc: Option<String>

The document being parsed, matching CPython’s exc.doc. None when the document exceeds JsonErrorData::MAX_DOC_LEN or is not valid UTF-8 (json.loads on bytes input).

§pos: usize

Character index of the error in doc, matching CPython’s exc.pos.

§lineno: usize

1-based line of the error, matching CPython’s exc.lineno.

§colno: usize

1-based column of the error, matching CPython’s exc.colno.

Implementations§

Source§

impl JsonErrorData

Source

pub const MAX_DOC_LEN: usize

Document size cap, mirroring UnicodeErrorData::MAX_OBJECT_LEN: exception payloads are copied into the host once they escape the worker, so doc is dropped (not truncated — a partial document would misplace pos) for larger inputs.

Source

pub fn build( msg: &str, doc: &[u8], pos: usize, lineno: usize, colno: usize, ) -> ExcData

Builds the payload for a decode error on doc, omitting the document when it exceeds Self::MAX_DOC_LEN or is not valid UTF-8.

Trait Implementations§

Source§

impl Clone for JsonErrorData

Source§

fn clone(&self) -> JsonErrorData

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 JsonErrorData

Source§

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

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

impl<'de> Deserialize<'de> for JsonErrorData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for JsonErrorData

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 PartialEq for JsonErrorData

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for JsonErrorData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for JsonErrorData

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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, 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.