pub struct Any<T = ()>(/* private fields */);Available on crate feature
serde only.Expand description
Easily convert a non-Specta type into a Specta compatible type.
This will be typed as any in Typescript.
WARNING: When used with Option<Any<T>>, Typescript will not prompt you about nullability checks as any | null is coalesced to any in Typescript.
§Examples
This can be used as a type override.
use serde::Serialize;
use specta::{Type, Any};
#[derive(Serialize, Type)]
pub struct Demo {
#[specta(type = Any)]
pub field: String,
}Or it can be used as a wrapper type.
use serde::Serialize;
use specta::{Type, Any};
#[derive(Serialize, Type)]
pub struct Demo {
pub field: Any<String>,
}Trait Implementations§
Source§impl<T> Type for Any<T>
impl<T> Type for Any<T>
Source§fn inline(_: &mut TypeCollection, _: Generics<'_>) -> DataType
fn inline(_: &mut TypeCollection, _: Generics<'_>) -> DataType
Returns the definition of a type using the provided generics. Read more
Source§fn reference(type_map: &mut TypeCollection, generics: &[DataType]) -> Reference
fn reference(type_map: &mut TypeCollection, generics: &[DataType]) -> Reference
Generates a datatype corresponding to a reference to this type,
as determined by its category. Getting a reference to a type implies that
it should belong in the type map (since it has to be referenced from somewhere),
so the output of
definition will be put into the type map.Auto Trait Implementations§
impl<T> Freeze for Any<T>where
T: Freeze,
impl<T> RefUnwindSafe for Any<T>where
T: RefUnwindSafe,
impl<T> Send for Any<T>where
T: Send,
impl<T> Sync for Any<T>where
T: Sync,
impl<T> Unpin for Any<T>where
T: Unpin,
impl<T> UnwindSafe for Any<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more