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

Function safe_byte_slice

modules/llrt_buffer/src/buffer.rs:493–507  ·  view source on GitHub ↗
(s: &str, end: usize)

Source from the content-addressed store, hash-verified

491}
492
493fn get_write_parameters<'js>(
494 ctx: &Ctx<'js>,
495 args: &Rest<Value<'js>>,
496 len: usize,
497) -> Result<(usize, usize, String)> {
498 let mut offset = 0;
499 let mut length = len;
500 let mut encoding = "utf8".to_owned();
501
502 if let Some(v1) = args.0.first() {
503 if let Some(s) = v1.as_string() {
504 return Ok((0, len, s.to_string()?));
505 }
506 offset = v1.as_int().unwrap_or(0) as usize;
507 if offset > len {
508 return Err(Exception::throw_range(
509 ctx,
510 "The value of \"offset\" is out of range",

Callers 1

writeFunction · 0.85

Calls 2

as_bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected