lib: move Slice, ScalarStyle, StreamEncoding enums

from lib/token to event/types, and add Copy derives for ScalarStyle +
StreamEncoding.
This commit is contained in:
Paul Stemmet 2022-03-27 09:08:24 +00:00 committed by Paul Stemmet
parent 51c7529f75
commit c2f20d7883
2 changed files with 20 additions and 18 deletions

View File

@ -11,9 +11,11 @@ use std::{array::IntoIter as ArrayIter, borrow::Cow, collections::HashMap};
use crate::{
scanner::{entry::Lazy, error::ScanResult},
token::{ScalarStyle, Slice, StreamEncoding, Token},
token::Token,
};
pub type Slice<'a> = std::borrow::Cow<'a, str>;
pub const DEFAULT_TAGS: [(Slice<'static>, Slice<'static>); 2] = [
(Cow::Borrowed("!"), Cow::Borrowed("!")),
(Cow::Borrowed("!!"), Cow::Borrowed("tag:yaml.org,2002:")),
@ -352,3 +354,19 @@ pub struct VersionDirective
/// Typedef map of tag directives present in the current
/// document
pub type TagDirectives<'de> = HashMap<Slice<'de>, Slice<'de>>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum StreamEncoding
{
UTF8,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ScalarStyle
{
Plain,
SingleQuote,
DoubleQuote,
Literal,
Folded,
}

View File

@ -4,7 +4,7 @@
* was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
pub type Slice<'a> = std::borrow::Cow<'a, str>;
pub use crate::event::types::{ScalarStyle, Slice, StreamEncoding};
/// Tokens that may be emitted by a YAML scanner
#[derive(Debug, PartialEq)]
@ -199,19 +199,3 @@ impl PartialEq<Token<'_>> for Marker
self == &Self::from(other)
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum StreamEncoding
{
UTF8,
}
#[derive(Debug, Clone, PartialEq)]
pub enum ScalarStyle
{
Plain,
SingleQuote,
DoubleQuote,
Literal,
Folded,
}