From 86a7364542e9148d194fa79a841cd7b5a38472c2 Mon Sep 17 00:00:00 2001 From: Bazaah Date: Sat, 28 May 2022 11:30:02 +0000 Subject: [PATCH] lib/value: placeholder public api for the Yaml type --- src/lib.rs | 1 + src/value.rs | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 src/value.rs diff --git a/src/lib.rs b/src/lib.rs index ed3d652..6d8d29a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,7 @@ pub use error::Error; pub mod error; pub mod event; pub mod reader; +pub mod value; mod node; mod queue; diff --git a/src/value.rs b/src/value.rs new file mode 100644 index 0000000..14abc26 --- /dev/null +++ b/src/value.rs @@ -0,0 +1,152 @@ +#![allow(missing_docs)] + +use std::{marker::PhantomData, sync::Arc}; + +use crate::{error::Result, reader::Read}; + +pub struct Yaml +{ + inner: Option>, + _mkr: PhantomData, +} + +impl Yaml +{ + pub fn load(src: R) -> Result + where + R: Read, + { + todo!() + } + + /// Fetch a scalar datum from the given .path + /// + /// May return an empty scalar (`len==0`,`style=Plain`) + /// if the scalar does not exist + pub fn scalar

(&self, path: P) -> Scalar<'_> + where + P: AsPath, + { + todo!() + } + + /// Fetch a scalar datum from the given .path + /// + /// May return `None` if the scalar does not exist + pub fn get_scalar

(&self, path: P) -> Option> + where + P: AsPath, + { + todo!() + } + + /// Fetch a scalar datum from the given .path + /// + /// May return an error explaining what went wrong + pub fn try_scalar

(&self, path: P) -> Result> + where + P: AsPath, + { + todo!() + } + + /// Create a new [`Yaml`] view using the node at .path + /// as the new root + /// + /// The returned view may be empty if the node does not + /// exist + pub fn node

(&self, path: P) -> Yaml + where + P: AsPath, + { + todo!() + } + + /* + * use YARY::path as p; + * let yaml = ...; + * let vec = yaml.node(~["name", 5, "name"]); + * + * vec.scalar(1) + */ + + /// Create a new [`Yaml`] view using the node at .path + /// as the new root + /// + /// May return `None` if the node does not exist + pub fn get_node

(&self, path: P) -> Option + where + P: AsPath, + { + todo!() + } + + /// Create a new [`Yaml`] view using the node at .path + /// as the new root + /// + /// May return an error explaining what went wrong + pub fn try_node

(&self, path: P) -> Result + where + P: AsPath, + { + todo!() + } +} + +impl Yaml +{ + pub fn lazy(src: R) -> Self + where + R: Read, + { + todo!() + } + + pub fn load(self) -> Result + { + todo!() + } + + pub fn node_at

(&mut self, path: P) -> Result> + where + P: AsPath, + { + todo!() + } + + pub fn touch

(&mut self, path: P) -> Result + where + P: AsPath, + { + todo!() + } + + pub fn freeze(&mut self) -> Yaml + { + todo!() + } + + pub fn freeze_at

(&mut self, path: P) -> Result + where + P: AsPath, + { + todo!() + } +} + +pub struct Scalar<'a> +{ + s: &'a str, +} + +pub struct NodeRef<'a> +{ + _mkr: &'a str, +} + +pub trait AsPath {} + +struct Node; + +pub struct Eager; +pub struct Lazy;