pub enum SliceQueryResultsParserOutput<'a> {
Solutions(SliceSolutionsParser<'a>),
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 (SliceSolutionsParser
).
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(SliceSolutionsParser<'a>)
Boolean(bool)
Auto Trait Implementations§
impl<'a> Freeze for SliceQueryResultsParserOutput<'a>
impl<'a> RefUnwindSafe for SliceQueryResultsParserOutput<'a>
impl<'a> Send for SliceQueryResultsParserOutput<'a>
impl<'a> Sync for SliceQueryResultsParserOutput<'a>
impl<'a> Unpin for SliceQueryResultsParserOutput<'a>
impl<'a> UnwindSafe for SliceQueryResultsParserOutput<'a>
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