xso: make Context use a builder-like pattern

That way, we can (hopefully) add more fields in the future without
breaking stuff.

I don't yet know what such fields could be, though.
This commit is contained in:
Jonas Schäfer 2025-04-27 13:21:01 +02:00
commit cffb5e7e65
2 changed files with 46 additions and 18 deletions

View file

@ -648,7 +648,8 @@ impl<T: FromXml> ReadXsoState<T> {
}
Ok(Some(rxml::Event::StartElement(_, name, attrs))) => {
let source_tmp = source.as_mut();
let ctx = xso::Context::new(source_tmp.lang_stack.current());
let ctx = xso::Context::empty()
.with_language(source_tmp.lang_stack.current());
*self = ReadXsoState::Parsing(
<Result<T, xso::error::Error> as FromXml>::from_events(
name, attrs, &ctx,
@ -708,7 +709,7 @@ impl<T: FromXml> ReadXsoState<T> {
};
let source_tmp = source.as_mut();
let ctx = xso::Context::new(source_tmp.lang_stack.current());
let ctx = xso::Context::empty().with_language(source_tmp.lang_stack.current());
match builder.feed(ev, &ctx) {
Err(err) => {
*self = ReadXsoState::Done;