Skip to main content

Namespace

Struct Namespace 

Source
pub(super) struct Namespace {
    pub(super) path: PathBuf,
    linger: Duration,
    requests: Mutex<Option<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>>,
    pub(super) connect_budget: Budget,
}
Expand description

Creates the sockets of a session in its network namespace, which stay in the namespace they got created in. The runtime connects them. A thread enters the namespace and serves the connections which follow within the linger time, then it ends and leaves the namespace, at once when the session ends. Failures are not kept, every connection which fails gets its own error.

Fields§

§path: PathBuf§linger: Duration§requests: Mutex<Option<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>>

The requests of the thread which got started last.

§connect_budget: Budget

What the connections which get established hold, see CONNECT_BUDGET.

Implementations§

Source§

impl Namespace

Source

pub(super) fn new(path: PathBuf) -> Arc<Self> ⓘ

The network namespace at path, whose thread lingers for SOCKET_THREAD_LINGER.

Source

pub(super) fn with_linger(path: PathBuf, linger: Duration) -> Arc<Self> ⓘ

The network namespace at path, whose thread lingers for linger.

Source

pub(super) async fn sockets(&self) -> Result<Vec<(IpAddr, Result<TcpStream>)>>

New sockets in the namespace from its thread, which gets started if it ended.

Source

fn send( &self, reply: Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>, ) -> Result<()>

Send a request to the thread, which gets started if it ended.

Source

fn lock( &self, ) -> MutexGuard<'_, Option<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>>

Source

fn start( &self, ) -> Result<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>

Source

fn serve( path: &Path, linger: Duration, requests: &Receiver<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>, )

Create sockets until no request arrived for the linger time or the session is gone. The thread enters the namespace for its first request, a request which finds it outside of the namespace tries again and gets its own error.

Source

fn enter(path: &Path) -> Result<()>

Enter the network namespace with the current thread.

Source

fn create_sockets() -> Vec<(IpAddr, Result<TcpStream>)>

A socket of each family, for one connection. The IPv6 one is only needed if IPv4 fails, creating it right away costs less than another round trip into the namespace thread.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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