Skip to main content

GitTorrentService

Struct GitTorrentService 

Source
pub struct GitTorrentService { /* private fields */ }
Expand description

Main GitTorrent service

Implementations§

Source§

impl GitTorrentService

Source

pub async fn new(config: GitTorrentConfig) -> Result<Self>

Create a new GitTorrent service

Source

pub async fn add_repository(&self, name: String, path: &Path) -> Result<()>

Add a repository to the service

Source

pub async fn get_object(&self, hash: &Sha256Hash) -> Result<Option<Vec<u8>>>

Get a Git object by SHA256 hash

Source

pub async fn get_object_by_cid( &self, cid: &ContentCid, ) -> Result<Option<Vec<u8>>>

Get an object by its canonical content CID.

Discards commit provenance. Callers that persist fetched bytes (e.g. the XET smudge path, which must validate before persisting) must use [get_object_by_cid_with_provenance] instead; treating a provider-fetched, non-self-verifying result as already-validated bypasses the caller’s persistence gate.

Source

pub async fn get_object_by_cid_with_provenance( &self, cid: &ContentCid, ) -> Result<Option<ObjectFetch>>

Get an object by its canonical content CID, along with its commit provenance.

See ObjectFetch for the meaning of committed. The provenance is structural: it is derived from which store produced the bytes and whether the CID can self-verify them, never from a caller assertion. A non-committed result must not be persisted without end-to-end validation.

Source

pub async fn put_object(&self, data: Vec<u8>) -> Result<Sha256Hash>

Store a Git object, returning its SHA256 hash (the consumer-facing key).

Source

pub async fn put_object_by_cid( &self, cid: ContentCid, data: Vec<u8>, ) -> Result<()>

Store an object under a canonical content CID.

Source

pub async fn store_repository_objects( &self, repo_path: &Path, ) -> Result<Vec<Sha256Hash>>

Store all objects from a repository individually through the object facade (iroh-blobs + mainline announce).

Source

pub async fn store_commit_objects( &self, repo_path: &Path, commit_hash: &str, ) -> Result<Vec<Sha256Hash>>

Store objects for a specific commit and its history through the object facade.

Source

pub async fn reconstruct_repository( &self, object_hashes: &[Sha256Hash], target_path: &Path, ) -> Result<()>

Reconstruct repository from individual objects

Source

pub async fn get_commit_objects( &self, commit_hash: &Sha256Hash, ) -> Result<Vec<Vec<u8>>>

Get objects for a specific commit (recursive)

Source

pub async fn clone_repository( &self, url: &GitTorrentUrl, local_path: &Path, ) -> Result<()>

Clone a repository from a GitTorrent URL

Source

pub async fn stats(&self) -> ServiceStats

Get service statistics

Source

pub async fn list_repositories(&self) -> Vec<(String, RepositoryMetadata)>

List all repositories

Source

pub async fn announce_repository(&self, repo_path: &Path) -> Result<()>

Announce repository to P2P network (wrapper for store_repository_objects)

Source

pub async fn query_repository( &self, identifier: &str, ) -> Result<Option<RepositoryMetadata>>

Query for repository metadata by identifier

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,