| 1 | //! A module for parsing and manipulating APT source files that |
| 2 | //! use the pre-DEB822 single line format to hold package repositories specifications. |
| 3 | //! |
| 4 | //! # Examples |
| 5 | //! ``` |
| 6 | //! # use url::Url; |
| 7 | //! # use apt_sources::legacy::LegacyRepositories; |
| 8 | //! # use std::str::FromStr; |
| 9 | //! let single_line = "deb http://archive.ubuntu.com/ubuntu jammy main restricted"; |
| 10 | //! let repositories = LegacyRepositories::from_str(single_line) |
| 11 | //! .expect("Shall not fail for correct list entry!"); |
| 12 | //! assert_eq!(repositories.len(), 1); |
| 13 | //! let repository = repositories.iter().nth(0).expect("Shall not fail for first line"); |
| 14 | //! assert_eq!(repository.uri, "http://archive.ubuntu.com/ubuntu".parse::<Url>().unwrap()); |
| 15 | //! ``` |
| 16 | use superrust-analyzer cargo apt-sources 0.3.0 crate/::RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#; |
| 17 | use superrust-analyzer cargo apt-sources 0.3.0 crate/::RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#; |
| 18 | use superrust-analyzer cargo apt-sources 0.3.0 crate/::Signaturerust-analyzer cargo apt-sources 0.3.0 signature/Signature#; |
| 19 | use superrust-analyzer cargo apt-sources 0.3.0 crate/::YesNoForcerust-analyzer cargo apt-sources 0.3.0 YesNoForce#; |
| 20 | use itertoolsrust-analyzer cargo itertools 0.14.0 crate/::Itertoolsrust-analyzer cargo itertools 0.14.0 Itertools#; |
| 21 | use regexrust-analyzer cargo regex 1.12.3 crate/::Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#; |
| 22 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 23 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#; |
| 24 | use 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#; |
| 25 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#; |
| 26 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Notrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/Not#; |
| 27 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#; |
| 28 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 29 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#; |
| 30 | use urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#; |
| 31 | |
| 32 | /// A structure representing APT repository as declared by one-line-style `.list` file: |
| 33 | /// ```text |
| 34 | /// type [option=value option=value...] uri suite [component] [component] [...] |
| 35 | /// ``` |
| 36 | /// According to `sources.list(5)` man pages, only four fields are mandatory: |
| 37 | /// * `type` either `deb` or `deb-src` |
| 38 | /// * `uri` to repository holding valid APT structure |
| 39 | /// * `suite` usually being distribution codename |
| 40 | /// * `component` most of the time `main`, but it's a section of the repository; multiple values allowed |
| 41 | /// |
| 42 | /// The disabled field is just commented out with `#` followed by whitespaces at the beginning of the valid line |
| 43 | /// |
| 44 | /// The manpage specifies following optional fields |
| 45 | /// * `arch` comma separated list of binary architectures |
| 46 | /// * `lang` comma separated list of supported natural languages |
| 47 | /// * `target` |
| 48 | /// * `pdiffs` is a yes/no field |
| 49 | /// * `by-hash` is a yes/no/force field |
| 50 | /// * `allow-insecure` is a yes/no field, default no |
| 51 | /// * `allow-weak` is a yes/no field, default no |
| 52 | /// * `allow-downgrade-to-insecure` is a yes/no field, default no |
| 53 | /// * `trusted` us a yes/no field |
| 54 | /// * `signed-by` is a path to the key or fingerprint; optionally followed by exclamation mark |
| 55 | /// * `check-valid-until` is a yes/no field |
| 56 | /// * `valid-until-min` |
| 57 | /// * `valid-until-max` |
| 58 | /// * `check-date` is a yes/no field |
| 59 | /// * `date-max-future` |
| 60 | /// * `inrelease-path` relative path |
| 61 | /// * `snapshot` either `enable` or a snapshot ID |
| 62 | /// |
| 63 | /// Note: this module doesn't support undocumented options. |
| 64 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(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:, /*Eq,*/ Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 65 | pub struct LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 66 | /// This doesn't represent real field, but rather commented or uncommented line |
| 67 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: bool, |
| 68 | /// Legacy lists format support one type per line |
| 69 | pub typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#, |
| 70 | /// Single repo address; according to Debian that's URI, but this type is more advanced than URI from `http` crate |
| 71 | pub urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: Urlrust-analyzer cargo url 2.5.8 Url#, |
| 72 | /// The distribution name as codename or suite type (like `stable` or `testing`) |
| 73 | pub suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 74 | /// (Optional) Section of the repository, usually `main`, `contrib` or `non-free` |
| 75 | /// return `None` if repository is Flat Repository Format (<https://wiki.debian.org/DebianRepository/Format#Flat_Repository_Format>) |
| 76 | pub componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 77 | |
| 78 | /// (Optional) Architectures binaries from this repository run on |
| 79 | pub architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, // arch |
| 80 | /// (Optional) Translations support to download |
| 81 | pub languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, // lang |
| 82 | /// (Optional) Download targets to acquire from this source |
| 83 | pub targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, // target |
| 84 | /// (Optional) Controls if APT should try PDiffs instead of downloading indexes entirely; if not set defaults to configuration option `Acquire::PDiffs` |
| 85 | pub pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>, // pdiffs |
| 86 | /// (Optional) Controls if APT should try to acquire indexes via a URI constructed from a hashsum of the expected file |
| 87 | pub by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<YesNoForcerust-analyzer cargo apt-sources 0.3.0 YesNoForce#>, // by-hash |
| 88 | /// (Optional) If yes circumvents parts of `apt-secure`, don't thread lightly |
| 89 | pub allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure.: bool, // allow-insecure, default no |
| 90 | /// (Optional) If yes circumvents parts of `apt-secure`, don't thread lightly |
| 91 | pub allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak.: bool, // allow-weak, default no |
| 92 | /// (Optional) If yes circumvents parts of `apt-secure`, don't thread lightly |
| 93 | pub allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure.: bool, // allow-downgrade-to-insecure, default no |
| 94 | /// (Optional) If set forces whether APT considers source as trusted or no (default not present is a third state) |
| 95 | pub trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool>, // trusted |
| 96 | /// (Optional) Contains either absolute path to GPG keyring or embedded GPG public key block, if not set APT uses all trusted keys; |
| 97 | /// I can't find example of using with fingerprints |
| 98 | pub signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Signaturerust-analyzer cargo apt-sources 0.3.0 signature/Signature#>, // signed-by |
| 99 | } |
| 100 | |
| 101 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 102 | fn defaultrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][Default]default().() -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][Default] { |
| 103 | Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][Default] { |
| 104 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: true, |
| 105 | typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#, |
| 106 | urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: "http://nowhere.com".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 107 | suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: "none".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 108 | componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 109 | architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 110 | languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 111 | targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 112 | pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 113 | by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 114 | allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure.: false, |
| 115 | allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak.: false, |
| 116 | allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure.: false, |
| 117 | trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 118 | signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | impl LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 124 | /// In the ideal world we'd manage to use deserialization from a new format handling, but I'm not there yet to lift this for this format |
| 125 | fn assign_option_fieldrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository]assign_option_field().(&mut self, key: &str, value: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#> { |
| 126 | match key { |
| 127 | "arch" => self.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures. = value.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 128 | "lang" => self.languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages. = value.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 129 | "target" => self.targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets. = value.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 130 | "pdiffs" => self.pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo apt-sources 0.3.0 crate/::deserialize_yesnorust-analyzer cargo apt-sources 0.3.0 deserialize_yesno().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 131 | "by-hash" => self.by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(YesNoForcerust-analyzer cargo apt-sources 0.3.0 YesNoForce#::from_strrust-analyzer cargo apt-sources 0.3.0 impl#[YesNoForce][FromStr]from_str().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 132 | "allow-insecure" => self.allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure. = superrust-analyzer cargo apt-sources 0.3.0 crate/::deserialize_yesnorust-analyzer cargo apt-sources 0.3.0 deserialize_yesno().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., // , default no |
| 133 | "allow-weak" => self.allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak. = superrust-analyzer cargo apt-sources 0.3.0 crate/::deserialize_yesnorust-analyzer cargo apt-sources 0.3.0 deserialize_yesno().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., // , default no |
| 134 | "allow-downgrade-to-insecure" => { |
| 135 | self.allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure. = superrust-analyzer cargo apt-sources 0.3.0 crate/::deserialize_yesnorust-analyzer cargo apt-sources 0.3.0 deserialize_yesno().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 136 | } // , default no |
| 137 | "trusted" => self.trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo apt-sources 0.3.0 crate/::deserialize_yesnorust-analyzer cargo apt-sources 0.3.0 deserialize_yesno().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), // default not present is a third state |
| 138 | "signed-by" => self.signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Signaturerust-analyzer cargo apt-sources 0.3.0 signature/Signature#::KeyPathrust-analyzer cargo apt-sources 0.3.0 signature/Signature#KeyPath#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(value))), |
| 139 | any => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::UnrecognizedFieldNamerust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#UnrecognizedFieldName#(any.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 140 | }; |
| 141 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /// Container for multiple `LegacyRepository` specifications as single `.list` file may contain as per specification |
| 146 | #[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:)] |
| 147 | pub struct LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#>); |
| 148 | |
| 149 | impl LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories# { |
| 150 | /// Creates empty container of repositories |
| 151 | pub fn emptyrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]empty().() -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories] { |
| 152 | Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories](Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()) |
| 153 | } |
| 154 | |
| 155 | /// Creates repositories from container consisting `Repository` instances |
| 156 | pub fn newrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]new().<Container>(container: Container) -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories] |
| 157 | where |
| 158 | Container: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#>>, |
| 159 | { |
| 160 | Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories](container.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) |
| 161 | } |
| 162 | |
| 163 | /// Provides iterator over individual repositories in the whole file |
| 164 | pub fn repositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]repositories().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#> { |
| 165 | // TODO: that's by ref, not compatible with lossless |
| 166 | self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 167 | } |
| 168 | |
| 169 | /// Push a new repository |
| 170 | pub fn pushrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]push().(&mut self, repo: LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#) { |
| 171 | self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(repo); |
| 172 | } |
| 173 | |
| 174 | /// Retain repositories matching a predicate |
| 175 | pub fn retainrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]retain().<F>(&mut self, f: F) |
| 176 | where |
| 177 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(&LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#) -> bool, |
| 178 | { |
| 179 | self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(f); |
| 180 | } |
| 181 | |
| 182 | /// Get mutable iterator over repositories |
| 183 | pub fn iter_mutrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]iter_mut().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::IterMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/IterMut#<'_, LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#> { |
| 184 | self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().() |
| 185 | } |
| 186 | |
| 187 | /// Extend with an iterator of repositories |
| 188 | pub fn extendrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]extend().<I>(&mut self, iter: I) |
| 189 | where |
| 190 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#>, |
| 191 | { |
| 192 | self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(iter); |
| 193 | } |
| 194 | |
| 195 | /// Check if empty |
| 196 | pub fn is_emptyrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories]is_empty().(&self) -> bool { |
| 197 | self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | static RErust-analyzer cargo apt-sources 0.3.0 legacy/RE.: LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#<Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#> = LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/impl#[`LazyLock<T, F>`]new().(|| { |
| 202 | Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#::newrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]new().( |
| 203 | r"(?xm)^ |
| 204 | (?P<type>deb|deb-src)\s+ # Catch repository type |
| 205 | (\[(?P<options>[^]]*)]\s+)? # Catch options |
| 206 | (?P<uri>\S+)\s+ # Catch repository URI |
| 207 | (?P<suite>\S+)\s+ # Catch suite/distribution |
| 208 | (?P<components>(?:(?P<component>\w+)\s?)+) # Catch components (multiple) |
| 209 | $", |
| 210 | ) |
| 211 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Tested correct regular expression shall not fail!") |
| 212 | }); |
| 213 | |
| 214 | /// It only make sense to convert multiple lines at once as typical `.list` file has one uncommented |
| 215 | /// and one commented (`deb-src`) entry |
| 216 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories# { |
| 217 | type Errrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]Err# = RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#; |
| 218 | |
| 219 | fn from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(text: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr], Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 220 | let elements = RErust-analyzer cargo apt-sources 0.3.0 legacy/RE. |
| 221 | .captures_iterrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]captures_iter().(text) |
| 222 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|caps| { |
| 223 | let mut repository = LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#::defaultrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][Default]default().(); |
| 224 | repository.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ. = RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::from_strrust-analyzer cargo apt-sources 0.3.0 impl#[RepositoryType][FromStr]from_str().(&caps[rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index()."type"]rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 225 | let options = caps.namerust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]name().("options").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|o| o.as_strrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]as_str().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(""); |
| 226 | options |
| 227 | .trim_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_matches().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'[' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().']') |
| 228 | .split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().() |
| 229 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|o| { |
| 230 | o.splitnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]splitn().(2, '=') |
| 231 | .collect_tuplerust-analyzer cargo itertools 0.14.0 Itertools#collect_tuple().::<(&str, &str)>() |
| 232 | .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(RepositoryErrorrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#::InvalidFormatrust-analyzer cargo apt-sources 0.3.0 error/RepositoryError#InvalidFormat#) |
| 233 | }) |
| 234 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 235 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 236 | .try_for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#try_for_each().(|(k, v)| repository.assign_option_fieldrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository]assign_option_field().(k, v))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 237 | repository.urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri. = Urlrust-analyzer cargo url 2.5.8 Url#::from_strrust-analyzer cargo url 2.5.8 impl#[Url][FromStr]from_str().(&caps[rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index()."uri"]rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 238 | repository.suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite. = caps[rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index()."suite"]rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index()..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(); |
| 239 | repository |
| 240 | .componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components. |
| 241 | .extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(caps[rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index()."components"]rust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`][`Index<&'n str>`]index()..split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| c.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 242 | <Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#, Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#>>::Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(repository) |
| 243 | }) |
| 244 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, _>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 245 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr](elements)) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | impl Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories# { |
| 250 | type Targetrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][Deref]Target# = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#>; |
| 251 | |
| 252 | fn derefrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][Deref]deref().(&self) -> &Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 253 | &self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0. |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#> for superrust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# { |
| 258 | fn fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<&LegacyRepository>`]from().(original: &LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#) -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<&LegacyRepository>`] { |
| 259 | Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<&LegacyRepository>`] { |
| 260 | enabledrust-analyzer cargo apt-sources 0.3.0 Repository#enabled.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(original.enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.), // TODO: more valid one would be if true -> None else `Some(false)`... |
| 261 | typesrust-analyzer cargo apt-sources 0.3.0 Repository#types.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`][`From<[T; N]>`]from().([original.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ..clonerust-analyzer cargo apt-sources 0.3.0 impl#[RepositoryType][Clone]clone().()]), |
| 262 | urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![original.urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri..clonerust-analyzer cargo url 2.5.8 impl#[Url][Clone]clone().()], |
| 263 | suitesrust-analyzer cargo apt-sources 0.3.0 Repository#suites.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![original.suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()], |
| 264 | componentsrust-analyzer cargo apt-sources 0.3.0 Repository#components.: original.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 265 | architecturesrust-analyzer cargo apt-sources 0.3.0 Repository#architectures.: (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().original.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()) |
| 266 | .then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(original.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().()), |
| 267 | languagesrust-analyzer cargo apt-sources 0.3.0 Repository#languages.: (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().original.languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(original.languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().()), |
| 268 | targetsrust-analyzer cargo apt-sources 0.3.0 Repository#targets.: (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().original.targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(original.targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().()), |
| 269 | pdiffsrust-analyzer cargo apt-sources 0.3.0 Repository#pdiffs.: original.pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs., |
| 270 | by_hashrust-analyzer cargo apt-sources 0.3.0 Repository#by_hash.: original.by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash., |
| 271 | allow_insecurerust-analyzer cargo apt-sources 0.3.0 Repository#allow_insecure.: original.allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure..then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(true), |
| 272 | allow_weakrust-analyzer cargo apt-sources 0.3.0 Repository#allow_weak.: original.allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak..then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(true), |
| 273 | allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 Repository#allow_downgrade_to_insecure.: original.allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure..then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(true), |
| 274 | trustedrust-analyzer cargo apt-sources 0.3.0 Repository#trusted.: original.trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted., |
| 275 | signaturerust-analyzer cargo apt-sources 0.3.0 Repository#signature.: original.signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 276 | x_repolib_namerust-analyzer cargo apt-sources 0.3.0 Repository#x_repolib_name.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 277 | descriptionrust-analyzer cargo apt-sources 0.3.0 Repository#description.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#> for superrust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# { |
| 283 | fn fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<LegacyRepository>`]from().(original: LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#) -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<LegacyRepository>`] { |
| 284 | Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<LegacyRepository>`] { |
| 285 | enabledrust-analyzer cargo apt-sources 0.3.0 Repository#enabled.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(original.enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.), // TODO: more valid one would be if true -> None else `Some(false)`... |
| 286 | typesrust-analyzer cargo apt-sources 0.3.0 Repository#types.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`][`From<[T; N]>`]from().([original.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.]), |
| 287 | urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![original.urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.], |
| 288 | suitesrust-analyzer cargo apt-sources 0.3.0 Repository#suites.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![original.suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.], |
| 289 | componentsrust-analyzer cargo apt-sources 0.3.0 Repository#components.: original.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 290 | architecturesrust-analyzer cargo apt-sources 0.3.0 Repository#architectures.: (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().original.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(original.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures.), |
| 291 | languagesrust-analyzer cargo apt-sources 0.3.0 Repository#languages.: (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().original.languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(original.languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages.), |
| 292 | targetsrust-analyzer cargo apt-sources 0.3.0 Repository#targets.: (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().original.targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(original.targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets.), |
| 293 | pdiffsrust-analyzer cargo apt-sources 0.3.0 Repository#pdiffs.: original.pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs., |
| 294 | by_hashrust-analyzer cargo apt-sources 0.3.0 Repository#by_hash.: original.by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash., |
| 295 | allow_insecurerust-analyzer cargo apt-sources 0.3.0 Repository#allow_insecure.: original.allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure..then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(true), |
| 296 | allow_weakrust-analyzer cargo apt-sources 0.3.0 Repository#allow_weak.: original.allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak..then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(true), |
| 297 | allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 Repository#allow_downgrade_to_insecure.: original.allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure..then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(true), |
| 298 | trustedrust-analyzer cargo apt-sources 0.3.0 Repository#trusted.: original.trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted., |
| 299 | signaturerust-analyzer cargo apt-sources 0.3.0 Repository#signature.: original.signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature., |
| 300 | x_repolib_namerust-analyzer cargo apt-sources 0.3.0 Repository#x_repolib_name.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 301 | descriptionrust-analyzer cargo apt-sources 0.3.0 Repository#description.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#> for superrust-analyzer cargo apt-sources 0.3.0 crate/::Repositoriesrust-analyzer cargo apt-sources 0.3.0 Repositories# { |
| 307 | fn fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repositories`][`From<&LegacyRepositories>`]from().(original: &LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#) -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repositories`][`From<&LegacyRepositories>`] { |
| 308 | Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repositories`][`From<&LegacyRepositories>`](original.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|v| v.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()) |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#> for superrust-analyzer cargo apt-sources 0.3.0 crate/::Repositoriesrust-analyzer cargo apt-sources 0.3.0 Repositories# { |
| 313 | fn fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repositories`][`From<LegacyRepositories>`]from().(original: LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#) -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repositories`][`From<LegacyRepositories>`] { |
| 314 | Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repositories`][`From<LegacyRepositories>`](original.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|v| v.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()) |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&superrust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository#> for LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories# { |
| 319 | /// Convert a DEB822 Repository to legacy format lines. |
| 320 | /// Since a Repository can have multiple types/uris/suites, this may produce multiple lines. |
| 321 | fn fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][`From<&crate::Repository>`]from().(repo: &superrust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository#) -> Selfrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][`From<&crate::Repository>`] { |
| 322 | let mut repos = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 323 | |
| 324 | for typ in &repo.typesrust-analyzer cargo apt-sources 0.3.0 Repository#types. { |
| 325 | for uri in &repo.urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris. { |
| 326 | for suite in &repo.suitesrust-analyzer cargo apt-sources 0.3.0 Repository#suites. { |
| 327 | repos.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 328 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: repo.enabledrust-analyzer cargo apt-sources 0.3.0 Repository#enabled..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(true), |
| 329 | typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: typ.clonerust-analyzer cargo apt-sources 0.3.0 impl#[RepositoryType][Clone]clone().(), |
| 330 | urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: uri.clonerust-analyzer cargo url 2.5.8 impl#[Url][Clone]clone().(), |
| 331 | suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: suite.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), |
| 332 | componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: repo.componentsrust-analyzer cargo apt-sources 0.3.0 Repository#components..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 333 | architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures.: repo.architecturesrust-analyzer cargo apt-sources 0.3.0 Repository#architectures..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 334 | languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages.: repo.languagesrust-analyzer cargo apt-sources 0.3.0 Repository#languages..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 335 | targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets.: repo.targetsrust-analyzer cargo apt-sources 0.3.0 Repository#targets..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(), |
| 336 | pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs.: repo.pdiffsrust-analyzer cargo apt-sources 0.3.0 Repository#pdiffs., |
| 337 | by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash.: repo.by_hashrust-analyzer cargo apt-sources 0.3.0 Repository#by_hash., |
| 338 | allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure.: repo.allow_insecurerust-analyzer cargo apt-sources 0.3.0 Repository#allow_insecure..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false), |
| 339 | allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak.: repo.allow_weakrust-analyzer cargo apt-sources 0.3.0 Repository#allow_weak..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false), |
| 340 | allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure.: repo |
| 341 | .allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 Repository#allow_downgrade_to_insecure. |
| 342 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false), |
| 343 | trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted.: repo.trustedrust-analyzer cargo apt-sources 0.3.0 Repository#trusted., |
| 344 | signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature.: repo.signaturerust-analyzer cargo apt-sources 0.3.0 Repository#signature..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 345 | }); |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#(repos) |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | fn option_outputrust-analyzer cargo apt-sources 0.3.0 legacy/option_output().<O: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str> + Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#>(name: &str, option: &[O]) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 355 | if option.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 356 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("") |
| 357 | } else { |
| 358 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{name}={}", option.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().joinrust-analyzer cargo itertools 0.14.0 Itertools#join().(","))) |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 363 | fn fmtrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][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# { |
| 364 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", self.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 365 | // TODO: all options if any |
| 366 | |
| 367 | let options = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 368 | option_outputrust-analyzer cargo apt-sources 0.3.0 legacy/option_output().("arch", &self.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures.), |
| 369 | option_outputrust-analyzer cargo apt-sources 0.3.0 legacy/option_output().("lang", &self.languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages.), |
| 370 | option_outputrust-analyzer cargo apt-sources 0.3.0 legacy/option_output().("target", &self.targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets.), |
| 371 | self.pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs. |
| 372 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("pdiff={}", if p { "yes" } else { "no" }))) |
| 373 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("")), |
| 374 | self.by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash. |
| 375 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("by-hash={p}"))) |
| 376 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("")), |
| 377 | if self.allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure. { |
| 378 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#("allow-insecure=yes".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 379 | } else { |
| 380 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("") |
| 381 | }, |
| 382 | if self.allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak. { |
| 383 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#("allow-weak=yes".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 384 | } else { |
| 385 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("") |
| 386 | }, |
| 387 | if self.allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure. { |
| 388 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#("allow-downgrade-to-insecure=yes".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 389 | } else { |
| 390 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("") |
| 391 | }, |
| 392 | self.trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted. |
| 393 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|t| Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("trusted={}", if t { "yes" } else { "no" }))) |
| 394 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("")), |
| 395 | self.signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature. |
| 396 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 397 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| { |
| 398 | if let Signaturerust-analyzer cargo apt-sources 0.3.0 signature/Signature#::KeyPathrust-analyzer cargo apt-sources 0.3.0 signature/Signature#KeyPath#(ref p) = s { |
| 399 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("signed-by={}", p.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().())) |
| 400 | } else { |
| 401 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Short format not supported!") // TODO: design bug of LegacyRepository! |
| 402 | } |
| 403 | }) |
| 404 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("")), |
| 405 | ]; |
| 406 | let options = options.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|s| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().s.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().()).joinrust-analyzer cargo itertools 0.14.0 Itertools#join().(" "); |
| 407 | options.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().().notrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().().thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " [{options}]")); |
| 408 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " {}", self.urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 409 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " {}", self.suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 410 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, " {}", self.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components..joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(" ")) |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories# { |
| 415 | fn fmtrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][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# { |
| 416 | for (i, repo) in self.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 417 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 { |
| 418 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(f)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 419 | } |
| 420 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", repo)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 421 | } |
| 422 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | #[cfg(test)] |
| 427 | mod testsrust-analyzer cargo apt-sources 0.3.0 legacy/tests/ { |
| 428 | use craterust-analyzer cargo apt-sources 0.3.0 crate/::Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository#; |
| 429 | |
| 430 | use superrust-analyzer cargo apt-sources 0.3.0 legacy/::*; |
| 431 | use indocrust-analyzer cargo indoc 2.0.7 crate/::indocrust-analyzer cargo indoc 2.0.7 indoc!; |
| 432 | |
| 433 | const LONG_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/LONG_SAMPLE.: &str = indocrust-analyzer cargo indoc 2.0.7 indoc!!(" |
| 434 | deb [arch=arm64 signed-by=/usr/share/keyrings/rcn-ee-archive-keyring.gpg] http://debian.beagleboard.org/arm64/ jammy main |
| 435 | "); |
| 436 | const SHORT_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/SHORT_SAMPLE.: &str = indocrust-analyzer cargo indoc 2.0.7 indoc!!( |
| 437 | " |
| 438 | deb http://archive.ubuntu.com/ubuntu jammy main restricted |
| 439 | deb-src http://archive.ubuntu.com/ubuntu jammy main restricted |
| 440 | " |
| 441 | ); |
| 442 | const COMMENTED_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/COMMENTED_SAMPLE.: &str = indocrust-analyzer cargo indoc 2.0.7 indoc!!( |
| 443 | " |
| 444 | deb http://archive.ubuntu.com/ubuntu jammy main restricted |
| 445 | # deb-src http://archive.ubuntu.com/ubuntu jammy main restricted |
| 446 | " |
| 447 | ); |
| 448 | |
| 449 | fn golden_samplerust-analyzer cargo apt-sources 0.3.0 legacy/tests/golden_sample().() -> Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# { |
| 450 | // TODO: qualifies for lazy_static |
| 451 | Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# { |
| 452 | enabledrust-analyzer cargo apt-sources 0.3.0 Repository#enabled.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true), // TODO: looks odd, as only `Enabled: no` in meaningful |
| 453 | typesrust-analyzer cargo apt-sources 0.3.0 Repository#types.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`][`From<[T; N]>`]from().([RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#]), |
| 454 | architecturesrust-analyzer cargo apt-sources 0.3.0 Repository#architectures.: 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!!["arm64".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()]), |
| 455 | 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 Url#::from_strrust-analyzer cargo url 2.5.8 impl#[Url][FromStr]from_str().("http://debian.beagleboard.org/arm64/").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()], |
| 456 | 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_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()], |
| 457 | 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_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()]), |
| 458 | signaturerust-analyzer cargo apt-sources 0.3.0 Repository#signature.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Signaturerust-analyzer cargo apt-sources 0.3.0 signature/Signature#::KeyPathrust-analyzer cargo apt-sources 0.3.0 signature/Signature#KeyPath#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().( |
| 459 | "/usr/share/keyrings/rcn-ee-archive-keyring.gpg", |
| 460 | ))), |
| 461 | x_repolib_namerust-analyzer cargo apt-sources 0.3.0 Repository#x_repolib_name.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 462 | languagesrust-analyzer cargo apt-sources 0.3.0 Repository#languages.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 463 | targetsrust-analyzer cargo apt-sources 0.3.0 Repository#targets.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 464 | pdiffsrust-analyzer cargo apt-sources 0.3.0 Repository#pdiffs.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 465 | ..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().() |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 470 | fn test_legacy_repositories_from_strrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_legacy_repositories_from_str().() { |
| 471 | let repositories = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(LONG_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/LONG_SAMPLE.) |
| 472 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Shall not fail for correct list entry!"); |
| 473 | |
| 474 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 475 | let repository = repositories.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]nth().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 476 | |
| 477 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repository.enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled., true); |
| 478 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repository.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ., RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#); |
| 479 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repository.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures., vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["arm64".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()]); |
| 480 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 481 | repository.signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature., |
| 482 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Signaturerust-analyzer cargo apt-sources 0.3.0 signature/Signature#::KeyPathrust-analyzer cargo apt-sources 0.3.0 signature/Signature#KeyPath#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().( |
| 483 | "/usr/share/keyrings/rcn-ee-archive-keyring.gpg" |
| 484 | ))) |
| 485 | ); |
| 486 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repository.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ., RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#); |
| 487 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 488 | repository.urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri., |
| 489 | "http://debian.beagleboard.org/arm64/" |
| 490 | .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Urlrust-analyzer cargo url 2.5.8 Url#>() |
| 491 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 492 | ); |
| 493 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repository.suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite., "jammy".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 494 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repository.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components., vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["main".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()]); |
| 495 | } |
| 496 | |
| 497 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 498 | fn test_short_legacy_repositories_from_strrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_short_legacy_repositories_from_str().() { |
| 499 | let repositories = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(SHORT_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/SHORT_SAMPLE.) |
| 500 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Shall not fail for correct list entry!"); |
| 501 | |
| 502 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 503 | let bin_repository = repositories.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]nth().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 504 | let src_repository = repositories.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]nth().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 505 | |
| 506 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ., RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#); |
| 507 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(src_repository.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ., RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Sourcerust-analyzer cargo apt-sources 0.3.0 RepositoryType#Source#); |
| 508 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0); |
| 509 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(src_repository.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0); |
| 510 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 511 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(src_repository.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 512 | } |
| 513 | |
| 514 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 515 | #[ignore = "commented lines support not yet implemented"] |
| 516 | fn test_commented_legacy_repositories_from_strrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_commented_legacy_repositories_from_str().() { |
| 517 | let repositories = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(COMMENTED_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/COMMENTED_SAMPLE.) |
| 518 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Shall not fail for correct list entry!"); |
| 519 | |
| 520 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 521 | let bin_repository = repositories.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]nth().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 522 | let src_repository = repositories.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]nth().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 523 | |
| 524 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled., true); |
| 525 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled., false); |
| 526 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ., RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#); |
| 527 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(src_repository.typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ., RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Sourcerust-analyzer cargo apt-sources 0.3.0 RepositoryType#Source#); |
| 528 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0); |
| 529 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(src_repository.architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0); |
| 530 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bin_repository.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 531 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(src_repository.componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 532 | } |
| 533 | |
| 534 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 535 | fn test_conversion_from_legacy_to_deb822rust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_conversion_from_legacy_to_deb822().() { |
| 536 | let repositories = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(LONG_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/LONG_SAMPLE.) |
| 537 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Shall not fail for correct list entry!"); |
| 538 | |
| 539 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 540 | let legacy_repository = repositories.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]nth().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 541 | |
| 542 | let deb822_repository = Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository#::fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<&LegacyRepository>`]from().(legacy_repository); |
| 543 | let golden_sample = golden_samplerust-analyzer cargo apt-sources 0.3.0 legacy/tests/golden_sample().(); |
| 544 | |
| 545 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(golden_sample, deb822_repository); |
| 546 | } |
| 547 | |
| 548 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 549 | fn test_moving_conversion_from_legacy_to_deb822rust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_moving_conversion_from_legacy_to_deb822().() { |
| 550 | let mut repositories = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(LONG_SAMPLErust-analyzer cargo apt-sources 0.3.0 legacy/tests/LONG_SAMPLE.) |
| 551 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Shall not fail for correct list entry!"); |
| 552 | |
| 553 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repositories.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 554 | let legacy_repository = repositories.0rust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#0..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); // TODO: To make it work for user we'd need `DerefMut` but I'm reluctant |
| 555 | |
| 556 | let deb822_repository = Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository#::fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[`crate::Repository`][`From<LegacyRepository>`]from().(legacy_repository); |
| 557 | let golden_sample = golden_samplerust-analyzer cargo apt-sources 0.3.0 legacy/tests/golden_sample().(); |
| 558 | |
| 559 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(golden_sample, deb822_repository); |
| 560 | } |
| 561 | |
| 562 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 563 | fn test_display_of_simple_legacy_repositoryrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_display_of_simple_legacy_repository().() { |
| 564 | let sample = LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 565 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: true, |
| 566 | typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#, |
| 567 | urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: "http://debian.beagleboard.org/arm64/".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 568 | suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: "jammy".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 569 | componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: 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().()], |
| 570 | architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 571 | languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 572 | targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 573 | pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 574 | by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 575 | allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure.: false, |
| 576 | allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak.: false, |
| 577 | allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure.: false, |
| 578 | trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 579 | signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 580 | }; |
| 581 | let list_text = sample.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 582 | |
| 583 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 584 | list_text, |
| 585 | "deb http://debian.beagleboard.org/arm64/ jammy main" |
| 586 | ) |
| 587 | } |
| 588 | |
| 589 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 590 | fn test_display_of_legacy_repository_with_optionsrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_display_of_legacy_repository_with_options().() { |
| 591 | let sample = LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 592 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: true, |
| 593 | typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#, |
| 594 | urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: "http://debian.beagleboard.org/arm64/".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 595 | suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: "jammy".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 596 | componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: 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().()], |
| 597 | architecturesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#architectures.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["amd64".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()], |
| 598 | languagesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#languages.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 599 | targetsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#targets.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 600 | pdiffsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#pdiffs.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 601 | by_hashrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#by_hash.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 602 | allow_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_insecure.: false, |
| 603 | allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak.: false, |
| 604 | allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure.: false, |
| 605 | trustedrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#trusted.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 606 | signaturerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#signature.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Signaturerust-analyzer cargo apt-sources 0.3.0 signature/Signature#::KeyPathrust-analyzer cargo apt-sources 0.3.0 signature/Signature#KeyPath#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().( |
| 607 | "/usr/share/keyrings/rcn-ee-archive-keyring.gpg", |
| 608 | ))), // TODO: `.list` supports only key files, no way to fit PGP block |
| 609 | }; |
| 610 | let list_text = sample.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 611 | |
| 612 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 613 | list_text, |
| 614 | "deb [arch=amd64 signed-by=/usr/share/keyrings/rcn-ee-archive-keyring.gpg] http://debian.beagleboard.org/arm64/ jammy main" |
| 615 | ) |
| 616 | } |
| 617 | |
| 618 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 619 | fn test_conversion_from_deb822_to_legacyrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_conversion_from_deb822_to_legacy().() { |
| 620 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#; |
| 621 | |
| 622 | let repo = Repositoryrust-analyzer cargo apt-sources 0.3.0 Repository# { |
| 623 | enabledrust-analyzer cargo apt-sources 0.3.0 Repository#enabled.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(true), |
| 624 | typesrust-analyzer cargo apt-sources 0.3.0 Repository#types.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`][`From<[T; N]>`]from().([RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#, RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Sourcerust-analyzer cargo apt-sources 0.3.0 RepositoryType#Source#]), |
| 625 | urisrust-analyzer cargo apt-sources 0.3.0 Repository#uris.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["http://archive.ubuntu.com/ubuntu".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()], |
| 626 | 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().()], |
| 627 | 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().(), "universe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()]), |
| 628 | architecturesrust-analyzer cargo apt-sources 0.3.0 Repository#architectures.: 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!!["amd64".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()]), |
| 629 | ..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().() |
| 630 | }; |
| 631 | |
| 632 | let legacy = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::fromrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][`From<&crate::Repository>`]from().(&repo); |
| 633 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(legacy.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); // One for deb, one for deb-src |
| 634 | |
| 635 | let legacy_str = legacy.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 636 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(legacy_str.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("deb [arch=amd64]")); |
| 637 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(legacy_str.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("deb-src [arch=amd64]")); |
| 638 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(legacy_str.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("http://archive.ubuntu.com/ubuntu")); |
| 639 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(legacy_str.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("jammy main universe")); |
| 640 | } |
| 641 | |
| 642 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 643 | fn test_legacy_repositories_displayrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_legacy_repositories_display().() { |
| 644 | let repos = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 645 | LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 646 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: true, |
| 647 | typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#, |
| 648 | urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: "http://example.com/ubuntu".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 649 | suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: "jammy".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 650 | componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: 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().()], |
| 651 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][Default]default().() |
| 652 | }, |
| 653 | LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 654 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: true, |
| 655 | typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Sourcerust-analyzer cargo apt-sources 0.3.0 RepositoryType#Source#, |
| 656 | urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: "http://example.com/ubuntu".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 657 | suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: "jammy".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 658 | componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: 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().()], |
| 659 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][Default]default().() |
| 660 | }, |
| 661 | ]); |
| 662 | |
| 663 | let display = repos.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 664 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 665 | display, |
| 666 | "deb http://example.com/ubuntu jammy main\ndeb-src http://example.com/ubuntu jammy main" |
| 667 | ); |
| 668 | } |
| 669 | |
| 670 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 671 | fn test_allow_downgrade_to_insecure_parsingrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_allow_downgrade_to_insecure_parsing().() { |
| 672 | let input = "deb [allow-downgrade-to-insecure=yes] http://example.com/ubuntu jammy main\n"; |
| 673 | let repos = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 674 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(repos.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 675 | let repo = repos.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]nth().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 676 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(repo.allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure.); |
| 677 | 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().repo.allow_weakrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_weak.); |
| 678 | } |
| 679 | |
| 680 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 681 | fn test_allow_downgrade_to_insecure_displayrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_allow_downgrade_to_insecure_display().() { |
| 682 | let repo = LegacyRepositoryrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository# { |
| 683 | enabledrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#enabled.: true, |
| 684 | typrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#typ.: RepositoryTyperust-analyzer cargo apt-sources 0.3.0 RepositoryType#::Binaryrust-analyzer cargo apt-sources 0.3.0 RepositoryType#Binary#, |
| 685 | urirust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#uri.: "http://example.com/ubuntu".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 686 | suiterust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#suite.: "jammy".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 687 | componentsrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#components.: 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().()], |
| 688 | allow_downgrade_to_insecurerust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepository#allow_downgrade_to_insecure.: true, |
| 689 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepository][Default]default().() |
| 690 | }; |
| 691 | let text = repo.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 692 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 693 | text, |
| 694 | "deb [allow-downgrade-to-insecure=yes] http://example.com/ubuntu jammy main" |
| 695 | ); |
| 696 | } |
| 697 | |
| 698 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 699 | fn test_malformed_option_without_equalsrust-analyzer cargo apt-sources 0.3.0 legacy/tests/test_malformed_option_without_equals().() { |
| 700 | let input = "deb [badoption] http://example.com/ubuntu jammy main\n"; |
| 701 | let result = LegacyRepositoriesrust-analyzer cargo apt-sources 0.3.0 legacy/LegacyRepositories#::from_strrust-analyzer cargo apt-sources 0.3.0 legacy/impl#[LegacyRepositories][FromStr]from_str().(input); |
| 702 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 703 | } |
| 704 | } |