Skip to main content

SmartProtocol

Struct SmartProtocol 

Source
pub struct SmartProtocol<R, A>{
    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: String

Implementations§

Source§

impl<R, A> SmartProtocol<R, A>

Source

pub fn set_wire_hash_kind(&mut self, kind: HashKind)

Set the wire hash kind (sha1 or sha256)

Source

pub fn new( transport_protocol: TransportProtocol, repo_storage: R, auth_service: A, ) -> Self

Create a new SmartProtocol instance

Source

pub async fn authenticate_http( &self, headers: &HashMap<String, String>, ) -> Result<(), ProtocolError>

Authenticate an HTTP request using the injected auth service

Source

pub async fn authenticate_ssh( &self, username: &str, public_key: &[u8], ) -> Result<(), ProtocolError>

Authenticate an SSH session using username and public key

Source

pub fn set_transport_protocol(&mut self, protocol: TransportProtocol)

Set transport protocol (Http, Ssh, etc.)

Source

pub async fn git_info_refs( &self, service_type: ServiceType, ) -> Result<BytesMut, ProtocolError>

Get git info refs for the repository, with explicit service type

Source

pub async fn git_upload_pack( &mut self, upload_request: Bytes, ) -> Result<(ReceiverStream<Vec<u8>>, BytesMut), ProtocolError>

Handle git-upload-pack request

Source

pub fn parse_receive_pack_commands(&mut self, protocol_bytes: Bytes)

Parse receive pack commands from protocol bytes

Source

pub async fn git_receive_pack_stream( &mut self, data_stream: ProtocolStream, ) -> Result<Bytes, ProtocolError>

Handle git receive-pack operation (push)

Source

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.

Source

pub fn parse_capabilities(&mut self, cap_str: &str)

Parse capabilities from capability string

Source

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>
where R: Freeze, A: Freeze,

§

impl<R, A> RefUnwindSafe for SmartProtocol<R, A>

§

impl<R, A> Send for SmartProtocol<R, A>

§

impl<R, A> Sync for SmartProtocol<R, A>

§

impl<R, A> Unpin for SmartProtocol<R, A>
where R: Unpin, A: Unpin,

§

impl<R, A> UnsafeUnpin for SmartProtocol<R, A>
where R: UnsafeUnpin, A: UnsafeUnpin,

§

impl<R, A> UnwindSafe for SmartProtocol<R, A>
where R: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ValueSize for T

Source§

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>) -> usize
where 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>, ) -> usize
where 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
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,