Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created September 30, 2021 15:00
Show Gist options
  • Save ntakouris/205bafa19f43f79aea2dad8c8780d7e1 to your computer and use it in GitHub Desktop.
Save ntakouris/205bafa19f43f79aea2dad8c8780d7e1 to your computer and use it in GitHub Desktop.
match db.retrieve(&id) {
Ok(c) => match c {
Some(d) => {
/* map DataResource -> EventEntity */
let ret = match d.value {
DataResourcePayload::String(x) => EventEntity{ id: d.id, value: EventValue::String(x)},
DataResourcePayload::Float(x) => EventEntity{ id: d.id, value: EventValue::Float(x)},
DataResourcePayload::Int(x) => EventEntity{ id: d.id, value: EventValue::Int(x)},
DataResourcePayload::Bool(x) => EventEntity{ id: d.id, value: EventValue::Bool(x)},
DataResourcePayload::CaptionedImage(x) => {
// fetch from blob storage
let img_b64 = "<get from blob storage>".into();
EventEntity {
id: d.id,
value: EventValue::CaptionedImage(
CaptionedImageValue {
caption: x.caption,
contents_b64: img_b64
}
)
}
}
};
Result::Ok(Json(ret))
},
None => Result::Err(None)
},
Err(x) => Result::Err(Some(x))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment