Struct gix_transport::client::git::Connection

source ·
pub struct Connection<R, W> { /* private fields */ }
Available on crate features blocking-client or async-client only.
Expand description

A TCP connection to either a git daemon or a spawned git process.

When connecting to a daemon, additional context information is sent with the first line of the handshake. Otherwise that context is passed using command line arguments to a spawned git process.

Implementations§

source§

impl<R, W> Connection<R, W>
where R: Read, W: Write,

source

pub fn new( read: R, write: W, desired_version: Protocol, repository_path: impl Into<BString>, virtual_host: Option<(impl Into<String>, Option<u16>)>, mode: ConnectMode, trace: bool, ) -> Self

Available on crate feature blocking-client only.

Create a connection from the given read and write, asking for desired_version as preferred protocol and the transfer of the repository at repository_path.

virtual_host along with a port to which to connect to, while mode determines the kind of endpoint to connect to. If trace is true, all packetlines received or sent will be passed to the facilities of the gix-trace crate.

source§

impl<R, W> Connection<R, W>

source

pub fn into_inner(self) -> (R, W)

Return the inner reader and writer

source

pub fn custom_url(self, url: Option<BString>) -> Self

Optionally set the URL to be returned when asked for it if Some or calculate a default for None.

The URL is required as parameter for authentication helpers which are called in transports that support authentication. Even though plain git transports don’t support that, this may well be the case in custom transports.

Trait Implementations§

source§

impl<R, W> Transport for Connection<R, W>
where R: Read, W: Write,

Available on crate feature blocking-client only.
source§

fn handshake<'a>( &mut self, service: Service, extra_parameters: &'a [(&'a str, Option<&'a str>)], ) -> Result<SetServiceResponse<'_>, Error>

Initiate connection to the given service and send the given extra_parameters along with it. Read more
source§

impl<R, W> TransportWithoutIO for Connection<R, W>
where R: Read, W: Write,

Available on crate feature blocking-client only.
source§

fn request( &mut self, write_mode: WriteMode, on_into_read: MessageKind, trace: bool, ) -> Result<RequestWriter<'_>, Error>

Get a writer for sending data and obtaining the response. It can be configured in various ways to support the task at hand. write_mode determines how calls to the write(…) method are interpreted, and on_into_read determines which message to write when the writer is turned into the response reader using into_read(). If trace is true, then all packetlines written and received will be traced using facilities provided by the gix_trace crate.
source§

fn to_url(&self) -> Cow<'_, BStr>

Returns the canonical URL pointing to the destination of this transport.
source§

fn connection_persists_across_multiple_requests(&self) -> bool

Returns true if the transport provides persistent connections across multiple requests, or false otherwise. Not being persistent implies that certain information has to be resent on each ‘turn’ of the fetch negotiation or that the end of interaction (i.e. no further request will be made) has to be indicated to the server for most graceful termination of the connection.
source§

fn configure( &mut self, _config: &dyn Any, ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>

Pass config can be cast and interpreted by the implementation, as documented separately. Read more
source§

fn set_identity(&mut self, _identity: Account) -> Result<(), Error>

If the handshake or subsequent reads failed with std::io::ErrorKind::PermissionDenied, use this method to inform the transport layer about the identity to use for subsequent calls. If authentication continues to fail even with an identity set, consider communicating this to the provider of the identity in order to mark it as invalid. Otherwise the user might have difficulty updating obsolete credentials. Please note that most transport layers are unauthenticated and thus return an error here.
source§

fn supported_protocol_versions(&self) -> &[Protocol]

If the actually advertised server version is contained in the returned slice or it is empty, continue as normal, assume the server’s protocol version is desired or acceptable. Read more

Auto Trait Implementations§

§

impl<R, W> Freeze for Connection<R, W>
where W: Freeze, R: Freeze,

§

impl<R, W> RefUnwindSafe for Connection<R, W>

§

impl<R, W> Send for Connection<R, W>
where W: Send, R: Send,

§

impl<R, W> Sync for Connection<R, W>
where W: Sync, R: Sync,

§

impl<R, W> Unpin for Connection<R, W>
where W: Unpin, R: Unpin,

§

impl<R, W> UnwindSafe for Connection<R, W>
where W: UnwindSafe, R: UnwindSafe,

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> TransportV2Ext for T
where T: Transport,

source§

fn invoke<'a>( &mut self, command: &str, capabilities: impl Iterator<Item = (&'a str, Option<impl AsRef<str>>)> + 'a, arguments: Option<impl Iterator<Item = BString>>, trace: bool, ) -> Result<Box<dyn ExtendedBufRead<'_> + Unpin + '_>, Error>

Available on crate feature blocking-client only.
Invoke a protocol V2 style command with given capabilities and optional command specific arguments. The capabilities were communicated during the handshake. If trace is true, then all packetlines written and received will be traced using facilities provided by the gix_trace crate. Read more
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.