Debian Codegraph @

src/acquire.rs

raw symbols SCIP
1 //! File Acquiration
2 //!
3 //! The following was taken from libapt-pkg documentation.
4 //!
5 //! This module contains the Acquire system. It is responsible for bringing
6 //! files into the local pathname space. It deals with URIs for files and
7 //! URI handlers responsible for downloading or finding the URIs.
8 //!
9 //! Each file to download is represented by an Acquire::Item class subclassed
10 //! into a specialization. The Item class can add itself to several URI
11 //! acquire queues each prioritized by the download scheduler. When the
12 //! system is run the proper URI handlers are spawned and the acquire
13 //! queues are fed into the handlers by the schedular until the queues are
14 //! empty. This allows for an Item to be downloaded from an alternate source
15 //! if the first try turns out to fail. It also allows concurrent downloading
16 //! of multiple items from multiple sources as well as dynamic balancing
17 //! of load between the sources.
18 //!
19 //! Scheduling of downloads is done on a first ask first get basis. This
20 //! preserves the order of the download as much as possible. And means the
21 //! fastest source will tend to process the largest number of files.
22 //!
23 //! Internal methods and queues for performing gzip decompression,
24 //! md5sum hashing and file copying are provided to allow items to apply
25 //! a number of transformations to the data files they are working with.
26
27 #[cxxrust-analyzer cargo cxx 1.0.199 crate/::bridgerust-analyzer cargo cxxbridge-macro 1.0.199 bridge:]
28 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) mod rawrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ {
29 #[repr(u32)]
30 enum ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState# {
31 StatIdlerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatIdle.,
32 StatFetchingrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatFetching.,
33 StatDonerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatDone.,
34 StatErrorrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatError.,
35 StatAuthErrorrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatAuthError.,
36 StatTransientNetworkErrorrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemState]StatTransientNetworkError.,
37 }
38
39 unsafe extern "C++" {
40 includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include!!("rust-apt/apt-pkg-c/acquire.h");
41 type AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#;
42 type PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#;
43 type AcqWorkerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqWorker#;
44 type ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#;
45 type Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#;
46 type ItemState;
47
48 type AcquireProgressrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcquireProgress#<'a> = craterust-analyzer cargo rust-apt 0.8.0 crate/::progressrust-analyzer cargo rust-apt 0.8.0 progress/::AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#<'a>;
49
50 /// A client-supplied unique identifier.
51 ///
52 /// APT progress reporting will store an ID as shown in "Get:42…".
53 pub fn idrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]id().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> u32;
54 /// `true`` if entire object has been successfully fetched.
55 pub fn completerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]complete().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> bool;
56 /// The size of the object to fetch.
57 pub fn file_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]file_size().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> u64;
58 /// Get the URI of the item.
59 pub fn urirust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]uri().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
60 /// The Destination file path.
61 pub fn dest_filerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]dest_file().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
62 /// The current status of this item.
63 pub fn statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]status().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> ItemStaterust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemState#;
64 /// Contains a textual description of the error encountered
65 /// if ItemState is StatError or StatAuthError.
66 pub fn error_textrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]error_text().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
67 /// Contains the name of the subprocess that is operating on this item.
68 ///
69 /// For instance, "store", "gzip", "rred", "gpgv".
70 pub fn active_subprocessrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]active_subprocess().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
71 /// The acquire process with which this item is associated.
72 pub fn ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[Item]owner().(self: &Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#>;
73
74 /// URI from which to download this item.
75 pub fn urirust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]uri().(self: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
76 /// Description of this item.
77 pub fn descriptionrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]description().(self: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
78 /// Shorter description of this item.
79 pub fn short_descrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]short_desc().(self: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
80 /// Underlying item which is to be downloaded.
81 pub fn ownerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[ItemDesc]owner().(self: &ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<Itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/Item#>;
82
83 /// # Safety
84 ///
85 /// Before you do anything with AcqTextStatus you must set the callback.
86 ///
87 /// The returned UniquePtr cannot outlive the cache.
88 unsafe fn acquire_statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/acquire_status().() -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#>;
89 /// # Safety
90 ///
91 /// Setting the Callback requires a raw mutable pointer to
92 /// AcquireProgress.
93 ///
94 /// AcquireProgress must not be moved in memory or will segfault when
95 /// AcqTextStatus calls it.
96 unsafe fn set_callbackrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]set_callback().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#>, progress: *mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcquireProgress#);
97
98 /// The number of bytes fetched as of the most recent call
99 /// to pkgAcquireStatus::Pulse, including local items.
100 pub fn current_cpsrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]current_cps().(self: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) -> u64;
101 /// The amount of time that has elapsed since the download started.
102 pub fn elapsed_timerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]elapsed_time().(self: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) -> u64;
103 /// The total number of bytes accounted for by items that were
104 /// successfully fetched.
105 pub fn fetched_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]fetched_bytes().(self: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) -> u64;
106 /// The number of bytes fetched as of the most recent call to
107 /// pkgAcquireStatus::Pulse, including local items.
108 pub fn current_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]current_bytes().(self: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) -> u64;
109 /// The total number of bytes that need to be fetched.
110 ///
111 /// This member is inaccurate, as new items might be enqueued while the
112 /// download is in progress!
113 pub fn total_bytesrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]total_bytes().(self: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) -> u64;
114 /// The estimated percentage of the download (0-100)
115 pub fn percentrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqTextStatus]percent().(self: &AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#) -> f64;
116
117 /// The most recent status string received from the subprocess.
118 pub fn statusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]status().(self: &AcqWorkerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqWorker#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
119 /// The queue entry that is currently being downloaded.
120 pub fn itemrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]item().(self: &AcqWorkerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqWorker#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#>>;
121 /// How many bytes of the file have been downloaded.
122 ///
123 /// Zero if the current progress of the file cannot be determined.
124 pub fn current_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]current_size().(self: &AcqWorkerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqWorker#) -> u64;
125 /// The total number of bytes to be downloaded.
126 ///
127 /// Zero if the total size of the final is unknown.
128 pub fn total_sizerust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[AcqWorker]total_size().(self: &AcqWorkerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqWorker#) -> u64;
129
130 // TODO: This should probably be unsafe, but not sure at the moment how to
131 // handle it I guess we would need to wrap PkgAcquire and AcqWorker so they can
132 // have proper lifetimes?
133
134 /// CxxVector of active workers
135 pub fn workersrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[PkgAcquire]workers().(self: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<CxxVectorrust-analyzer cargo cxx 1.0.199 cxx_vector/CxxVector#<AcqWorkerrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqWorker#>>;
136
137 /// Get the ItemDesc that contain the source list URIs
138 ///
139 /// # Safety
140 ///
141 /// You must not let these out of scope of PkgAcquire. SIGABRT.
142 unsafe fn urisrust-analyzer cargo rust-apt 0.8.0 acquire/raw/impl#[PkgAcquire]uris().(self: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<CxxVectorrust-analyzer cargo cxx 1.0.199 cxx_vector/CxxVector#<ItemDescrust-analyzer cargo rust-apt 0.8.0 acquire/raw/ItemDesc#>>;
143
144 // It isn't clear that create_acquire should be unsafe.
145 // It doesn't segfault if you drop the Cache.
146 // But it does return a UniquePtr so I assume it is unsafe.
147
148 /// Create PkgAcquire.
149 ///
150 /// # Safety
151 ///
152 /// The returned UniquePtr cannot outlive the cache.
153 unsafe fn create_acquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/create_acquire().() -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#>;
154 }
155 }