pub struct PcsExternalClientBuilder { /* private fields */ }Expand description
Builder for PcsExternalClient<S>.
§Minimal wiring
use pcs_external::{PcsExternalClientBuilder, scopes::SendOnly};
let client = PcsExternalClientBuilder::new(
"https://api.ppoppo.com/ext",
"https://accounts.ppoppo.com/oauth/token",
"my-client-id",
"my-client-secret",
)
.build::<SendOnly>()
.await?;§From environment variables
Reads PCS_API_URL, PAS_TOKEN_URL, PAS_PCS_CLIENT_ID,
PAS_PCS_CLIENT_SECRET. Returns None if any is unset.
use pcs_external::{PcsExternalClientBuilder, scopes::SendOnly};
let client = PcsExternalClientBuilder::from_env()?
.build::<SendOnly>()
.await
.ok()?;Implementations§
Source§impl PcsExternalClientBuilder
impl PcsExternalClientBuilder
Sourcepub fn new(
api_url: impl Into<String>,
token_url: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
) -> Self
pub fn new( api_url: impl Into<String>, token_url: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, ) -> Self
Construct from explicit parameters.
Sourcepub fn from_env() -> Option<Self>
pub fn from_env() -> Option<Self>
Construct from environment variables.
Reads:
PCS_API_URL— e.g.https://api.ppoppo.com/extPAS_TOKEN_URL— e.g.https://accounts.ppoppo.com/oauth/tokenPAS_PCS_CLIENT_ID— OAuth2 client_idPAS_PCS_CLIENT_SECRET— OAuth2 client_secret
Returns None if any variable is missing.
Sourcepub fn with_cache_config(self, config: TokenCacheConfig) -> Self
pub fn with_cache_config(self, config: TokenCacheConfig) -> Self
Override the token cache configuration (e.g. refresh_skew).
Sourcepub async fn build<S: PcsExternalScopeSet>(
self,
) -> Result<PcsExternalClient<S>, Error>
pub async fn build<S: PcsExternalScopeSet>( self, ) -> Result<PcsExternalClient<S>, Error>
Build the client, connecting to the PCS External API endpoint.
§Errors
Returns Error::Transport or Error::InvalidPathPrefix if the
connection cannot be established.
Auto Trait Implementations§
impl Freeze for PcsExternalClientBuilder
impl RefUnwindSafe for PcsExternalClientBuilder
impl Send for PcsExternalClientBuilder
impl Sync for PcsExternalClientBuilder
impl Unpin for PcsExternalClientBuilder
impl UnsafeUnpin for PcsExternalClientBuilder
impl UnwindSafe for PcsExternalClientBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request