mirror of
https://github.com/TxtDot/dalet.git
synced 2025-02-26 14:21:25 +03:00
feat: add daletl types to rust lib
This commit is contained in:
parent
9d8220f726
commit
8464c71a5a
8 changed files with 125 additions and 1 deletions
4
libs/rust/src/lib.rs
Normal file
4
libs/rust/src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
mod types;
|
||||
|
||||
#[cfg(feature = "types")]
|
||||
pub use types::*;
|
6
libs/rust/src/main.rs
Normal file
6
libs/rust/src/main.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
use dalet::{Argument, Body, Tag};
|
||||
|
||||
fn main() {
|
||||
let _ = Tag::new(1, Body::Text("I am Heading".to_string()), Argument::Null);
|
||||
println!("Hello, world!");
|
||||
}
|
28
libs/rust/src/types.rs
Normal file
28
libs/rust/src/types.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Tag {
|
||||
id: i8,
|
||||
body: Body,
|
||||
argument: Argument,
|
||||
}
|
||||
|
||||
impl Tag {
|
||||
pub fn new(id: i8, body: Body, argument: Argument) -> Tag {
|
||||
Tag { id, body, argument }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum Body {
|
||||
Text(String),
|
||||
Tag(Box<Tag>),
|
||||
Null,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum Argument {
|
||||
Text(String),
|
||||
Number(i8),
|
||||
Null,
|
||||
}
|
Loading…
Add table
Reference in a new issue