mirror of https://codeberg.org/topola/topola.git
refactor(specctra-core): merge common.rs into lib.rs
This commit is contained in:
parent
ae006173ce
commit
81a6ec22d0
|
|
@ -1,25 +0,0 @@
|
|||
pub enum ListToken {
|
||||
Start { name: String },
|
||||
Leaf { value: String },
|
||||
End,
|
||||
}
|
||||
|
||||
impl ListToken {
|
||||
pub fn is_start_of(&self, valid_names: &[&'static str]) -> bool {
|
||||
if let Self::Start { name: actual_name } = self {
|
||||
valid_names
|
||||
.iter()
|
||||
.any(|i| i.eq_ignore_ascii_case(actual_name))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
match &self {
|
||||
Self::Start { name } => 1 + name.len(),
|
||||
Self::Leaf { value } => value.len(),
|
||||
Self::End => 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
//! Module containing the informations about handling the Specctra
|
||||
//! based file format, and parsing it into Topola's objects
|
||||
//! Module about handling the Specctra based file format, and parsing + serializing it
|
||||
|
||||
mod common;
|
||||
pub use common::*;
|
||||
pub mod error;
|
||||
pub mod math;
|
||||
pub mod mesadata;
|
||||
|
|
@ -10,3 +7,29 @@ pub mod read;
|
|||
pub mod rules;
|
||||
pub mod structure;
|
||||
pub mod write;
|
||||
|
||||
pub enum ListToken {
|
||||
Start { name: String },
|
||||
Leaf { value: String },
|
||||
End,
|
||||
}
|
||||
|
||||
impl ListToken {
|
||||
pub fn is_start_of(&self, valid_names: &[&'static str]) -> bool {
|
||||
if let Self::Start { name: actual_name } = self {
|
||||
valid_names
|
||||
.iter()
|
||||
.any(|i| i.eq_ignore_ascii_case(actual_name))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
match &self {
|
||||
Self::Start { name } => 1 + name.len(),
|
||||
Self::Leaf { value } => value.len(),
|
||||
Self::End => 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use super::common::ListToken;
|
||||
use super::error::{ParseError, ParseErrorContext};
|
||||
use super::structure::Parser;
|
||||
use super::ListToken;
|
||||
use utf8_chars::BufReadCharsExt;
|
||||
|
||||
pub struct InputToken {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::common::ListToken;
|
||||
use super::ListToken;
|
||||
use std::io;
|
||||
|
||||
pub trait WriteSes<W: io::Write> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue