pub struct Channel { /* private fields */ }
Expand description
A gRPC channel.
Channels are an abstraction of long-lived connections to remote servers. More client objects can reuse the same channel.
Use ChannelBuilder
to build a Channel
.
Implementations
sourceimpl Channel
impl Channel
sourcepub unsafe fn new(
cq: CompletionQueue,
env: Arc<Environment>,
channel: *mut grpc_channel
) -> Channel
pub unsafe fn new(
cq: CompletionQueue,
env: Arc<Environment>,
channel: *mut grpc_channel
) -> Channel
Create a new channel. Avoid using this directly and use
ChannelBuilder
to build a Channel
instead.
Safety
The given grpc_channel must correspond to an instantiated grpc core channel. Takes exclusive ownership of the channel and will close it after use.
sourcepub fn check_connectivity_state(
&self,
try_to_connect: bool
) -> ConnectivityState
pub fn check_connectivity_state(
&self,
try_to_connect: bool
) -> ConnectivityState
If try_to_connect is true, the channel will try to establish a connection, potentially changing the state.
sourcepub fn wait_for_state_change(
&self,
last_observed: ConnectivityState,
deadline: impl Into<Deadline>
) -> impl Future<Output = bool>
pub fn wait_for_state_change(
&self,
last_observed: ConnectivityState,
deadline: impl Into<Deadline>
) -> impl Future<Output = bool>
Blocking wait for channel state change or deadline expiration.
check_connectivity_state
needs to be called to get the current state. Returns false
means deadline excceeds before observing any state changes.
sourcepub async fn wait_for_connected(&self, deadline: impl Into<Deadline>) -> bool
pub async fn wait_for_connected(&self, deadline: impl Into<Deadline>) -> bool
Wait for this channel to be connected.
Returns false means deadline excceeds before connection is connected.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more