1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#![deny(missing_docs)]
#![deny(clippy::all)]
#![deny(unsafe_code)]
#[cfg(test)]
#[macro_use]
extern crate rust_releases_io;
use crate::fetch::{fetch_meta_manifest, fetch_release_manifests};
use crate::meta_manifest::MetaManifest;
use crate::release_manifest::parse_release_manifest;
use rust_releases_core::{Channel, FetchResources, Release, ReleaseIndex, Source};
use rust_releases_io::Document;
use std::collections::BTreeSet;
use std::iter::FromIterator;
pub(crate) mod errors;
pub(crate) mod fetch;
pub(crate) mod meta_manifest;
pub(crate) mod release_manifest;
pub use errors::{ChannelManifestsError, ChannelManifestsResult};
#[deprecated]
pub struct ChannelManifests {
documents: Vec<Document>,
}
#[allow(deprecated)]
impl Source for ChannelManifests {
type Error = ChannelManifestsError;
fn build_index(&self) -> Result<ReleaseIndex, Self::Error> {
let releases = self
.documents
.iter()
.map(|document| {
document
.load()
.map_err(ChannelManifestsError::RustReleasesIoError)
.and_then(|content| parse_release_manifest(&content).map(Release::new_stable))
})
.collect::<ChannelManifestsResult<BTreeSet<_>>>()?;
Ok(ReleaseIndex::from_iter(releases))
}
}
#[allow(deprecated)]
impl FetchResources for ChannelManifests {
type Error = ChannelManifestsError;
fn fetch_channel(channel: Channel) -> Result<Self, Self::Error> {
let source = fetch_meta_manifest()?;
let content = source.load()?;
let content =
String::from_utf8(content).map_err(|_| ChannelManifestsError::ParseMetaManifest)?;
let meta_manifest = MetaManifest::try_from_str(&content)?;
let release_manifests = fetch_release_manifests(&meta_manifest, channel)?;
Ok(Self {
documents: release_manifests,
})
}
}