Skip to main content

typescript_webidl/types/
mod.rs

1/// WebIDL 类型定义模块
2
3/// WebIDL 解析结果
4pub struct WebIdlResult {
5    /// WebIDL AST 根节点
6    pub root: oak_idl::ast::IdlRoot,
7    /// 生成的 TypeScript 类型定义
8    pub typescript: String,
9}
10
11/// WebIDL 错误
12pub enum WebIdlError {
13    /// 解析错误
14    ParseError(String),
15    /// 转换错误
16    ConvertError(String),
17}
18
19impl std::fmt::Display for WebIdlError {
20    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21        match self {
22            WebIdlError::ParseError(msg) => write!(f, "Parse error: {}", msg),
23            WebIdlError::ConvertError(msg) => write!(f, "Convert error: {}", msg),
24        }
25    }
26}
27
28impl std::fmt::Debug for WebIdlError {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        write!(f, "{}", self)
31    }
32}
33
34impl std::error::Error for WebIdlError {}