pub struct Transport<H: Http> { /* private fields */ }
Available on crate features
blocking-client
and http-client
only.Expand description
A transport for supporting arbitrary http clients by abstracting interactions with them into the Http trait.
Implementations§
source§impl<H: Http> Transport<H>
impl<H: Http> Transport<H>
sourcepub fn new_http(
http: H,
url: Url,
desired_version: Protocol,
trace: bool,
) -> Self
pub fn new_http( http: H, url: Url, desired_version: Protocol, trace: bool, ) -> Self
Create a new instance with http
as implementation to communicate to url
using the given desired_version
.
Note that we will always fallback to other versions as supported by the server.
If trace
is true
, all packetlines received or sent will be passed to the facilities of the gix-trace
crate.
source§impl Transport<Impl>
impl Transport<Impl>
sourcepub fn new(url: Url, desired_version: Protocol, trace: bool) -> Self
Available on crate features http-client-curl
or http-client-reqwest
only.
pub fn new(url: Url, desired_version: Protocol, trace: bool) -> Self
http-client-curl
or http-client-reqwest
only.Create a new instance to communicate to url
using the given desired_version
of the git
protocol.
If trace
is true
, all packetlines received or sent will be passed to the facilities of the gix-trace
crate.
Note that the actual implementation depends on feature toggles.
Trait Implementations§
source§impl<H: Http> TransportWithoutIO for Transport<H>
impl<H: Http> TransportWithoutIO for Transport<H>
source§fn 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.source§fn request(
&mut self,
write_mode: WriteMode,
on_into_read: MessageKind,
trace: bool,
) -> Result<RequestWriter<'_>, Error>
fn request( &mut self, write_mode: WriteMode, on_into_read: MessageKind, trace: bool, ) -> Result<RequestWriter<'_>, Error>
Available on crate features
blocking-client
or async-client
only.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>
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
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>>
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 moresource§fn supported_protocol_versions(&self) -> &[Protocol]
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<H> Freeze for Transport<H>
impl<H> RefUnwindSafe for Transport<H>
impl<H> Send for Transport<H>
impl<H> Sync for Transport<H>
impl<H> Unpin for Transport<H>
impl<H> UnwindSafe for Transport<H>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> TransportV2Ext for Twhere
T: Transport,
impl<T> TransportV2Ext for Twhere
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>
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