Debian Codegraph @

src/distribution.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/;
2
3 /// Represents a Linux distribution
4 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
5 pub enum Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution# {
6 /// Ubuntu Linux
7 Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu#,
8 /// Debian Linux
9 Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian#,
10 /// Other distribution
11 Otherrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Other#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
12 }
13
14 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution# {
15 fn fmtrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
16 match self {
17 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Ubuntu"),
18 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Debian"),
19 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Otherrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Other#(name) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", name),
20 }
21 }
22 }
23
24 impl Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution# {
25 /// Get the current system's distribution information
26 ///
27 /// Returns None if /etc/os-release is not present or cannot be parsed.
28 pub fn currentrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]current().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#> {
29 let content = fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().("/etc/os-release").okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
30
31 for line in content.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().() {
32 if line.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("ID=") {
33 let id = line
34 .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().("ID=")
35 .trim_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_matches().('"')
36 .to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().();
37
38 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(match id.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() {
39 "ubuntu" => Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu#,
40 "debian" => Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian#,
41 other => Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Otherrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Other#(other.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()),
42 });
43 }
44 }
45
46 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
47 }
48
49 /// Get default components for this distribution
50 pub fn default_componentsrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]default_components().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'static str> {
51 match self {
52 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu# => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main", "universe"],
53 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian# => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main"],
54 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Otherrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Other#(_) => vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main"],
55 }
56 }
57
58 /// Get the base name for the main sources file for this distribution
59 ///
60 /// For example, returns "ubuntu" for Ubuntu, "debian" for Debian.
61 /// This can be used to construct filenames like "ubuntu.sources".
62 pub fn sources_basenamerust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]sources_basename().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'static str> {
63 match self {
64 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ubuntu"),
65 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("debian"),
66 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Otherrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Other#(_) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
67 }
68 }
69
70 /// Check if a repository is a main distribution repository
71 pub fn is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&self, repo: &craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository#) -> bool {
72 for uri in &repo.urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris. {
73 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(host) = uri.host_strrust-analyzer cargo url 2.5.8 impl#[Url]host_str().() {
74 match self {
75 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu# => {
76 if host.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("ubuntu.com")
77 || host.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("canonical.com")
78 || host rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."archive.ubuntu.com"
79 || host rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."security.ubuntu.com"
80 || host rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."ports.ubuntu.com"
81 {
82 return true;
83 }
84 }
85 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian# => {
86 if host.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("debian.org")
87 || host rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."deb.debian.org"
88 || host rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."security.debian.org"
89 {
90 return true;
91 }
92 }
93 _ => {}
94 }
95 }
96 }
97 false
98 }
99 }
100
101 /// Get system codename from /etc/os-release
102 ///
103 /// Returns None if /etc/os-release is not present or doesn't contain VERSION_CODENAME.
104 /// The architecture is always an empty string (APT will use the system's native architecture).
105 pub fn get_system_inforust-analyzer cargo apt-sources 0.3.0 distribution/get_system_info().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)> {
106 let content = fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().("/etc/os-release").okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
107
108 let codename = content
109 .linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().()
110 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|line| line.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("VERSION_CODENAME="))
111 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|line| {
112 line.trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().("VERSION_CODENAME=")
113 .trim_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_matches().('"')
114 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
115 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
116
117 // Return empty string for architecture - APT will use the system's native architecture
118 // when the Architectures field is omitted from the sources file
119 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((codename, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().()))
120 }
121
122 #[cfg(test)]
123 mod testsrust-analyzer cargo apt-sources 0.3.0 distribution/tests/ {
124 use superrust-analyzer cargo apt-sources 0.3.0 distribution/::*;
125
126 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
127 fn test_is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/tests/test_is_main_repository().() {
128 let dist = Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu#;
129 let repo = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
130 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().("http://archive.ubuntu.com/ubuntu").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()],
131 suitesrust-analyzer cargo apt-sources 0.3.0 Repository#suites.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["jammy".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()],
132 componentsrust-analyzer cargo apt-sources 0.3.0 Repository#components.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()]),
133 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
134 };
135 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&repo));
136
137 let non_main_repo = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
138 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().("http://example.com/ubuntu").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()],
139 suitesrust-analyzer cargo apt-sources 0.3.0 Repository#suites.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["jammy".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()],
140 componentsrust-analyzer cargo apt-sources 0.3.0 Repository#components.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()]),
141 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
142 };
143 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&non_main_repo));
144 }
145
146 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
147 fn test_is_main_repository_all_ubuntu_hostsrust-analyzer cargo apt-sources 0.3.0 distribution/tests/test_is_main_repository_all_ubuntu_hosts().() {
148 let dist = Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu#;
149
150 // Test each Ubuntu host individually
151 let ubuntu_hosts = [
152 "http://archive.ubuntu.com/ubuntu",
153 "http://security.ubuntu.com/ubuntu",
154 "http://ports.ubuntu.com/ubuntu-ports",
155 "http://us.archive.ubuntu.com/ubuntu", // contains ubuntu.com
156 "http://mirrors.canonical.com/ubuntu", // contains canonical.com
157 ];
158
159 for host in &ubuntu_hosts {
160 let repo = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
161 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().(host).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()],
162 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
163 };
164 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&repo), "Failed for host: {}", host);
165 }
166 }
167
168 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
169 fn test_is_main_repository_all_debian_hostsrust-analyzer cargo apt-sources 0.3.0 distribution/tests/test_is_main_repository_all_debian_hosts().() {
170 let dist = Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian#;
171
172 // Test each Debian host individually
173 let debian_hosts = [
174 "http://deb.debian.org/debian",
175 "http://security.debian.org/debian-security",
176 "http://ftp.debian.org/debian", // contains debian.org
177 "http://mirrors.debian.org/debian", // contains debian.org
178 ];
179
180 for host in &debian_hosts {
181 let repo = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
182 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().(host).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()],
183 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
184 };
185 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&repo), "Failed for host: {}", host);
186 }
187 }
188
189 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
190 fn test_is_main_repository_other_distributionrust-analyzer cargo apt-sources 0.3.0 distribution/tests/test_is_main_repository_other_distribution().() {
191 let dist = Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Otherrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Other#("mint".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
192
193 // Other distributions should not match any repository
194 let repo = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
195 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().("http://archive.ubuntu.com/ubuntu").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()],
196 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
197 };
198 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&repo));
199
200 let repo2 = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
201 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().("http://deb.debian.org/debian").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()],
202 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
203 };
204 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&repo2));
205 }
206
207 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
208 fn test_is_main_repository_empty_urisrust-analyzer cargo apt-sources 0.3.0 distribution/tests/test_is_main_repository_empty_uris().() {
209 let dist = Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu#;
210 let repo = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
211 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
212 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
213 };
214 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&repo));
215 }
216
217 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
218 fn test_is_main_repository_multiple_urisrust-analyzer cargo apt-sources 0.3.0 distribution/tests/test_is_main_repository_multiple_uris().() {
219 let dist = Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu#;
220 let repo = craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# {
221 urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
222 urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().("http://example.com/ubuntu").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
223 urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#::parserust-analyzer cargo url 2.5.8 impl#[Url]parse().("http://archive.ubuntu.com/ubuntu").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
224 ],
225 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 impl#[Repository][Default]default().()
226 };
227 // Should return true if ANY URI matches
228 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dist.is_main_repositoryrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]is_main_repository().(&repo));
229 }
230
231 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
232 fn test_default_componentsrust-analyzer cargo apt-sources 0.3.0 distribution/tests/test_default_components().() {
233 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
234 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Ubunturust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Ubuntu#.default_componentsrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]default_components().(),
235 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main", "universe"]
236 );
237 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Debianrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Debian#.default_componentsrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]default_components().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main"]);
238 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
239 Distributionrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#::Otherrust-analyzer cargo apt-sources 0.3.0 distribution/Distribution#Other#("mint".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).default_componentsrust-analyzer cargo apt-sources 0.3.0 distribution/impl#[Distribution]default_components().(),
240 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main"]
241 );
242 }
243 }