mirror of
https://github.com/TxtDot/dalet-rs.git
synced 2024-11-21 16:26:21 +03:00
refactor: move traits to daletl
This commit is contained in:
parent
accf9aae58
commit
4cc99ce163
4 changed files with 25 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
use num_enum::TryFromPrimitive;
|
||||
|
||||
use crate::daletl::{self, t_new, Tid};
|
||||
use crate::daletl::{self, t_new, Tid, ToDaletl, ToDaletlArgument, ToDaletlBody, ToDaletlTag};
|
||||
|
||||
const NB: daletl::Body = daletl::Body::Null;
|
||||
const NA: daletl::Argument = daletl::Argument::Null;
|
||||
|
@ -39,14 +39,6 @@ pub enum Tag {
|
|||
Pre(String),
|
||||
}
|
||||
|
||||
pub trait ToDaletl {
|
||||
fn to_daletl(self) -> Vec<daletl::Tag>;
|
||||
}
|
||||
|
||||
pub trait ToDaletlTag {
|
||||
fn to_daletl_tag(self) -> daletl::Tag;
|
||||
}
|
||||
|
||||
impl ToDaletlTag for Tag {
|
||||
fn to_daletl_tag(self) -> daletl::Tag {
|
||||
match self {
|
||||
|
@ -84,14 +76,6 @@ impl ToDaletlTag for Tag {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ToDaletlBody {
|
||||
fn to_daletl_body(self) -> daletl::Body;
|
||||
}
|
||||
|
||||
pub trait ToDaletlArgument {
|
||||
fn to_daletl_argument(self) -> daletl::Argument;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, TryFromPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum HeadingLevel {
|
||||
|
|
|
@ -21,10 +21,6 @@ pub fn t_new(id: Tid, body: Body, argument: Argument) -> Tag {
|
|||
Tag::new(id, body, argument)
|
||||
}
|
||||
|
||||
pub trait IsNull {
|
||||
fn is_null(&self) -> bool;
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(untagged)]
|
||||
pub enum Body {
|
||||
|
@ -94,3 +90,23 @@ pub enum Tid {
|
|||
Code,
|
||||
Pre,
|
||||
}
|
||||
|
||||
pub trait IsNull {
|
||||
fn is_null(&self) -> bool;
|
||||
}
|
||||
|
||||
pub trait ToDaletl {
|
||||
fn to_daletl(self) -> Vec<Tag>;
|
||||
}
|
||||
|
||||
pub trait ToDaletlTag {
|
||||
fn to_daletl_tag(self) -> Tag;
|
||||
}
|
||||
|
||||
pub trait ToDaletlBody {
|
||||
fn to_daletl_body(self) -> Body;
|
||||
}
|
||||
|
||||
pub trait ToDaletlArgument {
|
||||
fn to_daletl_argument(self) -> Argument;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use dalet::{
|
||||
abstractions::{Body, HeadingLevel, NotNullBody, Tag, TextOrNullArgument, ToDaletl},
|
||||
abstractions::{Body, HeadingLevel, NotNullBody, Tag, TextOrNullArgument},
|
||||
daletl::ToDaletl,
|
||||
daletpack::*,
|
||||
};
|
||||
use flate2::Compression;
|
||||
use std::io::{read_to_string, Write};
|
||||
use std::io::Write;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! iprint {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
=> gemini://example.com A supremely cool Gemini capsule
|
||||
=> sftp://example.com
|
||||
|
||||
Hi
|
||||
This is paragraph
|
||||
|
||||
=>https://example.com A cool website
|
||||
=>gopher://example.com An even cooler gopherhole
|
||||
|
|
Loading…
Add table
Reference in a new issue