mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Add InstanceMetadata builder (#269)
* Add InstanceMetadata builder, with context field for globbing * Revert snapshot changes * Port snapshot functions to InstanceMetadata builder-ish pattern * Remove IgnoreGlob struct * Elide lifetime
This commit is contained in:
committed by
GitHub
parent
da6c7b4d7a
commit
a48c238ed7
@@ -1,4 +1,7 @@
|
||||
use std::{fmt, path::PathBuf};
|
||||
use std::{
|
||||
fmt,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -42,14 +45,41 @@ pub struct InstanceMetadata {
|
||||
pub relevant_paths: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl Default for InstanceMetadata {
|
||||
fn default() -> Self {
|
||||
InstanceMetadata {
|
||||
impl InstanceMetadata {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
ignore_unknown_instances: false,
|
||||
instigating_source: None,
|
||||
relevant_paths: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ignore_unknown_instances(self, ignore_unknown_instances: bool) -> Self {
|
||||
Self {
|
||||
ignore_unknown_instances,
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn instigating_source(self, instigating_source: impl Into<InstigatingSource>) -> Self {
|
||||
Self {
|
||||
instigating_source: Some(instigating_source.into()),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn relevant_paths(self, relevant_paths: Vec<PathBuf>) -> Self {
|
||||
Self {
|
||||
relevant_paths,
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for InstanceMetadata {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -74,3 +104,9 @@ impl From<PathBuf> for InstigatingSource {
|
||||
InstigatingSource::Path(path)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Path> for InstigatingSource {
|
||||
fn from(path: &Path) -> Self {
|
||||
InstigatingSource::Path(path.to_path_buf())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user