pub struct DownloadSource { /* private fields */ }

Implementations§

source§

impl DownloadSource

source

pub fn new(url: String, source_type: DownloadSourceType) -> Self

Examples found in repository?
examples/downloads.rs (lines 10-13)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
async fn main() -> DownloadResult<()> {
    let source_1 = DownloadSource::new(
        "https://mirrors.bfsu.edu.cn/anthon/debs/pool/stable/main/g/go_1.19.4%2Btools0.4.0%2Bnet0.4.0-0_amd64.deb".to_string(),
        DownloadSourceType::Http
    );

    let file_1 = DownloadEntryBuilder::default()
        .source(vec![source_1])
        .filename("go.deb".to_string())
        .dir(PathBuf::from("./oma-fetcher-test"))
        .hash("0625cbba48a14438eea144682567a026a17e173420c5bdcbc06dcb11aba50628".to_string())
        .allow_resume(true)
        .build()?;

    let source_2 = DownloadSource::new(
        "https://mirrors.bfsu.edu.cn/anthon/debs/pool/stable/main/v/vscodium_1.77.3.23102-0_arm64.deb".to_string(),
        DownloadSourceType::Http
    );

    let file_2 = DownloadEntryBuilder::default()
        .source(vec![source_2])
        .filename("vscode.deb".to_string())
        .dir(PathBuf::from("./oma-fetcher-test"))
        .allow_resume(false)
        .build()?;

    let mut test_local_file = tokio::fs::File::create("test").await?;
    test_local_file.write_all(b"test").await?;

    let source_3 = DownloadSource::new("./test".to_string(), DownloadSourceType::Local);

    let file_3 = DownloadEntryBuilder::default()
        .source(vec![source_3])
        .filename("test_downloaded".to_string())
        .dir(PathBuf::from("./oma-fetcher-test"))
        .build()?;

    let fetcher = OmaFetcher::new(None, true, None, vec![file_1, file_2, file_3], None)?;

    tokio::fs::create_dir_all("./oma-fetcher-test").await?;
    fetcher
        .start_download()
        .await
        .into_iter()
        .collect::<DownloadResult<Vec<_>>>()?;

    Ok(())
}

Trait Implementations§

source§

impl Clone for DownloadSource

source§

fn clone(&self) -> DownloadSource

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DownloadSource

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more