pub struct GitTorrentService { /* private fields */ }Expand description
Main GitTorrent service
Implementations§
Source§impl GitTorrentService
impl GitTorrentService
Sourcepub async fn new(config: GitTorrentConfig) -> Result<Self>
pub async fn new(config: GitTorrentConfig) -> Result<Self>
Create a new GitTorrent service
Sourcepub async fn add_repository(&self, name: String, path: &Path) -> Result<()>
pub async fn add_repository(&self, name: String, path: &Path) -> Result<()>
Add a repository to the service
Sourcepub async fn get_object(&self, hash: &Sha256Hash) -> Result<Option<Vec<u8>>>
pub async fn get_object(&self, hash: &Sha256Hash) -> Result<Option<Vec<u8>>>
Get a Git object by SHA256 hash
Sourcepub async fn get_object_by_cid(
&self,
cid: &ContentCid,
) -> Result<Option<Vec<u8>>>
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.
Sourcepub async fn get_object_by_cid_with_provenance(
&self,
cid: &ContentCid,
) -> Result<Option<ObjectFetch>>
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.
Sourcepub async fn put_object(&self, data: Vec<u8>) -> Result<Sha256Hash>
pub async fn put_object(&self, data: Vec<u8>) -> Result<Sha256Hash>
Store a Git object, returning its SHA256 hash (the consumer-facing key).
Sourcepub async fn put_object_by_cid(
&self,
cid: ContentCid,
data: Vec<u8>,
) -> Result<()>
pub async fn put_object_by_cid( &self, cid: ContentCid, data: Vec<u8>, ) -> Result<()>
Store an object under a canonical content CID.
Sourcepub async fn store_repository_objects(
&self,
repo_path: &Path,
) -> Result<Vec<Sha256Hash>>
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).
Sourcepub async fn store_commit_objects(
&self,
repo_path: &Path,
commit_hash: &str,
) -> Result<Vec<Sha256Hash>>
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.
Sourcepub async fn reconstruct_repository(
&self,
object_hashes: &[Sha256Hash],
target_path: &Path,
) -> Result<()>
pub async fn reconstruct_repository( &self, object_hashes: &[Sha256Hash], target_path: &Path, ) -> Result<()>
Reconstruct repository from individual objects
Sourcepub async fn get_commit_objects(
&self,
commit_hash: &Sha256Hash,
) -> Result<Vec<Vec<u8>>>
pub async fn get_commit_objects( &self, commit_hash: &Sha256Hash, ) -> Result<Vec<Vec<u8>>>
Get objects for a specific commit (recursive)
Sourcepub async fn clone_repository(
&self,
url: &GitTorrentUrl,
local_path: &Path,
) -> Result<()>
pub async fn clone_repository( &self, url: &GitTorrentUrl, local_path: &Path, ) -> Result<()>
Clone a repository from a GitTorrent URL
Sourcepub async fn stats(&self) -> ServiceStats
pub async fn stats(&self) -> ServiceStats
Get service statistics
Sourcepub async fn list_repositories(&self) -> Vec<(String, RepositoryMetadata)>
pub async fn list_repositories(&self) -> Vec<(String, RepositoryMetadata)>
List all repositories
Sourcepub async fn announce_repository(&self, repo_path: &Path) -> Result<()>
pub async fn announce_repository(&self, repo_path: &Path) -> Result<()>
Announce repository to P2P network (wrapper for store_repository_objects)
Sourcepub async fn query_repository(
&self,
identifier: &str,
) -> Result<Option<RepositoryMetadata>>
pub async fn query_repository( &self, identifier: &str, ) -> Result<Option<RepositoryMetadata>>
Query for repository metadata by identifier
Auto Trait Implementations§
impl Freeze for GitTorrentService
impl !RefUnwindSafe for GitTorrentService
impl Send for GitTorrentService
impl Sync for GitTorrentService
impl Unpin for GitTorrentService
impl UnsafeUnpin for GitTorrentService
impl !UnwindSafe for GitTorrentService
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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