rust_releases_core/lib.rs
1//! Defines the core routines required to implement a [`Source`].
2//!
3//! Please, see the [`rust-releases`] for additional documentation on how this crate can be used.
4//!
5//! [`Source`]: crate::Source
6//! [`rust-releases`]: https://docs.rs/rust-releases
7#![deny(missing_docs)]
8#![deny(clippy::all)]
9#![deny(unsafe_code)]
10
11/// Defines release channels, such as the stable, beta and nightly release channels.
12pub(crate) mod channel;
13
14/// Errors for this crate.
15pub(crate) mod errors;
16
17/// Defines the `ReleaseIndex`.
18pub(crate) mod index;
19
20/// Defines a `Release`
21pub(crate) mod release;
22
23/// Re-export the semver crate to the root scope
24pub use semver;
25
26pub use crate::{
27 channel::Channel, errors::CoreError, errors::CoreResult, index::ReleaseIndex, release::Release,
28};
29
30/// A `Source` is a set of inputs from which a release index can be built.
31pub trait Source {
32 /// The error to be returned when an index can not be build for a source.
33 type Error;
34
35 /// Build a release index from a data set.
36 fn build_index(&self) -> Result<ReleaseIndex, Self::Error>;
37}
38
39/// With `FetchResources`, the set of inputs required to build a release index can be fetched.
40pub trait FetchResources
41where
42 Self: Sized,
43{
44 /// The error to be returned when a resource can not be fetched.
45 type Error;
46
47 /// Fetch a set of inputs for a release channel.
48 fn fetch_channel(channel: Channel) -> Result<Self, Self::Error>;
49}