pub enum ApiBodyType {
Show 14 variants String, Number, Boolean, Null, Any, Unknown, Binary, ArrayOf { value: Box<ApiBodyInfo>, }, TupleOf { values: Vec<ApiBodyInfo>, }, ObjectOf { value: Box<ApiBodyInfo>, }, Object { keys: HashMap<String, ApiBodyInfo>, }, OneOf { values: Vec<ApiBodyInfo>, }, StringLiteral { literal: String, }, Optional { value: Box<ApiBodyInfo>, },
}
Expand description

An enum representing the shape of the JSON that is provided or output from the API. There is a straightforward mapping from this to TypeScript types.

Variants§

§

String

Corresponds to the TypeScript type string.

§

Number

Corresponds to the TypeScript type number.

§

Boolean

Corresponds to the TypeScript type boolean.

§

Null

Corresponds to the TypeScript type null.

§

Any

Corresponds to the TypeScript type any.

This is used when the shape cannot be statically determined, and we want to indicate that any type can be provided. In many cases ApiBodyType::Unknown may be preferred.

§

Unknown

Corresponds to the TypeScript type unknown.

This is used when the shape cannot be statically determined, and we want to indicate that we’re not sure what the type is, unlike ApiBodyType::Any which hints that any type can be provided.

§

Binary

Indicate that we expect binary data to be provided. This may correspond to Blob in a UI.

§

ArrayOf

Fields

§value: Box<ApiBodyInfo>

The type of all of the values in the array.

An array of values of one type, where each value has the type value, eg string[] or number[].

§

TupleOf

Fields

§values: Vec<ApiBodyInfo>

A list of each of the types in this fixed length array.

A fixed length array of values that can be of mixed types, eg [string, number, Foo].

§

ObjectOf

Fields

§value: Box<ApiBodyInfo>

The type of all of the values in the object/map.

An object where the keys are strings and the values are all of the same type, eg { [key: string]: Foo }.

§

Object

Fields

§keys: HashMap<String, ApiBodyInfo>

The property name and type of each entry in the object.

An object whose keys and value types are known at compile time, eg { foo: string, bar: boolean, wibble: Foo }.

§

OneOf

Fields

§values: Vec<ApiBodyInfo>

Each of the possible types that this can be.

The type is one of several variants, eg string | number | Foo.

§

StringLiteral

Fields

§literal: String

The exact string literal that we expect.

The type is a string literal with a specific value, eg "stringvalue".

§

Optional

Fields

§value: Box<ApiBodyInfo>

The type that is optional.

The type is optional, and need not be provided. It corresponds to either { key?: Foo } in objects, or Foo | undefined in other contexts.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.