Struct specta_util::Any
source · 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 TypeMap, _: Generics<'_>) -> DataType
fn inline(_: &mut TypeMap, _: Generics<'_>) -> DataType
Returns the definition of a type using the provided generics. Read more
source§fn reference(type_map: &mut TypeMap, generics: &[DataType]) -> Reference
fn reference(type_map: &mut TypeMap, 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)