Skip to content

Commit

Permalink
OWX Reader return type is now generic
Browse files Browse the repository at this point in the history
Previously the OWX reader could only return a SetOntology<Rc<str>>,
which meant it must be transfered to what ever Ontology type was
needed if this was not right. Now it can return any type of
MutableOntology.
  • Loading branch information
phillord committed Jun 29, 2024
1 parent 492d6af commit e8e2d45
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/io/owx/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ where
build: &'a Build<A>,
mapping: PrefixMapping,
reader: NsReader<R>,
// buf: Vec<u8>,
}

pub fn read<R: BufRead>(
Expand All @@ -39,20 +38,19 @@ pub fn read<R: BufRead>(
read_with_build(bufread, &b)
}

pub fn read_with_build<A: ForIRI, R: BufRead>(
pub fn read_with_build<A: ForIRI, O: MutableOntology<A> + Default, R: BufRead>(
bufread: R,
build: &Build<A>,
) -> Result<(SetOntology<A>, PrefixMapping), HornedError> {
) -> Result<(O, PrefixMapping), HornedError> {
let reader: NsReader<R> = NsReader::from_reader(bufread);
let mut ont = SetOntology::new();
let mut ont: O = Default::default();
let mapping = PrefixMapping::default();
let mut buf = Vec::new();

let mut r = Read {
reader,
build,
mapping,
// buf: Vec::new(),
};

loop {
Expand Down Expand Up @@ -1363,10 +1361,11 @@ pub mod test {
ComponentMappedOntology<RcStr, RcAnnotatedComponent>,
PrefixMapping,
) {
let r = read(bufread, ParserConfiguration::default());
let b = Build::new();
let r = read_with_build(bufread, &b);
assert!(r.is_ok(), "Expected ontology, got failure:{:?}", r.err());
let (o, m) = r.ok().unwrap();
(o.into(), m)
(o, m)
}

#[test]
Expand Down

0 comments on commit e8e2d45

Please sign in to comment.