fad06fd
use async_trait::async_trait;
use crate::server::error::ServerResult;
use crate::server::request::{AuthContext, RefUpdateBatch, ServerRequest};
use crate::server::stream::{BoxedAsyncRead, IngestReport};
#[async_trait]
pub trait ServerBackend: Send + Sync + 'static {
async fn authorize(&self, req: &ServerRequest) -> ServerResult<AuthContext>;
async fn list_refs_stream(&self, req: &ServerRequest) -> ServerResult<BoxedAsyncRead>;
async fn produce_pack_stream(
&self,
req: &ServerRequest,
wants: &[String],
) -> ServerResult<BoxedAsyncRead>;
async fn ingest_pack_stream(
&self,
req: &ServerRequest,
batch: RefUpdateBatch,
) -> ServerResult<IngestReport>;
async fn lfs_get_stream(&self, req: &ServerRequest, oid: &str) -> ServerResult<BoxedAsyncRead>;
async fn lfs_put_stream(
&self,
req: &ServerRequest,
oid: &str,
declared_size: u64,
) -> ServerResult<IngestReport>;
}
pub fn empty_body() -> BoxedAsyncRead {
Box::new(tokio::io::empty())
}