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

Method respond

modules/llrt_stream_web/src/readable/byte_controller.rs:1936–1972  ·  view source on GitHub ↗
(
        ctx: Ctx<'js>,
        byob_request: This<OwnedBorrowMut<'js, Self>>,
        bytes_written: usize,
    )

Source from the content-addressed store, hash-verified

1934
1935 fn respond(
1936 ctx: Ctx<'js>,
1937 byob_request: This<OwnedBorrowMut<'js, Self>>,
1938 bytes_written: usize,
1939 ) -> Result<()> {
1940 // If this.[[controller]] is undefined, throw a TypeError exception.
1941 let (controller, view) = match (&byob_request.controller, &byob_request.view) {
1942 (Some(controller), Some(view)) => (controller.clone(), view),
1943 _ => {
1944 return Err(Exception::throw_type(
1945 &ctx,
1946 "This BYOB request has been invalidated",
1947 ));
1948 },
1949 };
1950 let (buffer, _, _) = view.get_array_buffer()?;
1951 drop(byob_request);
1952
1953 // If ! IsDetachedBuffer(this.[[view]].[[ArrayBuffer]]) is true, throw a TypeError exception.
1954 if buffer.as_bytes().is_none() {
1955 return Err(Exception::throw_type(
1956 &ctx,
1957 "The BYOB request's buffer has been detached and so cannot be used as a response",
1958 ));
1959 }
1960
1961 let objects =
1962 ReadableStreamObjects::from_byte_controller(OwnedBorrowMut::from_class(controller))
1963 .refresh_reader();
1964
1965 // Perform ? ReadableByteStreamControllerRespond(this.[[controller]], bytesWritten).
1966 ReadableByteStreamController::readable_byte_stream_controller_respond(
1967 ctx,
1968 objects,
1969 bytes_written,
1970 )
1971 }
1972
1973 fn respond_with_new_view(
1974 ctx: Ctx<'js>,
1975 byob_request: This<OwnedBorrowMut<'js, Self>>,

Callers

nothing calls this directly

Calls 4

refresh_readerMethod · 0.80
cloneMethod · 0.45
get_array_bufferMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected