Struct git_transport::client::git::Connection
source · [−]pub struct Connection<R, W> { /* private fields */ }
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
sourceimpl<R, W> Connection<R, W> where
R: Read,
W: Write,
impl<R, W> Connection<R, W> where
R: Read,
W: Write,
sourcepub fn new(
read: R,
write: W,
desired_version: Protocol,
repository_path: impl Into<BString>,
virtual_host: Option<(impl Into<String>, Option<u16>)>,
mode: ConnectMode
) -> Self
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
) -> Self
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.
sourceimpl<R, W> Connection<R, W>
impl<R, W> Connection<R, W>
sourcepub fn into_inner(self) -> (R, W)
pub fn into_inner(self) -> (R, W)
Return the inner reader and writer
sourcepub fn custom_url(self, url: Option<String>) -> Self
pub fn custom_url(self, url: Option<String>) -> 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
sourceimpl<R, W> Transport for Connection<R, W> where
R: Read,
W: Write,
impl<R, W> Transport for Connection<R, W> where
R: Read,
W: Write,
sourceimpl<R, W> TransportWithoutIO for Connection<R, W> where
R: Read,
W: Write,
impl<R, W> TransportWithoutIO for Connection<R, W> where
R: Read,
W: Write,
sourcefn supported_protocol_versions(&self) -> &[Protocol]
fn supported_protocol_versions(&self) -> &[Protocol]
We implement this in a paranoid and safe way, not allowing downgrade to V1 which could send large amounts of refs in case we didn’t want to support V1.
sourcefn request(
&mut self,
write_mode: WriteMode,
on_into_read: MessageKind
) -> Result<RequestWriter<'_>, Error>
fn request(
&mut self,
write_mode: WriteMode,
on_into_read: MessageKind
) -> 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()
. Read more
sourcefn to_url(&self) -> String
fn to_url(&self) -> String
Returns the canonical URL pointing to the destination of this transport. Please note that local paths may not be represented correctly, as they will go through a potentially lossy unicode conversion. Read more
sourcefn connection_persists_across_multiple_requests(&self) -> bool
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. Read more
sourcefn set_identity(&mut self, _identity: Account) -> Result<(), Error>
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. Read more
Auto Trait Implementations
impl<R, W> RefUnwindSafe for Connection<R, W> where
R: RefUnwindSafe,
W: RefUnwindSafe,
impl<R, W> Send for Connection<R, W> where
R: Send,
W: Send,
impl<R, W> Sync for Connection<R, W> where
R: Sync,
W: Sync,
impl<R, W> Unpin for Connection<R, W> where
R: Unpin,
W: Unpin,
impl<R, W> UnwindSafe for Connection<R, W> where
R: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more