Expose the range parser (#1993)
This commit is contained in:
parent
10f29fbb26
commit
c02d176646
1 changed files with 18 additions and 0 deletions
|
@ -17,6 +17,7 @@ use serde::{Deserialize, Serialize};
|
|||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::ops::Bound;
|
||||
use std::str::FromStr;
|
||||
|
||||
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Range";
|
||||
|
||||
|
@ -29,6 +30,23 @@ pub struct Range {
|
|||
pub end: Bound<Id>,
|
||||
}
|
||||
|
||||
impl FromStr for Range {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Self::try_from(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for Range {
|
||||
type Error = ();
|
||||
fn try_from(v: &str) -> Result<Self, Self::Error> {
|
||||
match range(v) {
|
||||
Ok((_, v)) => Ok(v),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Range {
|
||||
/// Process this type returning a computed simple Value
|
||||
pub(crate) async fn compute(
|
||||
|
|
Loading…
Reference in a new issue