Skip to main content

MockBridgeService

Struct MockBridgeService 

Source
pub struct MockBridgeService {
Show 30 fields pub read_response: ReadResponse, pub write_response: WriteResponse, pub browse_response: BrowsePage, pub browse_continuation_response: Option<BrowsePage>, pub list_servers_response: ListServersResponse, pub capabilities_response: GetCapabilitiesResponse, pub gateway_info_response: GetGatewayInfoResponse, pub search_events: Vec<SearchEvent>, pub search_index_status_response: SearchIndexStatus, pub search_index_response: SearchIndexResponse, pub search_error: Option<Status>, pub fail_read_from_call: Option<u32>, pub read_calls: Arc<AtomicU32>, pub write_calls: Arc<AtomicU32>, pub close_browse_session_calls: Arc<AtomicU32>, pub list_servers_error: Option<Status>, pub browse_error: Option<Status>, pub capabilities_error: Option<Status>, pub gateway_info_error: Option<Status>, pub search_index_status_requests: Arc<Mutex<Vec<GetSearchIndexStatusRequest>>>, pub search_index_status_error: Option<Status>, pub search_index_requests: Arc<Mutex<Vec<SearchIndexRequest>>>, pub search_index_error: Option<Status>, pub refresh_search_index_requests: Arc<Mutex<Vec<RefreshSearchIndexRequest>>>, pub refresh_search_index_error: Option<Status>, pub control_search_index_requests: Arc<Mutex<Vec<ControlSearchIndexRequest>>>, pub control_search_index_error: Option<Status>, pub read_error: Option<Status>, pub write_error: Option<Status>, pub close_error: Option<Status>,
}
Expand description

Configurable mock Bridge service.

Every field is public so a test can set one value and fill the rest with ..Default::default(). Counters and request logs are shared Arcs so a test can observe them after the service has moved into the server task.

Fields§

§read_response: ReadResponse

Returned by read unless Self::read_error or Self::fail_read_from_call fires. A single value whose tag_id is ignored is cloned once per requested tag id.

§write_response: WriteResponse

Returned by write unless Self::write_error is set. success: false is a rejected write, not an RPC error.

§browse_response: BrowsePage

Returned by browse when the request has no page token, and as the fallback when a continuation page was not configured.

§browse_continuation_response: Option<BrowsePage>

Returned by browse when the request carries a page token.

§list_servers_response: ListServersResponse

Returned by list_servers unless Self::list_servers_error is set.

§capabilities_response: GetCapabilitiesResponse

Returned by get_capabilities unless Self::capabilities_error is set.

§gateway_info_response: GetGatewayInfoResponse

Returned by get_gateway_info unless Self::gateway_info_error is set.

§search_events: Vec<SearchEvent>

Events forwarded, in order, by search.

§search_index_status_response: SearchIndexStatus

Returned by the indexed-search status, refresh, and control RPCs on success.

§search_index_response: SearchIndexResponse

Returned by search_index on success.

§search_error: Option<Status>

RPC error for search, checked before any event is sent.

§fail_read_from_call: Option<u32>

1-based read call number at which later reads fail. Earlier reads still succeed.

§read_calls: Arc<AtomicU32>

Count of read calls, including calls that then fail.

§write_calls: Arc<AtomicU32>

Count of write calls, including calls that then fail.

§close_browse_session_calls: Arc<AtomicU32>

Count of close_browse_session calls that did not return Self::close_error.

§list_servers_error: Option<Status>

RPC error for list_servers.

§browse_error: Option<Status>

RPC error for browse, checked before page-token selection.

§capabilities_error: Option<Status>

RPC error for get_capabilities.

§gateway_info_error: Option<Status>

RPC error for get_gateway_info.

§search_index_status_requests: Arc<Mutex<Vec<GetSearchIndexStatusRequest>>>

Recorded get_search_index_status requests, including calls that then fail.

§search_index_status_error: Option<Status>

RPC error for get_search_index_status, returned after the request is recorded.

§search_index_requests: Arc<Mutex<Vec<SearchIndexRequest>>>

Recorded search_index requests, including calls that then fail.

§search_index_error: Option<Status>

RPC error for search_index, returned after the request is recorded.

§refresh_search_index_requests: Arc<Mutex<Vec<RefreshSearchIndexRequest>>>

Recorded refresh_search_index requests, including calls that then fail.

§refresh_search_index_error: Option<Status>

RPC error for refresh_search_index, returned after the request is recorded.

§control_search_index_requests: Arc<Mutex<Vec<ControlSearchIndexRequest>>>

Recorded control_search_index requests, including calls that then fail.

§control_search_index_error: Option<Status>

RPC error for control_search_index, returned after the request is recorded.

§read_error: Option<Status>

RPC error for read. Checked before Self::fail_read_from_call, so both can be set.

§write_error: Option<Status>

RPC error for write. Distinct from a success: false Self::write_response.

§close_error: Option<Status>

RPC error for close_browse_session. A failed close is not counted.

Implementations§

Source§

impl MockBridgeService

Source

pub fn failing_read_from_call(self, n: u32) -> Self

Fails read on the 1-based call n and every call after it.

Trait Implementations§

Source§

impl Bridge for MockBridgeService

Source§

type SearchStream = ReceiverStream<Result<SearchEvent, Status>>

Server streaming response type for the Search method.
Source§

fn get_gateway_info<'life0, 'async_trait>( &'life0 self, _request: Request<GetGatewayInfoRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<GetGatewayInfoResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_capabilities<'life0, 'async_trait>( &'life0 self, _request: Request<GetCapabilitiesRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<GetCapabilitiesResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list_servers<'life0, 'async_trait>( &'life0 self, _request: Request<ListServersRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<ListServersResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn browse<'life0, 'async_trait>( &'life0 self, request: Request<BrowseRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<BrowsePage>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn close_browse_session<'life0, 'async_trait>( &'life0 self, _request: Request<CloseBrowseSessionRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<()>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn search<'life0, 'async_trait>( &'life0 self, _request: Request<SearchRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<Self::SearchStream>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn get_search_index_status<'life0, 'async_trait>( &'life0 self, request: Request<GetSearchIndexStatusRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<SearchIndexStatus>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn refresh_search_index<'life0, 'async_trait>( &'life0 self, request: Request<RefreshSearchIndexRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<SearchIndexStatus>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn control_search_index<'life0, 'async_trait>( &'life0 self, request: Request<ControlSearchIndexRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<SearchIndexStatus>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn search_index<'life0, 'async_trait>( &'life0 self, request: Request<SearchIndexRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<SearchIndexResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn read<'life0, 'async_trait>( &'life0 self, request: Request<ReadRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<ReadResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn write<'life0, 'async_trait>( &'life0 self, _request: Request<WriteRequest>, ) -> Pin<Box<dyn Future<Output = Result<Response<WriteResponse>, Status>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl Clone for MockBridgeService

Source§

fn clone(&self) -> MockBridgeService

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for MockBridgeService

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

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].
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more