pub struct DownloadManager {
pub directory: PathBuf,
pub persist: bool,
/* private fields */
}Expand description
One managed download lifecycle for a browser.
Fields§
§directory: PathBufThe directory downloads are saved into.
persist: boolWhether files outlive the browser. Always true today.
Implementations§
Source§impl DownloadManager
impl DownloadManager
Sourcepub fn create(options: DownloadOptions) -> Result<Arc<Self>, DownloadError>
pub fn create(options: DownloadOptions) -> Result<Arc<Self>, DownloadError>
Create a manager with a prepared download directory.
The directory is resolved and probed before a single download can start: a permission problem found afterwards looks exactly like a file that never arrived.
§Arguments
options- How downloads should be managed
§Returns
A manager with no source attached yet.
§Errors
Returns DownloadError::RelativeDirectory,
DownloadError::DirectoryNotCreated or
DownloadError::DirectoryNotWritable.
Sourcepub async fn attach(
self: &Arc<Self>,
transport: &dyn CdpTransport,
) -> Result<(), DownloadError>
pub async fn attach( self: &Arc<Self>, transport: &dyn CdpTransport, ) -> Result<(), DownloadError>
Point a browser’s downloads at this manager.
Browser.setDownloadBehavior is browser-wide, which is what makes a
download a person started observable too, and the directory watcher
is what stands in for the event stream this crate’s CDP transport does
not have.
§Arguments
transport- A CDP connection with Browser-domain access
§Errors
Returns DownloadError::Transport when the browser refuses to
redirect its downloads, which is how an attached browser that denies
the Browser domain reports itself.
Sourcepub async fn attach_filesystem(self: &Arc<Self>) -> Result<(), DownloadError>
pub async fn attach_filesystem(self: &Arc<Self>) -> Result<(), DownloadError>
Watch the managed staging directory after a WebDriver launcher has configured its native download preferences. Does not send CDP commands.
Sourcepub fn list(&self) -> Vec<DownloadArtifact>
pub fn list(&self) -> Vec<DownloadArtifact>
Sourcepub fn subscribe(&self) -> Receiver<DownloadArtifact>
pub fn subscribe(&self) -> Receiver<DownloadArtifact>
Watch every download as it settles.
§Returns
A receiver of settled artifacts, plus the started announcement.
Sourcepub async fn capture<F>(
&self,
options: CaptureOptions,
action: F,
) -> Result<DownloadArtifact, DownloadError>
pub async fn capture<F>( &self, options: CaptureOptions, action: F, ) -> Result<DownloadArtifact, DownloadError>
Wait for a download, triggering it first.
The waiter and this capture’s naming rules are armed before action
is awaited. A download can start, finish and be saved inside the
action, so attaching them afterwards would save the file under the
wrong name and skip the caller’s validation entirely.
§Arguments
options- Naming, validation, conflict policy and budgetaction- What triggers the download
§Returns
The completed artifact.
§Errors
Returns DownloadError::ActionFailed when the action itself failed,
DownloadError::CaptureTimeout when nothing settled inside the
budget, and DownloadError::DownloadFailed when the download failed
or was cancelled — a capture never reports a file that is not there.
Trait Implementations§
Source§impl Debug for DownloadManager
impl Debug for DownloadManager
Source§impl DownloadSink for DownloadManager
impl DownloadSink for DownloadManager
Source§fn started(&self, start: DownloadStart) -> String
fn started(&self, start: DownloadStart) -> String
Auto Trait Implementations§
impl !Freeze for DownloadManager
impl !RefUnwindSafe for DownloadManager
impl !UnwindSafe for DownloadManager
impl Send for DownloadManager
impl Sync for DownloadManager
impl Unpin for DownloadManager
impl UnsafeUnpin for DownloadManager
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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