crate::ix!();
impl PartiallyGrownModel {
#[tracing::instrument(level = "trace", skip_all)]
pub fn try_filling_next_none_field_from_clipboard(&mut self) -> bool {
trace!("self={:#?}",self);
let mut did_fill = false;
if self.maybe_ungrown_justified_grower_tree_configuration().is_none() {
trace!("attempting parse clipboard as JustifiedGrowerTreeConfiguration");
match fuzzy_parse_clipboard_contents::<JustifiedGrowerTreeConfiguration>(false) {
Ok(val) => {
trace!("Clipboard provided a valid JustifiedGrowerTreeConfiguration => setting it.");
self.set_maybe_ungrown_justified_grower_tree_configuration(Some(val));
did_fill = true;
}
Err(e) => {
warn!("Fuzzy parse for JustifiedGrowerTreeConfiguration from clipboard failed => leaving None. Error: {:?}", e);
}
}
return did_fill;
}
if self.maybe_ungrown_justified_string_skeleton().is_none() {
trace!("attempting parse clipboard as JustifiedStringSkeleton");
match fuzzy_parse_clipboard_contents::<JustifiedStringSkeleton>(false) {
Ok(val) => {
trace!("Clipboard provided a valid JustifiedStringSkeleton => setting it.");
self.set_maybe_ungrown_justified_string_skeleton(Some(val));
did_fill = true;
}
Err(e) => {
warn!("Fuzzy parse for JustifiedStringSkeleton from clipboard failed => leaving None. Error: {:?}", e);
}
}
return did_fill;
}
if self.maybe_ungrown_stripped_string_skeleton().is_none() {
trace!("attempting parse clipboard as StrippedStringSkeleton");
match (|| -> Result<StrippedStringSkeleton, std::io::Error> {
let mut ctx = ClipboardContext::new().map_err(|e| {
std::io::Error::new(std::io::ErrorKind::Other, format!("Clipboard context error: {e}"))
})?;
let contents = ctx.get_contents().map_err(|e| {
std::io::Error::new(std::io::ErrorKind::Other, format!("Clipboard get_contents error: {e}"))
})?;
let json_val: serde_json::Value = serde_json::from_str(&contents).map_err(|e| {
std::io::Error::new(std::io::ErrorKind::InvalidData, format!("Clipboard JSON parsing error: {e}"))
})?;
let parsed = try_deserialize_with_path::<StrippedStringSkeleton>(&json_val).map_err(|e| {
std::io::Error::new(std::io::ErrorKind::InvalidData, format!("StrippedStringSkeleton parse error from clipboard: {e}"))
})?;
Ok(parsed)
})() {
Ok(parsed) => {
trace!("Clipboard provided a valid StrippedStringSkeleton => setting it.");
self.set_maybe_ungrown_stripped_string_skeleton(Some(parsed));
did_fill = true;
}
Err(e) => {
warn!("Parse for StrippedStringSkeleton from clipboard failed => leaving None. Error: {e}");
}
}
return did_fill;
}
if self.maybe_ungrown_core_string_skeleton().is_none() {
trace!("attempting parse clipboard as CoreStringSkeleton");
match fuzzy_parse_clipboard_contents::<CoreStringSkeleton>(false) {
Ok(val) => {
trace!("Clipboard provided a valid CoreStringSkeleton => setting it.");
self.set_maybe_ungrown_core_string_skeleton(Some(val));
did_fill = true;
}
Err(e) => {
warn!("Fuzzy parse for CoreStringSkeleton from clipboard failed => leaving None. Error: {:?}", e);
}
}
return did_fill;
}
if self.maybe_ungrown_annotated_leaf_holder_expansions().is_none() {
trace!("attempting parse clipboard as AnnotatedLeafHolderExpansions");
match fuzzy_parse_clipboard_contents::<AnnotatedLeafHolderExpansions>(false) {
Ok(val) => {
trace!("Clipboard provided a valid AnnotatedLeafHolderExpansions => setting it.");
self.set_maybe_ungrown_annotated_leaf_holder_expansions(Some(val));
did_fill = true;
}
Err(e) => {
warn!("Fuzzy parse for AnnotatedLeafHolderExpansions failed => leaving None. Error: {:?}", e);
}
}
return did_fill;
}
trace!("All optional fields are already set; nothing to fill from clipboard.");
did_fill
}
}