Review closed semantic constructor groups with retained typed drafts
This commit is contained in:
@@ -5,12 +5,14 @@ use super::*;
|
||||
pub(super) fn selector() -> FacetSelector {
|
||||
FacetSelector::Occurrence(OccurrenceFacet::MessageKind)
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub(super) fn timer_selector() -> FacetSelector {
|
||||
FacetSelector::Occurrence(OccurrenceFacet::TimerExpression)
|
||||
}
|
||||
pub(super) fn handles(facet: &FacetSelector) -> bool {
|
||||
*facet == selector()
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub(super) fn value(project: &Project, id: Id) -> Option<&MessageKind> {
|
||||
match project.elements.get(&id)?.shared()? {
|
||||
SharedBody::Occurrence {
|
||||
@@ -20,13 +22,3 @@ pub(super) fn value(project: &Project, id: Id) -> Option<&MessageKind> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub(super) fn available(project: &Project, trace: &Trace) -> bool {
|
||||
value(project, trace.oa).is_some() && value(project, trace.sa).is_some()
|
||||
}
|
||||
/// MessageConstructor observations contain only the discriminator. Taking a
|
||||
/// replacing group needs the complete typed payload, including Timer.expression.
|
||||
pub(super) fn source_value(project: &Project, id: Id) -> Result<Value, String> {
|
||||
let value =
|
||||
value(project, id).ok_or("Message kind requires an existing Exchange occurrence.")?;
|
||||
serde_json::to_value(value).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user