haste_operation_executor/
structs.rs1use haste_fhir_model::r4::generated::terminology::IssueType;
2use haste_fhir_operation_error::OperationOutcomeError;
3
4#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5pub enum PluginCodeType {
6 JavaScript,
7 TypeScript,
8}
9
10impl TryFrom<&str> for PluginCodeType {
11 type Error = OperationOutcomeError;
12
13 fn try_from(value: &str) -> Result<Self, Self::Error> {
14 match value {
15 "typescript" | "text/typescript" | "application/typescript" => {
16 Ok(PluginCodeType::TypeScript)
17 }
18 "javascript" | "text/javascript" | "application/javascript" => {
19 Ok(PluginCodeType::JavaScript)
20 }
21 _ => Err(OperationOutcomeError::error(
22 IssueType::invalid(),
23 format!("Unsupported custom-code media-type: {value}"),
24 )),
25 }
26 }
27}