Skip to main content

SyncChannel

Struct SyncChannel 

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

Shared, single-threaded connection. Clones share one HTTP/2 session.

Connections stay on their owning OS thread.

ⓘ
use grpc::{SyncChannel, core::transport::MemoryPipe};
fn require_send<T: Send>() {}
require_send::<SyncChannel<MemoryPipe>>();
ⓘ
use grpc::{SyncChannel, core::transport::MemoryPipe};
fn require_sync<T: Sync>() {}
require_sync::<SyncChannel<MemoryPipe>>();

Implementations§

Source§

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

Source

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

Creates a channel using standard connection defaults.

§Errors

Returns invalid configuration or transport/session initialization failures.

Source

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

Creates a nonblocking session; blocking RPC methods wait on the caller thread.

§Errors

Returns invalid authority/scheme, transport or session initialization errors.

Source

pub fn unary<C, Req, Resp>( &mut self, path: &str, req: &Req, codec: &mut C, options: CallOptions, ) -> Result<(Resp, Metadata, Metadata), Status>
where C: Codec<EncodeItem = Req, DecodeItem = Resp>,

Performs a unary RPC, returning its response and both metadata collections.

A mutable codec also supports stateful serializers and generated service adapters.

§Errors

Returns transport, codec, deadline, remote status or response cardinality errors.

Source

pub fn call_unary<C, Req, Resp>( &mut self, path: &str, req: &Req, codec: &mut C, ) -> Result<Resp, Status>
where C: Codec<EncodeItem = Req, DecodeItem = Resp>,

Performs a unary call with default call options.

§Errors

Returns the same failures as Self::unary.

Source

pub fn server_streaming<C, Req, Resp>( &mut self, path: &str, req: &Req, codec: C, options: CallOptions, ) -> Result<ServerStreamingCall<Resp>, Status>
where C: Codec<EncodeItem = Req, DecodeItem = Resp> + 'static, Req: 'static, Resp: 'static,

Starts one request followed by a response stream.

§Errors

Returns setup, encoding or request submission failures.

Source

pub fn client_streaming<C, Req, Resp>( &mut self, path: &str, codec: C, options: CallOptions, ) -> Result<ClientStreamingCall<Req, Resp>, Status>
where C: Codec<EncodeItem = Req, DecodeItem = Resp> + 'static, Req: 'static, Resp: 'static,

Starts a request stream with one terminal response.

§Errors

Returns invalid options or session submission failures.

Source

pub fn bidi_streaming<C, Req, Resp>( &mut self, path: &str, codec: C, options: CallOptions, ) -> Result<BidiStreamingCall<Req, Resp>, Status>
where C: Codec<EncodeItem = Req, DecodeItem = Resp> + 'static, Req: 'static, Resp: 'static,

Starts independent request and response streams.

§Errors

Returns invalid options or session submission failures.

Source§

impl SyncChannel<TcpTransport>

Source

pub fn connect(address: impl ToSocketAddrs) -> Result<Self, Status>

Connects a TCP channel with authority derived from the peer address.

§Errors

Returns connection, address or session initialization errors.

Source

pub fn connect_tls( address: impl ToSocketAddrs, config: &TlsClientConfig, server_name: &str, ) -> Result<SyncChannel<impl SyncTransport + 'static>, Status>

Connects and verifies an HTTP/2 TLS session before creating the channel.

§Errors

Returns invalid server name, TCP, certificate, ALPN or handshake errors.

Source§

impl SyncChannel<UnixTransport>

Source

pub fn connect_unix(path: impl AsRef<Path>) -> Result<Self, Status>

Connects a Unix-domain channel.

§Errors

Returns socket connection or session initialization errors.

Trait Implementations§

Source§

impl<T: SyncTransport> Clone for SyncChannel<T>

Source§

fn clone(&self) -> Self

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

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for SyncChannel<T>

§

impl<T> !Send for SyncChannel<T>

§

impl<T> !Sync for SyncChannel<T>

§

impl<T> !UnwindSafe for SyncChannel<T>

§

impl<T> Freeze for SyncChannel<T>
where Rc<RefCell<ChannelInner<T>>>: Freeze,

§

impl<T> Unpin for SyncChannel<T>
where Rc<RefCell<ChannelInner<T>>>: Unpin,

§

impl<T> UnsafeUnpin for SyncChannel<T>
where Rc<RefCell<ChannelInner<T>>>: 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> 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.

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> 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 = !

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.