Skip to content
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

Bug? ExecPager isn't exported #9

Closed
naamancurtis opened this issue Mar 22, 2021 · 2 comments
Closed

Bug? ExecPager isn't exported #9

naamancurtis opened this issue Mar 22, 2021 · 2 comments

Comments

@naamancurtis
Copy link

Hey,

I was trying to write some logic to issue a paged query using a prepared statement, however the type that exec returns - ExecPager isn't exported from cdrs_tokio::cluster. The struct is marked as public, however it doesn't appear to offer any interface to convert it into a type that I do have access to. My primary reason for wanting access to the type is so that I can return it as the result of a helper function. https://docs.rs/cdrs-tokio/3.0.0/src/cdrs_tokio/cluster/pager.rs.html#174

let mut pager = self.conn.paged(5);
let query = pager.exec(&prepared_query);

Am I just misunderstanding the API? or is this a quick fix?

@krojew
Copy link
Owner

krojew commented Mar 22, 2021

You should be able to call next() on ExecPager to get the data. https://github.com/krojew/cdrs-tokio/blob/master/examples/paged_query.rs shows how to use paged queries, although it uses QueryPager with string queries.

@naamancurtis
Copy link
Author

Thanks for the quick response. Yep, that makes sense.

However I was hoping to abstract the query creation logic into a function that I can call that would return an ExecPager. eg:

    async fn create_query<'a, Q: ToString, P: 'a>(
        &self,
        timeout_duration: Duration,
    ) -> ExecPager<'a, Q, P>;

But without ExecPager I'm not able to type the return type of the function? unless there's a trait I can use in it's place?

As an aside (apologies for hijacking the issue) I notice there's no way of providing parameters to a prepared query when using this pagination interface, is there a specific reason for this, or has the feature just not been implemented yet?

@krojew krojew closed this as completed in 9c6e869 Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants