Created
September 30, 2021 15:00
-
-
Save ntakouris/205bafa19f43f79aea2dad8c8780d7e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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