pub enum TypeRef {
RefNamed(QualifiedName),
RefPrimitive(String, Option<String>),
RefArray(Box<TypeRef>),
RefOptional(Box<TypeRef>),
RefAny,
RefUnknown,
}Expand description
Reference to a type (Haskell-style tagged union with contents)
Haskell Aeson emits:
- Variants with data: {“tag”: “RefNamed”, “contents”: {…}}
- Unit variants: {“tag”: “RefAny”} (no contents field)
We use a custom deserializer to handle both cases.
Variants§
RefNamed(QualifiedName)
Named type reference
RefPrimitive(String, Option<String>)
Primitive type with optional format
RefArray(Box<TypeRef>)
Array type
RefOptional(Box<TypeRef>)
Optional type
RefAny
Intentionally dynamic (serde_json::Value) - accepts any JSON, no warning
RefUnknown
Unknown type (schema gap) - should warn
Implementations§
Source§impl TypeRef
impl TypeRef
Sourcepub fn to_ts(&self) -> String
pub fn to_ts(&self) -> String
Convert to TypeScript type string (fully qualified - joins namespace.Name as NamespaceName)
Sourcepub fn to_ts_in_namespace(&self, current_namespace: &str) -> String
pub fn to_ts_in_namespace(&self, current_namespace: &str) -> String
Convert to TypeScript type string within a namespace context Always uses local name - cross-namespace types are handled via imports
Sourcepub fn get_namespace(&self) -> Option<&str>
pub fn get_namespace(&self) -> Option<&str>
Get the namespace from a RefNamed, if qualified
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Check if this is an unknown type (schema gap that should warn)
Sourcepub fn contains_unknown(&self) -> bool
pub fn contains_unknown(&self) -> bool
Check if this contains an unknown type anywhere
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TypeRef
impl<'de> Deserialize<'de> for TypeRef
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TypeRef
impl RefUnwindSafe for TypeRef
impl Send for TypeRef
impl Sync for TypeRef
impl Unpin for TypeRef
impl UnsafeUnpin for TypeRef
impl UnwindSafe for TypeRef
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