Struct gix_transport::client::capabilities::Capabilities
source · pub struct Capabilities { /* private fields */ }
Expand description
A structure to represent multiple capabilities or features supported by the server.
§Deviation
As a shortcoming, we are unable to parse V1
as emitted from git-upload-pack
without a git-daemon
or server,
as it will not emit any capabilities for some reason. Only V2
and V0
work in that context.
Implementations§
source§impl Capabilities
impl Capabilities
sourcepub fn from_lines_with_version_detection<T: Read>(
rd: &mut StreamingPeekableIter<T>
) -> Result<Outcome<'_>, Error>
Available on crate feature blocking-client
only.
pub fn from_lines_with_version_detection<T: Read>( rd: &mut StreamingPeekableIter<T> ) -> Result<Outcome<'_>, Error>
blocking-client
only.Read the capabilities and version advertisement from the given packetline reader.
If Protocol::V1
was requested, or the remote decided to downgrade, the remote refs
advertisement will also be included in the Outcome
.
source§impl Capabilities
impl Capabilities
sourcepub fn from_bytes(bytes: &[u8]) -> Result<(Capabilities, usize), Error>
pub fn from_bytes(bytes: &[u8]) -> Result<(Capabilities, usize), Error>
Parse capabilities from the given bytes
.
Useful in case they are encoded within a ref
behind a null byte.
sourcepub fn from_lines(lines_buf: BString) -> Result<Capabilities, Error>
pub fn from_lines(lines_buf: BString) -> Result<Capabilities, Error>
Parse capabilities from the given a lines_buf
which is expected to be all newline separated lines
from the server.
Useful for parsing capabilities from a data sent from a server, and to avoid having to deal with blocking and async traits for as long as possible. There is no value in parsing a few bytes in a non-blocking fashion.
sourcepub fn contains(&self, feature: &str) -> bool
pub fn contains(&self, feature: &str) -> bool
Returns true of the given feature
is mentioned in this list of capabilities.
sourcepub fn capability(&self, name: &str) -> Option<Capability<'_>>
pub fn capability(&self, name: &str) -> Option<Capability<'_>>
Returns the capability with name
.
sourcepub fn iter(&self) -> impl Iterator<Item = Capability<'_>>
pub fn iter(&self) -> impl Iterator<Item = Capability<'_>>
Returns an iterator over all capabilities.
Trait Implementations§
source§impl Clone for Capabilities
impl Clone for Capabilities
source§fn clone(&self) -> Capabilities
fn clone(&self) -> Capabilities
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Capabilities
impl Debug for Capabilities
source§impl Default for Capabilities
impl Default for Capabilities
This implementation yields exactly those minimal capabilities that are required for gix
to work, nothing more and nothing less.
This is a bit of a hack just get tests with Protocol V0 to work, which is a good way to enforce stateful transports.
Of course, V1 would also do that but when calling git-upload-pack
directly, it advertises so badly that this is easier to implement.