Struct wiremock_grpc::GrpcServer
source · [−]pub struct GrpcServer { /* private fields */ }
Expand description
A running gRPC server You do not directly create this object instead use the macro generated server to instantiate this for you.
mod mock_server {
wiremock_grpc::generate!("hello.Greeter", MyServer);
}
use mock_server::*;
MyServer
also Deref
to GrpcServer
.
Therefore you can call setup
/ find
functions on it.
Implementations
sourceimpl GrpcServer
impl GrpcServer
pub fn new(port: u16) -> Self
pub async fn find_unused_port() -> Option<u16>
pub async fn _start(&mut self, f: JoinHandle<Result<(), Error>>)
pub fn setup<M>(&mut self, r: M) -> MockBuilderwhere
M: Into<MockBuilder> + Clone + Mountable,
pub fn address(&self) -> &SocketAddr
pub fn handle_request<B>(
&self,
req: Request<B>
) -> BoxFuture<Response<BoxBody>, Never>where
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
sourceimpl GrpcServer
impl GrpcServer
sourcepub fn find(&self, r: &MockBuilder) -> Option<Vec<RequestItem>>
pub fn find(&self, r: &MockBuilder) -> Option<Vec<RequestItem>>
Finds one or more matched requests for a given request builder.
Returns
None
: when the givenMockBuilder
is not registered using thesetup()
function.- Empty Vector: when no request was made that matches the builder,
sourcepub fn find_one(&self, r: &MockBuilder) -> RequestItem
pub fn find_one(&self, r: &MockBuilder) -> RequestItem
Finds a single matched request for a given criteria
Panics
- No request matching the criteria (eg. No request receieved by the mock server)
- When more than one request matches the criteria (in this case use
GrpcServer::find
) - When the criteria is inavlid (not registered with the server using the
setup()
function),
sourcepub fn find_request_count(&self) -> u32
pub fn find_request_count(&self) -> u32
Returns number of handled requests
sourcepub fn rules_unmatched(&self) -> usize
pub fn rules_unmatched(&self) -> usize
Return number of umatched so far
Trait Implementations
sourceimpl Clone for GrpcServer
impl Clone for GrpcServer
sourcefn clone(&self) -> GrpcServer
fn clone(&self) -> GrpcServer
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for GrpcServer
impl Debug for GrpcServer
Auto Trait Implementations
impl RefUnwindSafe for GrpcServer
impl Send for GrpcServer
impl Sync for GrpcServer
impl Unpin for GrpcServer
impl UnwindSafe for GrpcServer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request