workyard-application 0.1.0

Task actions and interface contracts for Workyard
Documentation
use serde::Serialize;
use trine::NativePath;
use workyard_core::Participant;

/// Participant placement and progress exposed to clients.
#[derive(Serialize)]
pub struct ParticipantOutcome {
	/// Name used to identify this entry.
	pub name: String,
	/// Filesystem path associated with this entry.
	pub path: NativePath,
	/// Step reached by this participant.
	pub phase: String,
}

impl From<Participant> for ParticipantOutcome {
	fn from(participant: Participant) -> Self {
		Self {
			name: participant.name,
			path: NativePath::new(participant.destination).expect("validated filesystem path"),
			phase: participant.phase.as_str().into(),
		}
	}
}

#[derive(Serialize)]
pub struct ParticipantChange {
	pub participant: String,
	pub kind: &'static str,
}

impl From<workyard_core::AmendmentChange> for ParticipantChange {
	fn from(change: workyard_core::AmendmentChange) -> Self {
		Self {
			participant: change.participant,
			kind: change.kind.as_str(),
		}
	}
}