Skip to main content

Server

Struct Server 

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

VFS agent server.

Construct a connected server with new or new_split and call serve. On Unix, bind constructs a listener that accepts sessions until a client requests shutdown.

Implementations§

Source§

impl Server

Source

pub async fn new<T>(stream: T) -> Result<Self>
where T: AsyncRead + AsyncWrite + Unpin + Send + 'static,

Creates an opaque-only VFS server over a bidirectional byte stream.

Source

pub async fn new_split<R, W>(reader: R, writer: W) -> Result<Self>
where R: AsyncRead + Send + 'static, W: AsyncWrite + Send + 'static,

Creates an opaque-only VFS server on separate reader and writer streams.

Source

pub async fn bind(path: impl AsRef<Path>) -> Result<Self>

Available on Unix only.

Binds a Unix-domain listener for VFS agent connections.

Source

pub async fn bind_with_key( path: impl AsRef<Path>, key: Option<AuthKey>, ) -> Result<Self>

Available on Unix only.

Binds a Unix-domain listener that requires mutual proof of a pre-shared key from every connection.

The socket’s permissions cannot distinguish the intended client when the peer’s uid is not knowable in advance; key is what does. A connection that fails the check is dropped during negotiation, before it can issue any request.

Source

pub async fn from_named_pipe_client(pipe: NamedPipeClient) -> Result<Self>

Available on Windows only.

Creates a VFS RPC server on the client end of a connected Windows named pipe.

Source

pub async fn accept(self) -> Result<()>

Available on Unix only.

Accepts connections until a client requests server shutdown.

Each connection runs in an independent handler task. Routine client disconnects are ignored; unexpected handler failures are reported to standard error.

Source

pub async fn accept_one<F>(self, established: F) -> Result<()>
where F: FnOnce(),

Available on Unix only.

Accepts connections until one completes negotiation, then serves that session alone.

established runs once, as soon as some connection has negotiated successfully — the point at which the listening socket has done its job and the caller can unlink it. Nothing is accepted afterwards.

Connections that fail to negotiate (including failing authentication) are dropped and do not consume the single slot, so an impostor that reaches the socket first cannot deny the intended client its session; it can only waste an attempt. Negotiation has a timeout and a fixed limit on in-flight attempts, so a peer that connects and then says nothing cannot stall or crowd out the real one either.

Source

pub async fn serve(self) -> Result<()>

Serves one connected VFS session until it closes or fails.

Auto Trait Implementations§

§

impl !Freeze for Server

§

impl !RefUnwindSafe for Server

§

impl !Sync for Server

§

impl !UnwindSafe for Server

§

impl Send for Server

§

impl Unpin for Server

§

impl UnsafeUnpin for Server

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.