pub enum ReaderQueryResultsParserOutput<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(b"true".as_slice())?
{
assert_eq!(v, true);
}
// solutions
if let ReaderQueryResultsParserOutput::Solutions(solutions) =
tsv_parser.for_reader(b"?foo\t?bar\n\"test\"\t".as_slice())?
{
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)
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> 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