pub struct ComplianceService<C = ConsentService> { /* private fields */ }
Expand description
The main compliance service that manages policies and evaluates flows.
ComplianceService
implements the Service
trait from the Tower library,
providing an asynchronous interface for handling compliance requests.
It combines policy storage and evaluation logic in a single service.
§Features
- Policy Management: Store, retrieve, and update resource policies
- Flow Evaluation: Check whether data flows comply with policies
- Thread Safety: Safe for concurrent use across multiple threads
- Async Interface: Non-blocking operations using Tower’s Service trait
§Request Types
The service handles several types of compliance requests:
EvalPolicies
- Evaluate whether a flow is permittedGetPolicy
/GetPolicies
- Retrieve existing policiesSetPolicy
- Set complete policy for a resourceSetConfidentiality
/SetIntegrity
/SetConsent
- Update specific policy fieldsSetDeleted
- Mark resources for deletion
§Operating Modes
§Normal Mode (default)
- Used in production
- Unknown resources get default policies automatically
- More forgiving for dynamic resource discovery
§Cache Mode
- Used primarily in testing
- Unknown resources cause
PolicyNotFound
errors - Enforces explicit policy management
§Error Handling
The service returns TraceabilityError
for various failure conditions:
PolicyNotFound
- Resource not found (in cache mode)DirectPolicyViolation
- Flow violates compliance rulesInternalTrace2eError
- Internal service errors
Implementations§
Source§impl ComplianceService<ConsentService>
impl ComplianceService<ConsentService>
pub fn new_with_consent(consent: ConsentService) -> Self
Trait Implementations§
Source§impl<C: Clone> Clone for ComplianceService<C>
impl<C: Clone> Clone for ComplianceService<C>
Source§fn clone(&self) -> ComplianceService<C>
fn clone(&self) -> ComplianceService<C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<C: Debug> Debug for ComplianceService<C>
impl<C: Debug> Debug for ComplianceService<C>
Source§impl Default for ComplianceService
impl Default for ComplianceService
Source§impl Service<ComplianceRequest> for ComplianceService<ConsentService>
impl Service<ComplianceRequest> for ComplianceService<ConsentService>
Source§type Response = ComplianceResponse
type Response = ComplianceResponse
Responses given by the service.
Source§type Error = TraceabilityError
type Error = TraceabilityError
Errors produced by the service.
Source§type Future = Pin<Box<dyn Future<Output = Result<<ComplianceService as Service<ComplianceRequest>>::Response, <ComplianceService as Service<ComplianceRequest>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<ComplianceService as Service<ComplianceRequest>>::Response, <ComplianceService as Service<ComplianceRequest>>::Error>> + Send>>
The future response value.
Source§fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Returns
Poll::Ready(Ok(()))
when the service is able to process requests. Read moreSource§fn call(&mut self, request: ComplianceRequest) -> Self::Future
fn call(&mut self, request: ComplianceRequest) -> Self::Future
Process the request and return the response asynchronously. Read more
Auto Trait Implementations§
impl<C> Freeze for ComplianceService<C>where
C: Freeze,
impl<C = ConsentService> !RefUnwindSafe for ComplianceService<C>
impl<C> Send for ComplianceService<C>where
C: Send,
impl<C> Sync for ComplianceService<C>where
C: Sync,
impl<C> Unpin for ComplianceService<C>where
C: Unpin,
impl<C = ConsentService> !UnwindSafe for ComplianceService<C>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered
].§impl<T> Pointable for T
impl<T> Pointable for T
§impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
§fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
Convert this service into a
MakeService
, that is a [Service
] whose
response is another service. Read more§fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
Convert this service into a
HandleError
, that will handle errors
by converting them into responses. Read more§impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
Yields a mutable reference to the service when it is ready to accept a request.
§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
Yields the service when it is ready to accept a request.
§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Consume this
Service
, calling it with the provided request once it is ready.§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
Executes a new future after this service’s future resolves. This does
not alter the behaviour of the
poll_ready
method. Read more§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
Maps this service’s response value to a different value. This does not
alter the behaviour of the
poll_ready
method. Read more§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
Maps this service’s error value to a different value. This does not
alter the behaviour of the
poll_ready
method. Read more§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Maps this service’s result type (
Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read more§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
Composes a function in front of the service. Read more
§fn filter<F, NewRequest>(self, filter: F) -> Filter<Self, F>where
Self: Sized,
F: Predicate<NewRequest>,
fn filter<F, NewRequest>(self, filter: F) -> Filter<Self, F>where
Self: Sized,
F: Predicate<NewRequest>,
§fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where
Self: Sized,
F: AsyncPredicate<NewRequest>,
Composes this service with an
AsyncFilter
that conditionally accepts or
rejects requests based on an [async predicate]. Read more§fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
Composes an asynchronous function after this service. Read more
§fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
Composes a function that transforms futures produced by the service. Read more