Skip to main content

ParseValue

Enum ParseValue 

Source
pub enum ParseValue {
Show 13 variants Null, Bool(bool), Number(f64), String(String), Array(Vec<ParseValue>), Object(ParseMap), Date(ParseDate), Pointer { class_name: String, object_id: String, }, GeoPoint { latitude: f64, longitude: f64, }, Bytes(Vec<u8>), File { name: String, url: Option<String>, }, Polygon(Vec<(f64, f64)>), Relation { class_name: String, },
}
Expand description

A Parse value.

The data plane stays dynamic on purpose. There is no compile-time struct per application class, because the schema does not exist at compile time. Object and Array contents are deliberately opaque.

Deliberately no PartialEq. See the module note.

Deliberately not #[non_exhaustive], either, and that is the opposite of the usual advice. non_exhaustive lets a downstream crate keep compiling when a variant is added, by forcing it to carry a wildcard arm. For this type that is precisely the wrong trade: every consumer is a total function over the value space, an encoder, a decoder, a storage transform, an equality predicate, and a wildcard arm in any of them is a silent data-loss bug waiting for the next variant. The whole premise of writing this in Rust is that forgetting a case is a compile error; non_exhaustive on this enum would make that false across exactly the crate boundary that matters.

Adding a variant here is a breaking change on purpose. ErrorCode keeps non_exhaustive, because nobody exhaustively matches sixty error codes and a new one genuinely is additive.

Variants§

§

Null

§

Bool(bool)

§

Number(f64)

JavaScript has exactly one number type. Matching its lossiness above 2^53 is the goal, not avoiding it.

§

String(String)

§

Array(Vec<ParseValue>)

§

Object(ParseMap)

§

Date(ParseDate)

{"__type":"Date","iso":"..."}, or a bare ISO string at createdAt/updatedAt.

§

Pointer

{"__type":"Pointer","className":"...","objectId":"..."}

Fields

§class_name: String
§object_id: String
§

GeoPoint

{"__type":"GeoPoint","latitude":n,"longitude":n}

Fields

§latitude: f64
§longitude: f64
§

Bytes(Vec<u8>)

{"__type":"Bytes","base64":"..."}. Held decoded, because Mongo stores BSON Binary and re-encoding from a canonical byte slice is what keeps the two backends agreeing.

§

File

{"__type":"File","name":"...","url":"..."}. url is absent on a file pointer that has not been through expandFilesInObject, so it is optional rather than defaulted.

Fields

§name: String
§

Polygon(Vec<(f64, f64)>)

{"__type":"Polygon","coordinates":[[lat,lng],...]}

Note the axis order: Parse’s wire form is latitude first, the reverse of GeoJSON. PolygonCoder.databaseToJSON swaps on the way out (MongoTransform.js:1362-1372), so holding it in wire order keeps that swap confined to the Mongo boundary.

§

Relation

{"__type":"Relation","className":"..."}

Fields

§class_name: String

Implementations§

Source§

impl ParseValue

Source

pub fn to_json(&self) -> String

Serialize to the exact bytes Parse Server would emit.

Numbers go through js_number::to_ecma_string rather than any Rust float formatter, for the reasons in that module. Non-finite numbers become null, which is what JSON.stringify does; to_ecma_string alone would emit NaN, which is not valid JSON.

Trait Implementations§

Source§

impl Clone for ParseValue

Source§

fn clone(&self) -> ParseValue

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 ParseValue

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V