superfusion/
project.rs

1use super::prelude::IndexList;
2use std::fmt;
3use std::path::Path;
4
5/// A unique Project ID that can be easily copy.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub struct Pid(usize);
8
9impl Pid {
10	pub fn new(id: usize) -> Self {
11		Self(id)
12	}
13
14	pub fn value(&self) -> usize {
15		self.0
16	}
17}
18
19impl fmt::Display for Pid {
20	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21		write!(f, "#{}", self.0)
22	}
23}
24
25/// Conflict handling strategy.
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub enum Strategy {
28	/// This strategy will cause [File::merge](../file/trait.File.html#method.merge) method to be call.
29	Merge,
30	/// This strategy will cause the file to be rename to some unique name and [File::modify_relation](../file/trait.File.html#method.modify_relation) method to be call on related files.
31	Rename,
32	/// This strategy will cause the file to override the conflicted file entirely.
33	Replace,
34}
35
36/// Project interface representing a single project directory.
37pub trait Project {
38	/// Path to the root of the project directory
39	fn root(&self) -> &Path;
40	/// Pid of this project
41	fn pid(&self) -> Pid;
42
43	/// Return [IndexList](../index/struct.IndexList.html) of all indexes inside this project.
44	fn indexes(&self) -> IndexList;
45}