specta_typescript/opaque.rs
1use std::borrow::Cow;
2
3use specta::datatype::Reference;
4
5#[derive(PartialEq, Eq, Hash)]
6pub(crate) struct Define(pub(crate) Cow<'static, str>);
7
8#[derive(PartialEq, Eq, Hash)]
9pub(crate) struct Any;
10
11#[derive(PartialEq, Eq, Hash)]
12pub(crate) struct Unknown;
13
14#[derive(PartialEq, Eq, Hash)]
15pub(crate) struct Never;
16
17/// Define a custom Typescript string which can be used as a `DataType::Reference`.
18///
19/// This is an advanced feature which should be used with caution.
20pub fn define(raw: impl Into<Cow<'static, str>>) -> Reference {
21 Reference::opaque(Define(raw.into()))
22}