pub struct StatefulResponseHandler { /* private fields */ }Expand description
Stateful response handler
Implementations§
Source§impl StatefulResponseHandler
impl StatefulResponseHandler
Sourcepub async fn add_config(&self, path_pattern: String, config: StatefulConfig)
pub async fn add_config(&self, path_pattern: String, config: StatefulConfig)
Add a stateful configuration for a path
Sourcepub async fn can_handle(&self, _method: &Method, path: &str) -> bool
pub async fn can_handle(&self, _method: &Method, path: &str) -> bool
Check if this handler can process the request
Sourcepub async fn process_request(
&self,
method: &Method,
uri: &Uri,
headers: &HeaderMap,
body: Option<&[u8]>,
) -> Result<Option<StatefulResponse>>
pub async fn process_request( &self, method: &Method, uri: &Uri, headers: &HeaderMap, body: Option<&[u8]>, ) -> Result<Option<StatefulResponse>>
Process a request and return stateful response if applicable
Sourcepub async fn process_stub_state(
&self,
method: &Method,
uri: &Uri,
headers: &HeaderMap,
body: Option<&[u8]>,
resource_type: &str,
resource_id_extract: &ResourceIdExtract,
initial_state: &str,
transitions: Option<&[TransitionTrigger]>,
) -> Result<Option<StateInfo>>
pub async fn process_stub_state( &self, method: &Method, uri: &Uri, headers: &HeaderMap, body: Option<&[u8]>, resource_type: &str, resource_id_extract: &ResourceIdExtract, initial_state: &str, transitions: Option<&[TransitionTrigger]>, ) -> Result<Option<StateInfo>>
Process a stub with state machine configuration
This method extracts resource ID, manages state, and returns state information that can be used to select or modify stub responses based on current state.
Returns:
Ok(Some(StateInfo))if state machine config exists and state was processedOk(None)if no state machine config or state processing not applicableErrif there was an error processing state
Auto Trait Implementations§
impl Freeze for StatefulResponseHandler
impl !RefUnwindSafe for StatefulResponseHandler
impl Send for StatefulResponseHandler
impl Sync for StatefulResponseHandler
impl Unpin for StatefulResponseHandler
impl !UnwindSafe for StatefulResponseHandler
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