use radicle_core::{NodeId, RepoId};
use crate::fetcher::RefsToFetch;
use super::FetchConfig;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Command {
Fetch(Fetch),
Fetched(Fetched),
Cancel(Cancel),
}
impl From<Fetch> for Command {
fn from(v: Fetch) -> Self {
Self::Fetch(v)
}
}
impl From<Fetched> for Command {
fn from(v: Fetched) -> Self {
Self::Fetched(v)
}
}
impl From<Cancel> for Command {
fn from(v: Cancel) -> Self {
Self::Cancel(v)
}
}
impl Command {
pub fn fetch(from: NodeId, rid: RepoId, refs: RefsToFetch, config: FetchConfig) -> Self {
Self::from(Fetch {
from,
rid,
refs,
config,
})
}
pub fn fetched(from: NodeId, rid: RepoId) -> Self {
Self::from(Fetched { from, rid })
}
pub fn cancel(from: NodeId) -> Self {
Self::from(Cancel { from })
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Fetch {
pub from: NodeId,
pub rid: RepoId,
pub refs: RefsToFetch,
pub config: FetchConfig,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Fetched {
pub from: NodeId,
pub rid: RepoId,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Cancel {
pub from: NodeId,
}