Skip to main content

TypeDesc

Enum TypeDesc 

Source
pub enum TypeDesc {
Show 18 variants Any, None, Bool, Int, Float, Str, Datetime, Date, Timedelta, List { item: Box<TypeDesc>, }, Tuple { items: Vec<TypeDesc>, }, Dict { value: Box<TypeDesc>, }, Literal { values: Vec<Value>, }, Union { variants: Vec<TypeDesc>, }, TypedDict { name: String, fields: Vec<Field>, }, Dataclass { name: String, fields: Vec<Field>, }, Model { name: String, schema: Value, }, ProcessResult,
}
Expand description

The type of a value that can be stored as a task output.

Variants§

§

Any

Anything (an explicit Any): only the run-time check applies.

§

None

None.

§

Bool

bool.

§

Int

int.

§

Float

float.

§

Str

str.

§

Datetime

datetime (stored tagged).

§

Date

date (stored tagged).

§

Timedelta

timedelta (stored tagged).

§

List

list[T].

Fields

§item: Box<TypeDesc>

The element type.

§

Tuple

tuple[A, B, ...] (stored tagged).

Fields

§items: Vec<TypeDesc>

The element types, in order.

§

Dict

dict[str, T] (keys are always strings).

Fields

§value: Box<TypeDesc>

The value type.

§

Literal

Literal[...].

Fields

§values: Vec<Value>

The allowed values (strings, integers, booleans or null).

§

Union

A union, including Optional[T] (T | None).

Fields

§variants: Vec<TypeDesc>

The member types.

§

TypedDict

A TypedDict.

Fields

§name: String

The class name, for messages.

§fields: Vec<Field>

The keys, in declaration order.

§

Dataclass

A dataclass.

Fields

§name: String

The class name, for messages and outcome names.

§fields: Vec<Field>

The fields, in declaration order.

§

Model

A Pydantic model (decision 59), described by Pydantic’s JSON Schema of it: what model_dump(mode="json") writes. Only the Python layer compares it; here its parts are Any.

Fields

§name: String

The class name, for messages and outcome names.

§schema: Value

The JSON Schema (with its $defs).

§

ProcessResult

The output of a command or script task.

Implementations§

Source§

impl TypeDesc

Source

pub fn field(&self, name: &str) -> Option<&TypeDesc>

The type of the named field or key, for checking an output path such as out.rows.

Returns None if this type has no such field: TypedDicts, dataclasses and ProcessResult have named fields, dict[str, T] has any key (giving T), and Any and a model give Any.

Source

pub fn element(&self, index: u64) -> Option<&TypeDesc>

The type of the element at index, for checking an output path such as out[0].

Returns None if this type can’t be indexed, or for a tuple index out of range; Any and a model give Any.

Trait Implementations§

Source§

impl Clone for TypeDesc

Source§

fn clone(&self) -> TypeDesc

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 TypeDesc

Source§

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

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

impl<'de> Deserialize<'de> for TypeDesc

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 Eq for TypeDesc

Source§

impl JsonSchema for TypeDesc

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for TypeDesc

Source§

fn eq(&self, other: &TypeDesc) -> 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 TypeDesc

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 TypeDesc

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.