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

A handle to facilitate typical server interactions that include the handshake and command-invocations.

Implementations§

source§

impl Server

source

pub fn handshake( stdin: Stdin, stdout: Stdout, welcome_prefix: &str, pick_version: &mut dyn FnMut(&[usize]) -> Option<usize>, available_capabilities: &[&str] ) -> Result<Self, Error>

Perform a handshake with the client sending information to our stdin and receiving information through our stdout in packetline format. pick_version is called with all versions supported by the client to pick one from, or None to indicate the handshake should stop. Use available_capabilities to match our capabilities with the ones from the client, so we communicate at most a subset of these.

Note

The server claims exclusive access over stdout and stdin, so all kinds of other output has to be steered towards stderr or there will be a deadlock.

source

pub fn next_request(&mut self) -> Result<Option<Request<'_>>, Error>

Read the next request and return it, even if command is not supported by us. If Ok(None) is reported, the request loop should end and the process should be shutdown gracefully.

The reason for allowing any command is that the caller would have to match on the command anyway, and would have to handle invalid commands that way.

Lifecycle

Note that the process is supposed to shut-down once there are no more requests, and git will wait until it has finished.

source§

impl Server

Access

source

pub fn capabilities(&self) -> &HashSet<String>

Return the list of capabilities we are allowed to use, as negotiated with the client.

source

pub fn version(&self) -> usize

Return the negotiated version of the protocol.

Auto Trait Implementations§

§

impl RefUnwindSafe for Server

§

impl !Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnwindSafe 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.