Trait gix_transport::client::TransportWithoutIO
source · pub trait TransportWithoutIO {
// Required methods
fn request(
&mut self,
write_mode: WriteMode,
on_into_read: MessageKind,
trace: bool
) -> Result<RequestWriter<'_>, Error>;
fn to_url(&self) -> Cow<'_, BStr>;
fn connection_persists_across_multiple_requests(&self) -> bool;
fn configure(
&mut self,
config: &dyn Any
) -> Result<(), Box<dyn Error + Send + Sync + 'static>>;
// Provided methods
fn set_identity(&mut self, _identity: Account) -> Result<(), Error> { ... }
fn supported_protocol_versions(&self) -> &[Protocol] { ... }
}
Expand description
This trait represents all transport related functions that don’t require any input/output to be done which helps implementation to share more code across blocking and async programs.
Required Methods§
sourcefn 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.
fn request( &mut self, write_mode: WriteMode, on_into_read: MessageKind, trace: bool ) -> Result<RequestWriter<'_>, Error>
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.
sourcefn to_url(&self) -> Cow<'_, BStr>
fn to_url(&self) -> Cow<'_, BStr>
Returns the canonical URL pointing to the destination of this transport.
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.
Provided Methods§
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.
sourcefn 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.
Otherwise, abort the fetch operation with an error to avoid continuing any interaction with the transport.
In V1 this means a potentially large list of advertised refs won’t be read, instead the connection is ignored leaving the server with a client who potentially unexpectedly terminated the connection.
Note that transport.close()
is not called explicitly.
Custom transports can override this to prevent any use of older protocol versions.
Implementations on Foreign Types§
source§impl<T: TransportWithoutIO + ?Sized> TransportWithoutIO for &mut T
impl<T: TransportWithoutIO + ?Sized> TransportWithoutIO for &mut T
fn set_identity(&mut self, identity: Account) -> Result<(), Error>
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>
blocking-client
or async-client
only.fn to_url(&self) -> Cow<'_, BStr>
fn supported_protocol_versions(&self) -> &[Protocol]
fn connection_persists_across_multiple_requests(&self) -> bool
fn configure( &mut self, config: &dyn Any ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>
source§impl<T: TransportWithoutIO + ?Sized> TransportWithoutIO for Box<T>
impl<T: TransportWithoutIO + ?Sized> TransportWithoutIO for Box<T>
fn set_identity(&mut self, identity: Account) -> Result<(), Error>
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>
blocking-client
or async-client
only.fn to_url(&self) -> Cow<'_, BStr>
fn supported_protocol_versions(&self) -> &[Protocol]
fn connection_persists_across_multiple_requests(&self) -> bool
fn configure( &mut self, config: &dyn Any ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>
Implementors§
impl TransportWithoutIO for SpawnProcessOnDemand
blocking-client
only.impl<H: Http> TransportWithoutIO for Transport<H>
http-client
and blocking-client
only.impl<R, W> TransportWithoutIO for Connection<R, W>
blocking-client
and (crate features blocking-client
or async-client
) only.