Repository navigation
Add support for resolving external entities - #147
Conversation
|
@PeterlitsZo Could you verify that this works for you? Thanks! |
|
OK, of course. |
|
I am glad to say that this works well for my HDFS configure file. Thanks a lot. @RazrFalcon Hello, do you think if this PR can merged? |
Note that he said in #123 that he might not be able to work on this crate at all. I do want to give him a week or so to chime in and veto this, but without input, we'll have to find a way forward ourselves. |
|
OK. Sounds great. |
|
Looks good to me.
|
ad05ea6 to
023b8f3
Compare
Done. |
023b8f3 to
a6ce27e
Compare
a6ce27e to
4a3071c
Compare
This adds minimal support for resolving external entities by enabling the user to supply a resolver which can act on the public ID and URI defining the entity.
4a3071c to
9ca2157
Compare
|
Do you have an example of how this could be used with loading additional data from disk? The unit test uses a static str, and it's not clear how to create owned data in entity resolution and return a reference to it |
One option would be to use an arena, e.g. let bump = bumpalo::Bump::new();
let mut entity_resolver = |pub_id: Option<&str>, uri: &str| {
let path = uri_to_path(pub_id, uri);
let buf = std::fs::read_to_string(&path)
.map_err(|err| format!("Failed to read from {}: {}", path.display(), err))?;
Ok(Some(bump.alloc_str(&buf)))
};However, not that |
|
Trying to do a flavor of that still leads to lifetime issues let mut entity_resolver = move |pub_id: Option<&str>, uri: &str| {
let buf = uri.to_string();
let alloc: &str = bump.alloc_str(&buf);
Ok(Some(alloc))
}; |
|
Sorry, the |
|
Without the |
|
You definitely need to borrow from |
|
That conversation was because of Kimahriman/hdfs-native#260 which is what I'm trying to figure out how to improve. I think the only reason it works currently is because it uses raw pointers to create |
This adds minimal support for resolving external entities by enabling the user to supply a resolver which can act on the public ID and URI defining the entity.
Fixes #146