parser: add utf8 seeking functions

useful for peeking the previous utf8 char on a 0-copy utf8 buffer view
This commit is contained in:
William Casarin
2023-07-01 11:27:47 -07:00
parent cc043a4ec3
commit 3033943e52
4 changed files with 175 additions and 37 deletions

View File

@@ -1,6 +1,9 @@
use crate::parser;
#[derive(Eq, PartialEq, Debug)]
pub enum Error {
Nostr(enostr::Error),
Parse(parser::Error),
Generic(String),
}
@@ -10,6 +13,12 @@ impl From<String> for Error {
}
}
impl From<parser::Error> for Error {
fn from(s: parser::Error) -> Self {
Error::Parse(s)
}
}
impl From<enostr::Error> for Error {
fn from(err: enostr::Error) -> Self {
Error::Nostr(err)