pub enum Outcome {
Accepted,
AwaitingDeps(Vec<AnyDhtHash>),
Rejected(String),
}
Expand description
The outcome of sys validation
Variants§
Accepted
Moves to integration
AwaitingDeps(Vec<AnyDhtHash>)
Stays in limbo because a dependency needs is required to validate and could not be found
Rejected(String)
Moves to integration with status rejected
Implementations§
source§impl Outcome
impl Outcome
sourcepub fn awaiting<E, I: Into<AnyDhtHash> + Clone>(
h: &I
) -> OutcomeOrError<Self, E>
pub fn awaiting<E, I: Into<AnyDhtHash> + Clone>(
h: &I
) -> OutcomeOrError<Self, E>
Helper function for creating awaiting deps and exiting when the dependency isn’t found
Examples found in repository?
src/core/workflow/app_validation_workflow.rs (line 345)
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
async fn dhtop_to_op(op: DhtOp, cascade: &mut Cascade) -> AppValidationOutcome<Op> {
let op = match op {
DhtOp::StoreRecord(signature, action, entry) => Op::StoreRecord(StoreRecord {
record: Record::new(
SignedActionHashed::with_presigned(
ActionHashed::from_content_sync(action),
signature,
),
entry.map(|e| *e),
),
}),
DhtOp::StoreEntry(signature, action, entry) => Op::StoreEntry(StoreEntry {
action: SignedHashed::new(action.into(), signature),
entry: *entry,
}),
DhtOp::RegisterAgentActivity(signature, action) => {
Op::RegisterAgentActivity(RegisterAgentActivity {
action: SignedActionHashed::with_presigned(
ActionHashed::from_content_sync(action),
signature,
),
cached_entry: None,
})
}
DhtOp::RegisterUpdatedContent(signature, update, entry)
| DhtOp::RegisterUpdatedRecord(signature, update, entry) => {
let new_entry = match update.entry_type.visibility() {
EntryVisibility::Public => match entry {
Some(entry) => Some(*entry),
None => Some(
cascade
.retrieve_entry(update.entry_hash.clone(), Default::default())
.await?
.map(|e| e.into_content())
.ok_or_else(|| Outcome::awaiting(&update.entry_hash))?,
),
},
_ => None,
};
let original_entry = if let EntryVisibility::Public = update.entry_type.visibility() {
Some(
cascade
.retrieve_entry(update.original_entry_address.clone(), Default::default())
.await?
.map(|e| e.into_content())
.ok_or_else(|| Outcome::awaiting(&update.original_entry_address))?,
)
} else {
None
};
let original_action = cascade
.retrieve_action(update.original_action_address.clone(), Default::default())
.await?
.and_then(|sh| {
NewEntryAction::try_from(sh.hashed.content)
.ok()
.map(|h| h.into())
})
.ok_or_else(|| Outcome::awaiting(&update.original_action_address))?;
Op::RegisterUpdate(RegisterUpdate {
update: SignedHashed::new(update, signature),
new_entry,
original_action,
original_entry,
})
}
DhtOp::RegisterDeletedBy(signature, delete)
| DhtOp::RegisterDeletedEntryAction(signature, delete) => {
let original_action: EntryCreationAction = cascade
.retrieve_action(delete.deletes_address.clone(), Default::default())
.await?
.and_then(|sh| {
NewEntryAction::try_from(sh.hashed.content)
.ok()
.map(|h| h.into())
})
.ok_or_else(|| Outcome::awaiting(&delete.deletes_address))?;
let original_entry = if let EntryVisibility::Public =
original_action.entry_type().visibility()
{
Some(
cascade
.retrieve_entry(delete.deletes_entry_address.clone(), Default::default())
.await?
.map(|e| e.into_content())
.ok_or_else(|| Outcome::awaiting(&delete.deletes_entry_address))?,
)
} else {
None
};
Op::RegisterDelete(RegisterDelete {
delete: SignedHashed::new(delete, signature),
original_action,
original_entry,
})
}
DhtOp::RegisterAddLink(signature, create_link) => {
Op::RegisterCreateLink(RegisterCreateLink {
create_link: SignedHashed::new(create_link, signature),
})
}
DhtOp::RegisterRemoveLink(signature, delete_link) => {
let create_link = cascade
.retrieve_action(delete_link.link_add_address.clone(), Default::default())
.await?
.and_then(|sh| CreateLink::try_from(sh.hashed.content).ok())
.ok_or_else(|| Outcome::awaiting(&delete_link.link_add_address))?;
Op::RegisterDeleteLink(RegisterDeleteLink {
delete_link: SignedHashed::new(delete_link, signature),
create_link,
})
}
};
Ok(op)
}
sourcepub fn rejected<E, I: Into<String>>(s: I) -> OutcomeOrError<Self, E>
pub fn rejected<E, I: Into<String>>(s: I) -> OutcomeOrError<Self, E>
Helper function for creating rejected outcomes
Examples found in repository?
src/core/workflow/app_validation_workflow.rs (lines 526-529)
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
pub fn entry_creation_zomes_to_invoke(
action: &EntryCreationAction,
ribosome: &impl RibosomeT,
) -> AppValidationOutcome<ZomesToInvoke> {
match action {
EntryCreationAction::Create(Create {
entry_type: EntryType::App(app_entry_def),
..
})
| EntryCreationAction::Update(Update {
entry_type: EntryType::App(app_entry_def),
..
}) => {
let zome = ribosome
.get_integrity_zome(&app_entry_def.zome_index())
.ok_or_else(|| {
Outcome::rejected(&format!(
"Zome does not exist for {:?}",
app_entry_def.zome_index()
))
})?;
Ok(ZomesToInvoke::OneIntegrity(zome))
}
_ => Ok(ZomesToInvoke::AllIntegrity),
}
}
fn create_link_zomes_to_invoke(
create_link: &CreateLink,
ribosome: &impl RibosomeT,
) -> AppValidationOutcome<ZomesToInvoke> {
let zome = ribosome
.get_integrity_zome(&create_link.zome_index)
.ok_or_else(|| {
Outcome::rejected(&format!(
"Zome does not exist for {:?}",
create_link.link_type
))
})?;
Ok(ZomesToInvoke::One(zome.erase_type()))
}
/// Get the zomes to invoke for an [`Op::StoreRecord`].
fn store_record_zomes_to_invoke(
action: &Action,
ribosome: &impl RibosomeT,
) -> AppValidationOutcome<ZomesToInvoke> {
match action {
Action::CreateLink(create_link) => create_link_zomes_to_invoke(create_link, ribosome),
Action::Create(Create {
entry_type: EntryType::App(AppEntryDef { zome_index, .. }),
..
})
| Action::Update(Update {
entry_type: EntryType::App(AppEntryDef { zome_index, .. }),
..
}) => {
let zome = ribosome.get_integrity_zome(zome_index).ok_or_else(|| {
Outcome::rejected(&format!("Zome does not exist for {:?}", zome_index))
})?;
Ok(ZomesToInvoke::OneIntegrity(zome))
}
_ => Ok(ZomesToInvoke::AllIntegrity),
}
}
sourcepub fn exit_with_awaiting<T, I: Into<AnyDhtHash>, It: IntoIterator<Item = I>>(
h: It
) -> Result<T, OutcomeOrError<Outcome, AppValidationError>>
pub fn exit_with_awaiting<T, I: Into<AnyDhtHash>, It: IntoIterator<Item = I>>(
h: It
) -> Result<T, OutcomeOrError<Outcome, AppValidationError>>
Exit early with an awaiting outcome
sourcepub fn accepted<T>() -> Result<T, OutcomeOrError<Outcome, AppValidationError>>
pub fn accepted<T>() -> Result<T, OutcomeOrError<Outcome, AppValidationError>>
Early exits with an accepted outcome
sourcepub fn exit_with_rejected<T, I: Into<String>>(
reason: I
) -> Result<T, OutcomeOrError<Outcome, AppValidationError>>
pub fn exit_with_rejected<T, I: Into<String>>(
reason: I
) -> Result<T, OutcomeOrError<Outcome, AppValidationError>>
Exit early with a rejected outcome
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Outcome
impl Send for Outcome
impl Sync for Outcome
impl Unpin for Outcome
impl UnwindSafe for Outcome
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
TODO: once 1.33.0 is the minimum supported compiler version, remove
Any::type_id_compat and use StdAny::type_id instead.
https://github.com/rust-lang/rust/issues/27745
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.§impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref