Struct specta_util::Unknown
source · pub struct Unknown<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 unknown in Typescript.
§Examples
This can be used as a type override.
use serde::Serialize;
use specta::{Type, Unknown};
#[derive(Serialize, Type)]
pub struct Demo {
#[specta(type = Unknown)]
pub field: String,
}Or it can be used as a wrapper type.
use serde::Serialize;
use specta::{Type, Unknown};
#[derive(Serialize, Type)]
pub struct Demo {
pub field: Unknown<String>,
}Trait Implementations§
source§impl<T> Type for Unknown<T>
impl<T> Type for Unknown<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 Unknown<T>where
T: Freeze,
impl<T> RefUnwindSafe for Unknown<T>where
T: RefUnwindSafe,
impl<T> Send for Unknown<T>where
T: Send,
impl<T> Sync for Unknown<T>where
T: Sync,
impl<T> Unpin for Unknown<T>where
T: Unpin,
impl<T> UnwindSafe for Unknown<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)