Files
organic/src/wasm/plain_link.rs

53 lines
1.6 KiB
Rust
Raw Normal View History

use serde::Deserialize;
use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::compare::ElispFact;
2023-12-30 12:40:12 -05:00
use crate::types::LinkType;
use crate::types::PlainLink;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
2023-12-30 12:40:12 -05:00
#[serde(tag = "format")]
#[serde(rename = "plain")]
2023-12-29 12:49:43 -05:00
pub struct WasmPlainLink {
2023-12-30 12:40:12 -05:00
#[serde(rename = "type")]
pub(crate) link_type: String,
pub(crate) path: String,
#[serde(rename = "raw-link")]
pub(crate) raw_link: String,
pub(crate) application: Option<String>,
#[serde(rename = "search-option")]
pub(crate) search_option: Option<String>,
}
to_wasm!(
2023-12-29 12:49:43 -05:00
WasmPlainLink,
2023-12-25 11:51:39 -05:00
PlainLink<'s>,
2023-12-25 12:32:35 -05:00
original,
wasm_context,
{ WasmAstNode::PlainLink(original) },
2023-12-30 12:40:12 -05:00
{ "link".into() },
{
Ok((
Vec::new(),
WasmPlainLink {
2023-12-30 12:40:12 -05:00
link_type: match &original.link_type {
LinkType::File => "file".to_owned(),
LinkType::Protocol(protocol) => protocol.clone().into_owned(),
LinkType::Id => "id".to_owned(),
LinkType::CustomId => "custom-id".to_owned(),
LinkType::CodeRef => "coderef".to_owned(),
LinkType::Fuzzy => "fuzzy".to_owned(),
},
path: original.path.to_owned(),
raw_link: original.raw_link.to_owned(),
application: original.application.map(str::to_owned),
search_option: original.search_option.map(str::to_owned),
},
))
}
);