feat: add daletl types to rust lib

This commit is contained in:
Artemy Egorov 2024-07-28 20:49:55 +03:00
parent 9d8220f726
commit 8464c71a5a
8 changed files with 125 additions and 1 deletions

4
libs/rust/src/lib.rs Normal file
View file

@ -0,0 +1,4 @@
mod types;
#[cfg(feature = "types")]
pub use types::*;

6
libs/rust/src/main.rs Normal file
View 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
View 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,
}