Skip to main content

register_gittorrent_transport

Function register_gittorrent_transport 

Source
pub fn register_gittorrent_transport(
    service: Arc<GitTorrentService>,
) -> Result<()>
Expand description

Helper function to register GitTorrent transport with git2

This registers the gittorrent:// URL scheme handler globally with git2. Once registered, any git2 operations (clone, fetch, push) with gittorrent:// URLs will automatically use the P2P transport.

ยงExample

use std::sync::Arc;
use hyprstream_p2p::service::GitTorrentService;
use hyprstream_p2p::git::transport::register_gittorrent_transport;

let service = Arc::new(GitTorrentService::new(Default::default()).await?);
register_gittorrent_transport(service)?;

// Now gittorrent:// URLs work with standard git2 operations
let repo = git2::Repository::clone("gittorrent://hash/repo", "/tmp/repo")?;