pub enum ReaderQueryResultsParserOutput<R>where
R: Read,{
Solutions(ReaderSolutionsParser<R>),
Boolean(bool),
}Expand description
The reader for a given read of a results file.
It is either a read boolean (bool) or a streaming reader of a set of solutions (ReaderSolutionsParser).
Example in TSV (the API is the same for JSON and XML):
use oxrdf::{Literal, Variable};
use sparesults::{QueryResultsFormat, QueryResultsParser, ReaderQueryResultsParserOutput};
let tsv_parser = QueryResultsParser::from_format(QueryResultsFormat::Tsv);
// boolean
if let ReaderQueryResultsParserOutput::Boolean(v) =
tsv_parser.clone().for_reader("true".as_bytes())?
{
assert_eq!(v, true);
}
// solutions
if let ReaderQueryResultsParserOutput::Solutions(solutions) =
tsv_parser.for_reader("?foo\t?bar\n\"test\"\t".as_bytes())?
{
assert_eq!(
solutions.variables(),
&[Variable::new("foo")?, Variable::new("bar")?]
);
for solution in solutions {
assert_eq!(
solution?.iter().collect::<Vec<_>>(),
vec![(&Variable::new("foo")?, &Literal::from("test").into())]
);
}
}Variants§
Solutions(ReaderSolutionsParser<R>)
Boolean(bool)
Trait Implementations§
Source§impl<'a, R> From<ReaderQueryResultsParserOutput<R>> for QueryResults<'a>where
R: Read + 'a,
impl<'a, R> From<ReaderQueryResultsParserOutput<R>> for QueryResults<'a>where
R: Read + 'a,
Source§fn from(output: ReaderQueryResultsParserOutput<R>) -> QueryResults<'a>
fn from(output: ReaderQueryResultsParserOutput<R>) -> QueryResults<'a>
Converts to this type from the input type.
Auto Trait Implementations§
impl<R> Freeze for ReaderQueryResultsParserOutput<R>where
R: Freeze,
impl<R> RefUnwindSafe for ReaderQueryResultsParserOutput<R>where
R: RefUnwindSafe,
impl<R> Send for ReaderQueryResultsParserOutput<R>where
R: Send,
impl<R> Sync for ReaderQueryResultsParserOutput<R>where
R: Sync,
impl<R> Unpin for ReaderQueryResultsParserOutput<R>where
R: Unpin,
impl<R> UnsafeUnpin for ReaderQueryResultsParserOutput<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for ReaderQueryResultsParserOutput<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more