pub struct FileDownloadSession { /* private fields */ }Expand description
Manages the downloading of files from CAS storage.
This struct parallels FileUploadSession for the download path. It holds the
CAS client and a shared progress group for all downloads in the session.
Implementations§
Source§impl FileDownloadSession
impl FileDownloadSession
pub async fn new( config: Arc<TranslatorConfig>, chunk_cache: Option<Arc<dyn ChunkCache>>, ) -> Result<Arc<Self>>
Sourcepub fn from_client(
client: Arc<dyn Client>,
chunk_cache: Option<Arc<dyn ChunkCache>>,
) -> Arc<Self>
pub fn from_client( client: Arc<dyn Client>, chunk_cache: Option<Arc<dyn ChunkCache>>, ) -> Arc<Self>
Construct a download session from an existing CAS client.
This path uses default progress speed settings. Use Self::new when the
session should inherit the configured speed parameters from xet_config.
pub fn report(&self) -> GroupProgressReport
pub fn item_report(&self, id: UniqueID) -> Option<ItemProgressReport>
pub fn item_reports(&self) -> HashMap<UniqueID, ItemProgressReport>
pub fn unregister_stream_abort_callback(&self, id: UniqueID)
pub fn abort_active_streams(&self)
Sourcepub async fn download_file_background(
self: &Arc<Self>,
file_info: XetFileInfo,
write_path: PathBuf,
) -> Result<(UniqueID, JoinHandle<Result<u64>>)>
pub async fn download_file_background( self: &Arc<Self>, file_info: XetFileInfo, write_path: PathBuf, ) -> Result<(UniqueID, JoinHandle<Result<u64>>)>
Spawns a download task that writes file_info to write_path.
Acquires a permit from the global download semaphore before starting. Returns the tracking ID and the join handle for the spawned task.
Sourcepub async fn download_file(
&self,
file_info: &XetFileInfo,
write_path: &Path,
) -> Result<(UniqueID, u64)>
pub async fn download_file( &self, file_info: &XetFileInfo, write_path: &Path, ) -> Result<(UniqueID, u64)>
Downloads a complete file to the given path.
Sourcepub async fn download_to_writer<W: Write + Send + 'static>(
&self,
file_info: &XetFileInfo,
source_range: impl RangeBounds<u64>,
writer: W,
) -> Result<(UniqueID, u64)>
pub async fn download_to_writer<W: Write + Send + 'static>( &self, file_info: &XetFileInfo, source_range: impl RangeBounds<u64>, writer: W, ) -> Result<(UniqueID, u64)>
Downloads a byte range of a file and writes it to the provided writer.
The provided source_range is interpreted against the original file; output
starts at the writer’s current position. Accepts any RangeBounds<u64>:
4..12, 5.., ..100, or .. (full file).
This path does not acquire the session-level file download semaphore.
Sourcepub async fn download_stream(
&self,
file_info: &XetFileInfo,
source_range: Option<Range<u64>>,
) -> Result<(UniqueID, DownloadStream)>
pub async fn download_stream( &self, file_info: &XetFileInfo, source_range: Option<Range<u64>>, ) -> Result<(UniqueID, DownloadStream)>
Creates a streaming download of a file, optionally restricted to a byte range.
Returns a DownloadStream that yields data chunks as the file is
reconstructed. Reconstruction starts lazily on first
DownloadStream::next / DownloadStream::blocking_next call
(or when start() is called explicitly).
If source_range is Some, only the specified byte range of the
file is reconstructed.
This path does not acquire the session-level file download semaphore.
Sourcepub async fn download_unordered_stream(
&self,
file_info: &XetFileInfo,
source_range: Option<Range<u64>>,
) -> Result<(UniqueID, UnorderedDownloadStream)>
pub async fn download_unordered_stream( &self, file_info: &XetFileInfo, source_range: Option<Range<u64>>, ) -> Result<(UniqueID, UnorderedDownloadStream)>
Creates an unordered streaming download of a file, optionally restricted to a byte range.
Returns an UnorderedDownloadStream that yields (offset, Bytes)
chunks in whatever order they complete. The total expected size is
set from the range length (or file_info.file_size() when no range
is given).
If source_range is Some, only the specified byte range of the
file is reconstructed.
This path does not acquire the session-level file download semaphore.
Sourcepub async fn download_stream_range(
&self,
file_info: &XetFileInfo,
range: impl RangeBounds<u64>,
) -> Result<(UniqueID, DownloadStream)>
pub async fn download_stream_range( &self, file_info: &XetFileInfo, range: impl RangeBounds<u64>, ) -> Result<(UniqueID, DownloadStream)>
Creates a streaming download of a byte range of a file.
Accepts any RangeBounds<u64>: 4..12, 5.., ..100, or .. (full file).
This path does not acquire the session-level file download semaphore.
Auto Trait Implementations§
impl !Freeze for FileDownloadSession
impl !RefUnwindSafe for FileDownloadSession
impl Send for FileDownloadSession
impl Sync for FileDownloadSession
impl Unpin for FileDownloadSession
impl UnsafeUnpin for FileDownloadSession
impl !UnwindSafe for FileDownloadSession
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
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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