Render every populated MIME channel of a non-main display_data event into human-readable lines suitable for the stdout port. Binary channels are summarized (size only) instead of dumped as base64.
(r: &ResultEvent)
| 632 | /// human-readable lines suitable for the stdout port. Binary channels are |
| 633 | /// summarized (size only) instead of dumped as base64. |
| 634 | fn render_display_data(r: &ResultEvent) -> Vec<String> { |
| 635 | let mut out = Vec::new(); |
| 636 | if let Some(t) = &r.text { out.push(format!("[text] {}", t)); } |
| 637 | if let Some(h) = &r.html { out.push(format!("[html] {}", h)); } |
| 638 | if let Some(m) = &r.markdown { out.push(format!("[markdown] {}", m)); } |
| 639 | if let Some(s) = &r.svg { out.push(format!("[svg] {}", s)); } |
| 640 | if let Some(p) = &r.png { out.push(format!("[png] {} bytes (base64)", p.len())); } |
| 641 | if let Some(j) = &r.jpeg { out.push(format!("[jpeg] {} bytes (base64)", j.len())); } |
| 642 | if let Some(p) = &r.pdf { out.push(format!("[pdf] {} bytes (base64)", p.len())); } |
| 643 | if let Some(l) = &r.latex { out.push(format!("[latex] {}", l)); } |
| 644 | if let Some(j) = &r.json { out.push(format!("[json] {}", j)); } |
| 645 | if let Some(js) = &r.javascript { out.push(format!("[javascript] {}", js)); } |
| 646 | if let Some(d) = &r.data { out.push(format!("[data] {}", d)); } |
| 647 | if let Some(c) = &r.chart { out.push(format!("[chart] {}", c)); } |
| 648 | if let Some(e) = &r.extra { |
| 649 | // Loud signal: extra is whatever MIME types we don't know about. If E2B |
| 650 | // ever ships a new channel, we want it visible (not silently dropped). |
| 651 | tracing::warn!(target: "e2b", "unknown MIME channels in result.extra: {}", e); |
| 652 | out.push(format!("[extra] {}", e)); |
| 653 | } |
| 654 | out |
| 655 | } |
| 656 | |
| 657 | async fn exec_in_sandbox( |
| 658 | client: &reqwest::Client, |