MCPcopy Create free account
hub / github.com/awslabs/llrt / text

Method text

modules/llrt_fetch/src/request.rs:389–406  ·  view source on GitHub ↗
(&self, ctx: Ctx<'js>)

Source from the content-addressed store, hash-verified

387 }
388
389 pub fn text(&self, ctx: Ctx<'js>) -> Result<Promise<'js>> {
390 let body = match self.take_body_sync(&ctx) {
391 Ok(b) => b,
392 Err(e) => return reject_with_error(&ctx, e),
393 };
394 let ctx_clone = ctx.clone();
395 Promise::wrap_future(&ctx, async move {
396 let bytes_opt = resolve_body_taken(&ctx_clone, body).await?;
397 if let Some(bytes) = bytes_opt {
398 let bytes = strip_bom(bytes);
399 return Result::<String>::Ok(match String::from_utf8(bytes.into()) {
400 Ok(s) => s,
401 Err(e) => String::from_utf8_lossy(e.as_bytes()).into_owned(),
402 });
403 }
404 Ok(String::new())
405 })
406 }
407
408 pub fn json(&self, ctx: Ctx<'js>) -> Result<Promise<'js>> {
409 let body = match self.take_body_sync(&ctx) {

Callers

nothing calls this directly

Calls 6

reject_with_errorFunction · 0.85
resolve_body_takenFunction · 0.85
strip_bomFunction · 0.85
take_body_syncMethod · 0.80
cloneMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected