diff --git a/oca/src/facade/build.rs b/oca/src/facade/build.rs index c884d8d..042437a 100644 --- a/oca/src/facade/build.rs +++ b/oca/src/facade/build.rs @@ -293,7 +293,7 @@ impl Facade { let mut input: Vec = vec![]; match &step.parent_said { Some(said) => { - input.push(said.to_string().as_bytes().len().try_into().unwrap()); + input.push(said.to_string().len().try_into().unwrap()); input.extend(said.to_string().as_bytes()); } None => { @@ -358,7 +358,7 @@ impl Facade { let mut input: Vec = vec![]; match &capture_base_model.parent { Some(said) => { - input.push(said.to_string().as_bytes().len().try_into().unwrap()); + input.push(said.to_string().len().try_into().unwrap()); input.extend(said.to_string().as_bytes()); } None => { @@ -369,9 +369,7 @@ impl Facade { input.push( capture_base_model .command_digest - .to_string() - .as_bytes() - .len() + .to_string().len() .try_into() .unwrap(), ); @@ -390,7 +388,7 @@ impl Facade { let mut input: Vec = vec![]; match &overlay_model.parent { Some(said) => { - input.push(said.to_string().as_bytes().len().try_into().unwrap()); + input.push(said.to_string().len().try_into().unwrap()); input.extend(said.to_string().as_bytes()); } None => { @@ -401,9 +399,7 @@ impl Facade { input.push( overlay_model .command_digest - .to_string() - .as_bytes() - .len() + .to_string().len() .try_into() .unwrap(), ); @@ -422,7 +418,7 @@ impl Facade { let mut input: Vec = vec![]; match &oca_bundle_model.parent { Some(said) => { - input.push(said.to_string().as_bytes().len().try_into().unwrap()); + input.push(said.to_string().len().try_into().unwrap()); input.extend(said.to_string().as_bytes()); } None => { @@ -433,16 +429,14 @@ impl Facade { input.push( oca_bundle_model .capture_base_said - .to_string() - .as_bytes() - .len() + .to_string().len() .try_into() .unwrap(), ); input.extend(oca_bundle_model.capture_base_said.to_string().as_bytes()); for said in &oca_bundle_model.overlays_said { - input.push(said.to_string().as_bytes().len().try_into().unwrap()); + input.push(said.to_string().len().try_into().unwrap()); input.extend(said.to_string().as_bytes()); } diff --git a/semantics/oca-bundle/src/state/oca.rs b/semantics/oca-bundle/src/state/oca.rs index d5451fd..5de713b 100644 --- a/semantics/oca-bundle/src/state/oca.rs +++ b/semantics/oca-bundle/src/state/oca.rs @@ -716,9 +716,9 @@ impl From for OCABox { .iter() .filter_map(|x| x.as_any().downcast_ref::()) .collect::>(); - for overlay in conditional_overlays { - let re = regex::Regex::new(r"\$\{(\d+)\}").unwrap(); + let re = regex::Regex::new(r"\$\{(\d+)\}").unwrap(); + for overlay in conditional_overlays { for (attr_name, condition) in overlay.attribute_conditions.iter() { let condition_dependencies = overlay.attribute_dependencies.get(attr_name).unwrap(); // todo let cond = re diff --git a/semantics/oca-bundle/src/state/oca/overlay/label.rs b/semantics/oca-bundle/src/state/oca/overlay/label.rs index dbea3c3..4744bef 100644 --- a/semantics/oca-bundle/src/state/oca/overlay/label.rs +++ b/semantics/oca-bundle/src/state/oca/overlay/label.rs @@ -237,32 +237,28 @@ mod tests { assert!(overlay .category_labels - .get(&"_cat-1_".to_string()) - .is_some()); - if let Some(cat1) = overlay.category_labels.get(&"_cat-1_".to_string()) { + .contains_key("_cat-1_")); + if let Some(cat1) = overlay.category_labels.get("_cat-1_") { assert_eq!(*cat1, "Cat 1".to_string()); } assert!(overlay .category_labels - .get(&"_cat-2_".to_string()) - .is_some()); - if let Some(cat2) = overlay.category_labels.get(&"_cat-2_".to_string()) { + .contains_key("_cat-2_")); + if let Some(cat2) = overlay.category_labels.get("_cat-2_") { assert_eq!(*cat2, "Cat 2".to_string()); } assert!(overlay ._category_attributes - .get(&"_cat-1_".to_string()) - .is_some()); - if let Some(cat1_attrs) = overlay._category_attributes.get(&"_cat-1_".to_string()) { + .contains_key("_cat-1_")); + if let Some(cat1_attrs) = overlay._category_attributes.get("_cat-1_") { assert_eq!(cat1_attrs.len(), 1); assert!(cat1_attrs.contains(&"attr1".to_string())); } assert!(overlay ._category_attributes - .get(&"_cat-2_".to_string()) - .is_some()); - if let Some(cat2_attrs) = overlay._category_attributes.get(&"_cat-2_".to_string()) { + .contains_key("_cat-2_")); + if let Some(cat2_attrs) = overlay._category_attributes.get("_cat-2_") { assert_eq!(cat2_attrs.len(), 1); assert!(cat2_attrs.contains(&"attr2".to_string())); } diff --git a/semantics/oca-dag/src/versioning/bundle.rs b/semantics/oca-dag/src/versioning/bundle.rs index 62209cc..1523bd0 100644 --- a/semantics/oca-dag/src/versioning/bundle.rs +++ b/semantics/oca-dag/src/versioning/bundle.rs @@ -15,13 +15,13 @@ impl From for Vec { fn from(val: OCABundleDTO) -> Self { let mut digests: Vec = Vec::new(); if let Some(ref said) = val.bundle.capture_base.said { - digests.push(said.to_string().as_bytes().len().try_into().unwrap()); + digests.push(said.to_string().len().try_into().unwrap()); digests.extend(said.to_string().as_bytes()); } val.bundle.overlays.iter().for_each(|overlay| { if let Some(ref said) = overlay.said() { - digests.push(said.to_string().as_bytes().len().try_into().unwrap()); + digests.push(said.to_string().len().try_into().unwrap()); // digests.push(overlay.overlay_type().into()); digests.extend(said.to_string().as_bytes()); } diff --git a/semantics/oca-dag/src/versioning/ocafile.rs b/semantics/oca-dag/src/versioning/ocafile.rs index 0c22002..c92e985 100644 --- a/semantics/oca-dag/src/versioning/ocafile.rs +++ b/semantics/oca-dag/src/versioning/ocafile.rs @@ -43,14 +43,14 @@ pub fn build_oca( match base { Some(ref mut base) => { let base_said = base.generate_bundle().said.unwrap().to_string(); - input.push(base_said.as_bytes().len().try_into().unwrap()); + input.push(base_said.len().try_into().unwrap()); input.extend(base_said.as_bytes()); } None => { input.push(0); } } - input.push(command_str.as_bytes().len().try_into().unwrap()); + input.push(command_str.len().try_into().unwrap()); input.extend(command_str.as_bytes()); db.insert( &format!("oca.{}.operation", oca_bundle.clone().said.unwrap()),