Skip to content

Commit

Permalink
Remaining vevent properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed May 25, 2024
1 parent e6e70fe commit bf0d21b
Show file tree
Hide file tree
Showing 3 changed files with 596 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use nom::error::{ErrorKind, FromExternalError, ParseError};
use nom::multi::{fold_many0, many0, separated_list1};
use nom::sequence::{separated_pair, tuple};
use nom::{AsChar, IResult, Parser};
use std::str::FromStr;

mod component;
mod language_tag;
Expand Down Expand Up @@ -185,6 +186,18 @@ fn read_string<'a>(input: &'a [u8], context: &str) -> Result<String, nom::Err<Er
.to_string())
}

pub fn read_int<N: FromStr>(input: &[u8]) -> Result<N, nom::Err<Error>> {
std::str::from_utf8(input)
.map_err(|e| {
nom::Err::Error(Error::new(
input,
InnerError::EncodingError("Invalid integer number text".to_string(), e),
))
})?
.parse()
.map_err(|_| nom::Err::Error(Error::new(input, InnerError::InvalidIntegerNum)))
}

fn line_value(input: &[u8]) -> IResult<&[u8], Vec<u8>, Error> {
let (input, v) = fold_many0(
alt((
Expand Down
Loading

0 comments on commit bf0d21b

Please sign in to comment.