-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add read API without lifetimes #725
Comments
@casey can you give the attached PR a try and let me know if that works for your use case? |
Dope, I'll give it a shot! |
I took a look at the PR, but it's big and it wasn't obvious to me how to use it. What would the calls be to return an iterator from this function:
|
Call |
I finally got around to integrating this, and it works, with some caveats. We read out of the database and then populate a template struct with the data that will be inserted into a HTML template. This template object uses We can get a query from the database as an The PR above gets around this by putting the iterator in an |
Ah yes, I see. I'll take a look. I think it can |
Ok, give it a try now |
Just ran into an issue, in order for the iterator to be Got this error:
|
Here's the function: pub(crate) fn get_home_inscriptions(
&self,
) -> Result<impl Iterator<Item = InscriptionId> + Clone> {
Ok(
self
.database
.begin_read()?
.open_table(HOME_INSCRIPTIONS)?
.range_arc::<u32>(..)?
.rev()
.flat_map(|result| result.map(|(_number, id)| InscriptionId::load(id.value()))),
)
} |
Hmm, can you somehow call clone() before flat_map()? I don't think StorageError can be Clone. It contains an io::Error |
We could call clone before flat_map, but the issue is that we would ideally want to be able to call clone inside the template, so that it can clone the iterator and then iterate over eat, instead of doing the mutex/option/take stuff. Can ArcRange be clone? It seems like it should be possible, since it doesn't actually contain a storage error, but rustc is adamant that it doesn't work. |
I refactored that PR to remove ArcRange and instead return |
It would be nice to have a read transaction API that uses reference counting instead of lifetimes. This would allow callers to return the values/iterators retrieved from a table
The text was updated successfully, but these errors were encountered: