rave_engine 0.8.0

A secure and efficient JSON Schema validation and Rhai script execution engine
Documentation
use hdk::prelude::*;
pub fn remove_link(
    query: LinkQuery,
    strategy: GetStrategy,
    target: AnyLinkableHash,
) -> ExternResult<ActionHash> {
    match get_links(query, strategy)?
        .into_iter()
        .find(|link| target == link.target)
    {
        Some(links) => {
            // this helps with zero-arc to prefetch the hash
            let _ = get(links.create_link_hash.clone(), GetOptions::network())?;
            delete_link(
                links.create_link_hash,
                GetOptions::default().with_strategy(strategy),
            )
        }
        None => Err(wasm_error!(WasmErrorInner::Guest(
            "Link does not exist".to_string()
        ))),
    }
}