Struct gix_filter::driver::process::Server
source · 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
impl Server
sourcepub fn handshake(
stdin: Stdin,
stdout: Stdout,
welcome_prefix: &str,
pick_version: &mut dyn FnMut(&[usize]) -> Option<usize>,
available_capabilities: &[&str],
) -> Result<Self, Error>
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.
sourcepub fn next_request(&mut self) -> Result<Option<Request<'_>>, Error>
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.