pub struct TokenProvider { /* private fields */ }Expand description
Single-flight provider for cached LazyCat device API tokens.
Implementations§
Source§impl TokenProvider
impl TokenProvider
Sourcepub async fn connect(
api_url: &str,
credentials: ClientCredentials,
) -> Result<Self, Error>
pub async fn connect( api_url: &str, credentials: ClientCredentials, ) -> Result<Self, Error>
Connect an mTLS device channel and create its token provider.
§Errors
Returns an error if the URL is invalid or the device channel cannot be established.
Sourcepub fn new(channel: Channel, credentials: ClientCredentials) -> Self
pub fn new(channel: Channel, credentials: ClientCredentials) -> Self
Create a provider around an already connected raw device channel.
Sourcepub async fn token(&self) -> Result<Arc<AuthToken>, Error>
pub async fn token(&self) -> Result<Arc<AuthToken>, Error>
Return a cached token or refresh it once for all concurrent callers.
§Errors
Returns an error when request signing or the PermissionManager RPC fails.
Sourcepub fn authenticated_service(&self) -> AuthenticatedService<Channel>
pub fn authenticated_service(&self) -> AuthenticatedService<Channel>
Wrap this provider’s channel with automatic auth-token metadata.
Trait Implementations§
Source§impl Clone for TokenProvider
impl Clone for TokenProvider
Auto Trait Implementations§
impl !RefUnwindSafe for TokenProvider
impl !UnwindSafe for TokenProvider
impl Freeze for TokenProvider
impl Send for TokenProvider
impl Sync for TokenProvider
impl Unpin for TokenProvider
impl UnsafeUnpin for TokenProvider
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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