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 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 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