Skip to main content

SyncServer

Struct SyncServer 

Source
pub struct SyncServer<T: SyncTransport> { /* private fields */ }
Expand description

Synchronous single-connection server with path-based service registration.

Implementations§

Source§

impl<T: SyncTransport + 'static> SyncServer<T>

Source

pub fn new(transport: T) -> Result<Self, Status>

Creates a server with bounded default HTTP/2 session settings.

§Errors

Returns invalid settings or native initialization failures.

Source

pub fn with_config(transport: T, config: SessionConfig) -> Result<Self, Status>

Creates a connection with explicit HTTP/2 and message limits.

§Errors

Returns invalid settings or native initialization failures.

Source

pub fn register_unary<C, Req, Resp, F>( &mut self, path: &str, codec: C, handler: F, ) -> Result<(), Status>
where C: Codec<EncodeItem = Resp, DecodeItem = Req> + 'static, Req: 'static, Resp: 'static, F: FnMut(Request<Req>) -> Result<Response<Resp>, Status> + 'static,

Registers a unary handler with exactly one inbound and outbound message.

§Errors

Rejects invalid paths or duplicate registrations.

Source

pub fn register_server_streaming<C, Req, Resp, F>( &mut self, path: &str, codec: C, handler: F, ) -> Result<(), Status>
where C: Codec<EncodeItem = Resp, DecodeItem = Req> + 'static, Req: 'static, Resp: 'static, F: FnMut(Request<Req>, &mut ResponseSink<Resp>) -> Result<(), Status> + 'static,

Registers a single-request streaming-response handler. The server sends OK trailers if the handler has not already finished its sink.

§Errors

Rejects invalid paths or duplicate registrations.

Source

pub fn register_client_streaming<C, Req, Resp, F>( &mut self, path: &str, codec: C, handler: F, ) -> Result<(), Status>
where C: Codec<EncodeItem = Resp, DecodeItem = Req> + 'static, Req: 'static, Resp: 'static, F: FnMut(RequestStream<Req>) -> Result<Response<Resp>, Status> + 'static,

Registers a streaming-request handler returning exactly one response.

§Errors

Rejects invalid paths or duplicate registrations.

Source

pub fn register_bidi_streaming<C, Req, Resp, F>( &mut self, path: &str, codec: C, handler: F, ) -> Result<(), Status>
where C: Codec<EncodeItem = Resp, DecodeItem = Req> + 'static, Req: 'static, Resp: 'static, F: FnMut(RequestStream<Req>, &mut ResponseSink<Resp>) -> Result<(), Status> + 'static,

Registers a bidirectional streaming handler.

§Errors

Rejects invalid paths or duplicate registrations.

Source

pub fn register_service_handler<H: ServiceHandler + 'static>( &mut self, path: &str, handler: H, ) -> Result<(), Status>

Registers a raw-payload dispatcher, including generated-service adapters.

§Errors

Rejects invalid paths or duplicate registrations.

Source

pub fn poll_once(&mut self) -> Result<bool, Status>

Advances nonblocking socket I/O and dispatches at most one synchronous handler. A dispatched handler may wait for its request body on the calling thread.

§Errors

Returns native HTTP/2 or transport failures.

Source

pub fn serve_connection(&mut self) -> Result<(), Status>

Serves until peer EOF or local graceful shutdown.

§Errors

Returns connection-level HTTP/2, transport or handler completion failures.

Source

pub fn shutdown_with_goaway(&mut self, error_code: u32) -> Result<(), Status>

Queues GOAWAY and attempts a nonblocking flush. Continue polling or serving to drain accepted requests and pending output.

§Errors

Returns HTTP/2 submission or transport failures.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for SyncServer<T>

§

impl<T> !Send for SyncServer<T>

§

impl<T> !Sync for SyncServer<T>

§

impl<T> !UnwindSafe for SyncServer<T>

§

impl<T> Freeze for SyncServer<T>
where Rc<RefCell<ServerInner<T>>>: Freeze, BTreeMap<String, Box<dyn FnMut(IncomingRequest, Rc<RefCell<ServerInner<T>>>) -> Result<(), Status>>>: Freeze,

§

impl<T> Unpin for SyncServer<T>
where Rc<RefCell<ServerInner<T>>>: Unpin, BTreeMap<String, Box<dyn FnMut(IncomingRequest, Rc<RefCell<ServerInner<T>>>) -> Result<(), Status>>>: Unpin,

§

impl<T> UnsafeUnpin for SyncServer<T>
where Rc<RefCell<ServerInner<T>>>: UnsafeUnpin, BTreeMap<String, Box<dyn FnMut(IncomingRequest, Rc<RefCell<ServerInner<T>>>) -> Result<(), Status>>>: UnsafeUnpin,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.