git-next/crates/repo-actor/src/messages.rs

43 lines
1.4 KiB
Rust

//
use config::newtype;
use derive_more::Display;
use git_next_actor_macros::message;
use git_next_config as config;
use git_next_git as git;
message!(LoadConfigFromRepo);
message!(CloneRepo);
message!(ReceiveRepoConfig wraps config::RepoConfig);
message!(ValidateRepo wraps MessageToken);
message!(WebhookRegistered wraps (config::WebhookId, config::WebhookAuth));
impl WebhookRegistered {
pub const fn webhook_id(&self) -> &config::WebhookId {
&self.0 .0
}
pub const fn webhook_auth(&self) -> &config::WebhookAuth {
&self.0 .1
}
}
impl From<config::RegisteredWebhook> for WebhookRegistered {
fn from(value: config::RegisteredWebhook) -> Self {
let webhook_id = value.id().clone();
let webhook_auth = value.auth().clone();
Self::from((webhook_id, webhook_auth))
}
}
newtype!(MessageToken is a u32, Copy, Default, Display);
impl MessageToken {
pub const fn next(&self) -> Self {
Self(self.0 + 1)
}
}
message!(RegisterWebhook);
message!(CheckCIStatus wraps git::Commit); // next commit
message!(ReceiveCIStatus wraps (git::Commit, git::forge::commit::Status)); // commit and it's status
message!(AdvanceNext wraps (git::Commit, Vec<git::Commit>)); // next commit and the dev commit history
message!(AdvanceMain wraps git::Commit); // next commit
message!(WebhookNotification wraps config::webhook::forge_notification::ForgeNotification);