mirror of
https://github.com/TxtDot/dalet.git
synced 2024-12-26 04:23:45 +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
1
libs/rust/.gitignore
vendored
Normal file
1
libs/rust/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
65
libs/rust/Cargo.lock
generated
Normal file
65
libs/rust/Cargo.lock
generated
Normal file
|
@ -0,0 +1,65 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "dalet"
|
||||
version = "1.0.0-pre0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.204"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.204"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
19
libs/rust/Cargo.toml
Normal file
19
libs/rust/Cargo.toml
Normal file
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "dalet"
|
||||
version = "1.0.0-pre0"
|
||||
edition = "2021"
|
||||
authors = ["artegoser"]
|
||||
license = "MIT"
|
||||
description = "Dalet implementation in Rust"
|
||||
repository = "https://github.com/txtdot/dalet"
|
||||
homepage = "https://github.com/TxtDot/dalet/tree/main/libs/rust"
|
||||
readme = "./README.md"
|
||||
keywords = ["dalet"]
|
||||
categories = ["compression", "compilers", "encoding"]
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
[features]
|
||||
default = ["types"]
|
||||
types = []
|
1
libs/rust/readme.md
Normal file
1
libs/rust/readme.md
Normal file
|
@ -0,0 +1 @@
|
|||
# Dalet-rs
|
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,
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@txtdot/dalet",
|
||||
"version": "1.0.0-pre0",
|
||||
"description": "Dalet realization in typescript",
|
||||
"description": "Dalet implementation in typescript",
|
||||
"main": "dist/lib.js",
|
||||
"types": "dist/lib.d.ts",
|
||||
"files": [
|
||||
|
|
Loading…
Add table
Reference in a new issue