-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1089 from rainlanguage/2024-12-18-dotrain-yaml
Creating DotrainYaml struct
- Loading branch information
Showing
3 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use super::*; | ||
use std::sync::{Arc, RwLock}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct DotrainYaml { | ||
pub document: Arc<RwLock<StrictYaml>>, | ||
} | ||
|
||
impl YamlParsable for DotrainYaml { | ||
fn new(source: String, _validate: bool) -> Result<Self, YamlError> { | ||
let docs = StrictYamlLoader::load_from_str(&source)?; | ||
if docs.is_empty() { | ||
return Err(YamlError::EmptyFile); | ||
} | ||
let doc = docs[0].clone(); | ||
let document = Arc::new(RwLock::new(doc)); | ||
|
||
Ok(DotrainYaml { document }) | ||
} | ||
} | ||
|
||
impl DotrainYaml {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters