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

The ability to add mutliple scopes for a Call #333

Open
elpiel opened this issue Apr 14, 2022 · 1 comment
Open

The ability to add mutliple scopes for a Call #333

elpiel opened this issue Apr 14, 2022 · 1 comment

Comments

@elpiel
Copy link

elpiel commented Apr 14, 2022

I've made this small Trait extension for adding multiple scopes at once to a specific *Call.
It really helps when you have a static defining your scopes per request.

Can this be added to the *Call structs for convenience in some way?

use gmail1::api::{Scope, UserMessageGetCall, UserMessageListCall};

/// Extension trait for all Gmail calls.
pub trait CallExt {
    fn add_scopes(self, scopes: &[Scope]) -> Self;
}

impl<'a> CallExt for UserMessageGetCall<'a> {
    fn add_scopes(mut self, scopes: &[Scope]) -> UserMessageGetCall<'a> {
        for scope in scopes {
            self = self.add_scope(scope);
        }

        self
    }
}
impl<'a> CallExt for UserMessageListCall<'a> {
    fn add_scopes(mut self, scopes: &[Scope]) -> UserMessageListCall<'a> {
        for scope in scopes {
            self = self.add_scope(scope);
        }

        self
    }
}
@Byron
Copy link
Owner

Byron commented Apr 15, 2022

This does indeed look useful to have, and a PR would be very welcome. If you consider submitting one, please don't regenerate the APIs as it makes the review difficult. Thanks.

@elpiel elpiel changed the title The abbility to add mutliple scopes for a Call The ability to add mutliple scopes for a Call Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants