pub struct SmartProtocol<R, A>where
R: RepositoryAccess,
A: AuthenticationService,{
pub transport_protocol: TransportProtocol,
pub capabilities: Vec<Capability>,
pub side_band: Option<SideBand>,
pub command_list: Vec<RefCommand>,
pub wire_hash_kind: HashKind,
pub local_hash_kind: HashKind,
pub zero_id: String,
/* private fields */
}Expand description
Smart Git Protocol implementation
This struct handles the Git smart protocol operations for both HTTP and SSH transports. It uses trait abstractions to decouple from specific business logic implementations.
Fields§
§transport_protocol: TransportProtocol§capabilities: Vec<Capability>§side_band: Option<SideBand>§command_list: Vec<RefCommand>§wire_hash_kind: HashKind§local_hash_kind: HashKind§zero_id: StringImplementations§
Source§impl<R, A> SmartProtocol<R, A>where
R: RepositoryAccess,
A: AuthenticationService,
impl<R, A> SmartProtocol<R, A>where
R: RepositoryAccess,
A: AuthenticationService,
pub fn set_wire_hash_kind(&mut self, kind: HashKind)
Sourcepub fn new(
transport_protocol: TransportProtocol,
repo_storage: R,
auth_service: A,
) -> Self
pub fn new( transport_protocol: TransportProtocol, repo_storage: R, auth_service: A, ) -> Self
Create a new SmartProtocol instance
Sourcepub async fn authenticate_http(
&self,
headers: &HashMap<String, String>,
) -> Result<(), ProtocolError>
pub async fn authenticate_http( &self, headers: &HashMap<String, String>, ) -> Result<(), ProtocolError>
Authenticate an HTTP request using the injected auth service
Sourcepub async fn authenticate_ssh(
&self,
username: &str,
public_key: &[u8],
) -> Result<(), ProtocolError>
pub async fn authenticate_ssh( &self, username: &str, public_key: &[u8], ) -> Result<(), ProtocolError>
Authenticate an SSH session using username and public key
Sourcepub fn set_transport_protocol(&mut self, protocol: TransportProtocol)
pub fn set_transport_protocol(&mut self, protocol: TransportProtocol)
Set transport protocol (Http, Ssh, etc.)
Sourcepub async fn git_info_refs(
&self,
service_type: ServiceType,
) -> Result<BytesMut, ProtocolError>
pub async fn git_info_refs( &self, service_type: ServiceType, ) -> Result<BytesMut, ProtocolError>
Get git info refs for the repository, with explicit service type
Sourcepub async fn git_upload_pack(
&mut self,
upload_request: Bytes,
) -> Result<(ReceiverStream<Vec<u8>>, BytesMut), ProtocolError>
pub async fn git_upload_pack( &mut self, upload_request: Bytes, ) -> Result<(ReceiverStream<Vec<u8>>, BytesMut), ProtocolError>
Handle git-upload-pack request
Sourcepub fn parse_receive_pack_commands(&mut self, protocol_bytes: Bytes)
pub fn parse_receive_pack_commands(&mut self, protocol_bytes: Bytes)
Parse receive pack commands from protocol bytes
Sourcepub async fn git_receive_pack_stream(
&mut self,
data_stream: ProtocolStream,
) -> Result<Bytes, ProtocolError>
pub async fn git_receive_pack_stream( &mut self, data_stream: ProtocolStream, ) -> Result<Bytes, ProtocolError>
Handle git receive-pack operation (push)
Sourcepub fn build_side_band_format(
&self,
from_bytes: BytesMut,
length: usize,
) -> BytesMut
pub fn build_side_band_format( &self, from_bytes: BytesMut, length: usize, ) -> BytesMut
Builds the packet data in the sideband format if the SideBand/64k capability is enabled.
Sourcepub fn parse_capabilities(&mut self, cap_str: &str)
pub fn parse_capabilities(&mut self, cap_str: &str)
Parse capabilities from capability string
Sourcepub fn parse_ref_command(&self, pkt_line: &mut Bytes) -> RefCommand
pub fn parse_ref_command(&self, pkt_line: &mut Bytes) -> RefCommand
Parse a reference command from packet line
Auto Trait Implementations§
impl<R, A> Freeze for SmartProtocol<R, A>
impl<R, A> RefUnwindSafe for SmartProtocol<R, A>where
R: RefUnwindSafe,
A: RefUnwindSafe,
impl<R, A> Send for SmartProtocol<R, A>
impl<R, A> Sync for SmartProtocol<R, A>
impl<R, A> Unpin for SmartProtocol<R, A>
impl<R, A> UnwindSafe for SmartProtocol<R, A>where
R: UnwindSafe,
A: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ValueSize for T
impl<T> ValueSize for T
Source§fn value_size(&self) -> usize
fn value_size(&self) -> usize
The size of this value in bytes, excluding allocated data. Read more
Source§fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usizewhere
T: 'item,
fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usizewhere
T: 'item,
The total sum of the sizes of all values in the given iterator, in
bytes. This is default-implemented by computing ValueSize::value_size
on every element and summing them. For Sized types, a more potentially
efficient implementation using Iterator::count is provided. If you are
implementing this trait manually, it is unlikely to be more efficient to
provide a manual implementation here. Read more
Source§fn value_size_sum_exact_size_iter<'item>(
iterator: impl ExactSizeIterator<Item = &'item T>,
) -> usizewhere
T: 'item,
fn value_size_sum_exact_size_iter<'item>(
iterator: impl ExactSizeIterator<Item = &'item T>,
) -> usizewhere
T: 'item,
The total sum of the sizes of all values in the given
exact-size-iterator, in bytes. This is default-implemented by using
ValueSize::value_size_sum_iter. For Sized types, a usually more
efficient implementation using ExactSizeIterator::len is provided. If
you are implementing this trait manually, it is unlikely to be more
efficient to provide a manual implementation here. Read more