pub struct PolicyClient { /* private fields */ }Expand description
HTTP client for the enterprise policy server.
Implementations§
Source§impl PolicyClient
impl PolicyClient
Sourcepub fn new(server_url: &str, api_key: Option<String>) -> Result<Self>
pub fn new(server_url: &str, api_key: Option<String>) -> Result<Self>
Create a new PolicyClient.
§Arguments
server_url- Base URL of the policy serverapi_key- Optional API key for authentication
Sourcepub async fn fetch_bundle(&self) -> Result<PolicyBundle>
pub async fn fetch_bundle(&self) -> Result<PolicyBundle>
Fetch the current policy bundle from the server.
Makes a GET request to /v1/policies and deserializes the response
as a PolicyBundle.
Sourcepub fn poll(
self: Arc<Self>,
interval: Duration,
shutdown: Receiver<bool>,
) -> Receiver<Option<PolicyBundle>>
pub fn poll( self: Arc<Self>, interval: Duration, shutdown: Receiver<bool>, ) -> Receiver<Option<PolicyBundle>>
Start background polling for policy updates.
Fetches the policy bundle at the given interval and sends updates through the returned watch channel. Stops when the shutdown signal is received.
§Arguments
interval- How often to poll for updatesshutdown- Receiver that signals when to stop polling
§Returns
A watch receiver that receives new PolicyBundle values on updates.
Auto Trait Implementations§
impl Freeze for PolicyClient
impl !RefUnwindSafe for PolicyClient
impl Send for PolicyClient
impl Sync for PolicyClient
impl Unpin for PolicyClient
impl UnsafeUnpin for PolicyClient
impl !UnwindSafe for PolicyClient
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more