pub struct CreateGrantRequest {
pub provider: Provider,
pub settings: GrantSettings,
pub state: Option<GrantStatus>,
pub scope: Option<Vec<String>>,
pub metadata: Option<Value>,
}Expand description
Request to create a new grant.
Grants can be created from OAuth tokens or custom authentication credentials.
§Example
// Create from OAuth access token
let request = CreateGrantRequest::from_access_token(
Provider::Google,
"oauth_access_token".to_string(),
);Fields§
§provider: ProviderProvider type.
settings: GrantSettingsGrant settings (OAuth or custom)
state: Option<GrantStatus>Grant state (defaults to “valid”)
scope: Option<Vec<String>>OAuth scopes to request.
metadata: Option<Value>Custom metadata.
Implementations§
Source§impl CreateGrantRequest
impl CreateGrantRequest
Sourcepub fn builder(provider: Provider) -> CreateGrantRequestBuilder
pub fn builder(provider: Provider) -> CreateGrantRequestBuilder
Create a builder for CreateGrantRequest.
Sourcepub fn from_access_token(provider: Provider, access_token: String) -> Self
pub fn from_access_token(provider: Provider, access_token: String) -> Self
Create from OAuth access token
§Example
let request = CreateGrantRequest::from_access_token(
Provider::Google,
"oauth_token_123".to_string(),
);
assert_eq!(request.provider, Provider::Google);Sourcepub fn from_custom_auth(
provider: Provider,
settings: CustomAuthSettings,
) -> Self
pub fn from_custom_auth( provider: Provider, settings: CustomAuthSettings, ) -> Self
Create from custom authentication settings
§Example
let custom_auth = CustomAuthSettings::Imap {
imap_host: "imap.example.com".to_string(),
imap_port: 993,
imap_username: "user@example.com".to_string(),
imap_password: "password".to_string(),
smtp_host: "smtp.example.com".to_string(),
smtp_port: 587,
smtp_username: None,
smtp_password: None,
};
let request = CreateGrantRequest::from_custom_auth(
Provider::Imap,
custom_auth,
);
assert_eq!(request.provider, Provider::Imap);Trait Implementations§
Source§impl Clone for CreateGrantRequest
impl Clone for CreateGrantRequest
Source§fn clone(&self) -> CreateGrantRequest
fn clone(&self) -> CreateGrantRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CreateGrantRequest
impl Debug for CreateGrantRequest
Source§impl<'de> Deserialize<'de> for CreateGrantRequest
impl<'de> Deserialize<'de> for CreateGrantRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for CreateGrantRequest
impl PartialEq for CreateGrantRequest
Source§fn eq(&self, other: &CreateGrantRequest) -> bool
fn eq(&self, other: &CreateGrantRequest) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CreateGrantRequest
impl Serialize for CreateGrantRequest
impl StructuralPartialEq for CreateGrantRequest
Auto Trait Implementations§
impl Freeze for CreateGrantRequest
impl RefUnwindSafe for CreateGrantRequest
impl Send for CreateGrantRequest
impl Sync for CreateGrantRequest
impl Unpin for CreateGrantRequest
impl UnsafeUnpin for CreateGrantRequest
impl UnwindSafe for CreateGrantRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more