refactor: rename some types

This commit is contained in:
Artemy Egorov 2024-08-02 22:35:49 +03:00
parent a2cb481d29
commit ef1688b3be
4 changed files with 129 additions and 137 deletions

View file

@ -1,7 +1,7 @@
use dalet::{
daletl::ToDaletl,
daletpack::*,
typed::{Body, HeadingLevel, NotNullBody, Tag, TextOrNullArgument},
typed::{Body, Hl, NNBody, TNArgument, Tag},
};
use flate2::Compression;
use std::io::Write;
@ -33,54 +33,54 @@ pub fn compress_zlib(data: &Vec<u8>) -> std::io::Result<Vec<u8>> {
#[test]
fn bench() {
let page: Vec<Tag> = vec![
Tag::H("I am heading".to_owned(), HeadingLevel::One),
Tag::H("Heading 2".to_owned(), HeadingLevel::Two),
Tag::El(NotNullBody::Tags(vec![
Tag::El(NotNullBody::Text("Some ".to_owned())),
Tag::H("I am heading".to_owned(), Hl::One),
Tag::H("Heading 2".to_owned(), Hl::Two),
Tag::El(NNBody::Tags(vec![
Tag::El(NNBody::Text("Some ".to_owned())),
Tag::B("bold".to_owned()),
Tag::I("italic".to_owned()),
Tag::S("strike".to_owned()),
])),
Tag::Br,
Tag::Code("Hello world".to_owned(), TextOrNullArgument::Null),
Tag::Code("Hello world".to_owned(), TNArgument::Null),
Tag::Br,
Tag::Ol(vec![
Tag::El(NotNullBody::Text("abc".to_owned())),
Tag::El(NotNullBody::Tags(vec![
Tag::El(NotNullBody::Text("def".to_owned())),
Tag::El(NNBody::Text("abc".to_owned())),
Tag::El(NNBody::Tags(vec![
Tag::El(NNBody::Text("def".to_owned())),
Tag::Ol(vec![
Tag::El(NotNullBody::Text("defabc".to_owned())),
Tag::El(NotNullBody::Text("defdef".to_owned())),
Tag::El(NNBody::Text("defabc".to_owned())),
Tag::El(NNBody::Text("defdef".to_owned())),
]),
])),
Tag::El(NotNullBody::Text("xyz".to_owned())),
Tag::El(NNBody::Text("xyz".to_owned())),
]),
Tag::Br,
Tag::El(NotNullBody::Tags(vec![
Tag::El(NotNullBody::Text("Lorem ipsum ".to_owned())),
Tag::El(NNBody::Tags(vec![
Tag::El(NNBody::Text("Lorem ipsum ".to_owned())),
Tag::Link(
Body::Tags(vec![Tag::Img("https://my-picture".to_owned())]),
"https://some-link".to_owned(),
),
Tag::El(NotNullBody::Text(
Tag::El(NNBody::Text(
" dolor sit amet consequetur adipiscing elit".to_owned(),
)),
])),
Tag::Table(vec![
Tag::Tpcol(vec![
Tag::El(NotNullBody::Text("Col 1".to_owned())),
Tag::El(NotNullBody::Text("Col 2".to_owned())),
Tag::El(NotNullBody::Text("Col 3".to_owned())),
Tag::El(NNBody::Text("Col 1".to_owned())),
Tag::El(NNBody::Text("Col 2".to_owned())),
Tag::El(NNBody::Text("Col 3".to_owned())),
]),
Tag::Tcol(vec![
Tag::El(NotNullBody::Text("Never gonna".to_owned())),
Tag::El(NotNullBody::Text("give you".to_owned())),
Tag::El(NotNullBody::Text("up".to_owned())),
Tag::El(NNBody::Text("Never gonna".to_owned())),
Tag::El(NNBody::Text("give you".to_owned())),
Tag::El(NNBody::Text("up".to_owned())),
]),
]),
];
let dalet_page = page.to_daletl();
let dalet_page = page.to_dl();
let markdown = iprint!("Markdown", include_str!("./bench.md").as_bytes().to_vec());
let daletpack = iprint!("Daletpack", encode_no_compress(&dalet_page).unwrap());