Skip to main content

EmbeddedServer

Struct EmbeddedServer 

Source
pub struct EmbeddedServer { /* private fields */ }
Expand description

A running liminal server with no listener, granting in-process connections.

Built from the same ingredients the production stack is built from — services, an optional connection auth token, and the operational limits — and torn down on drop, so an embedded server’s lifetime is its handle’s.

Implementations§

Source§

impl EmbeddedServer

Source

pub fn with_services( services: Arc<dyn ConnectionServices>, ) -> Result<Self, ServerError>

Starts an embedded server over services, open-access and at the default limits.

§Errors

Returns ServerError when incarnation startup or scheduler startup fails.

Source

pub fn with_services_auth_and_limits( services: Arc<dyn ConnectionServices>, auth_token: Option<Vec<u8>>, limits: LimitsConfig, ) -> Result<Self, ServerError>

Starts an embedded server over services, gated by auth_token when one is configured, under limits.

The three arguments are exactly the three ConnectionSupervisor::with_services_auth_and_limits takes, because an embedded server is a production stack with the listener removed and nothing else: None for the token is the open-access server an absent [auth] section produces, and limits carries the same max_connections bound that both connection admission and the durable incarnation stream enforce.

§Errors

Returns ServerError when incarnation startup or scheduler startup fails.

Source

pub fn connect_loopback(&self) -> Result<LoopbackClientEnd, ServerError>

Admits one in-process connection and returns the caller’s end of it.

This is the whole grant. It replaces exactly the listener’s accept() + spawn_connection pair and nothing else about admission: the returned end is a byte stream that has not yet handshaken, so the caller still sends Connect and still receives ConnectAck or ConnectError from the same connect_response a socket client reaches.

Dropping the returned end tears the connection down by the same end-of-file a socket hangup produces, releasing its admission slot.

§Errors

Returns ServerError::ConnectionLimitReached when the server is at its max_connections bound — the identical typed refusal a socket connect receives at capacity, surfaced as an error rather than a panic — and other ServerError values when incarnation allocation or process spawn fails. On every refusal the duplex is dropped whole, so no half of a rejected connection survives.

Trait Implementations§

Source§

impl Debug for EmbeddedServer

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Prints nothing about the server.

A Debug that rendered the supervisor would be an accessor by another name: it would put the runtime’s contents, the admission counter, and the registry into any log line that formatted this handle.

Source§

impl Drop for EmbeddedServer

Source§

fn drop(&mut self)

Stops the connection scheduler, mirroring the in-tree socket fixtures’ teardown (SdkSocketFixture::stop): every host record is removed while the readiness owner is still live, then the scheduler is shut down.

Teardown is Drop alone rather than a shutdown method plus Drop because Rust drop points are already deterministic — a caller that wants the server stopped at a particular moment drops it at that moment — and a second spelling of the same act is a second surface to keep honest.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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

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

Source§

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.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more