Struct script::dom::readablestream::ReadableStream
source · #[repr(C)]pub struct ReadableStream {
reflector_: Reflector,
controller: ControllerType,
stored_error: Heap<JSVal>,
disturbed: Cell<bool>,
reader: ReaderType,
state: Cell<ReadableStreamState>,
}
Expand description
Fields§
§reflector_: Reflector
§controller: ControllerType
https://streams.spec.whatwg.org/#readablestream-controller
Note: the inner MutNullableDom
should really be an Option<Dom>
,
because it is never unset once set.
stored_error: Heap<JSVal>
§disturbed: Cell<bool>
§reader: ReaderType
§state: Cell<ReadableStreamState>
Implementations§
source§impl ReadableStream
impl ReadableStream
fn __assert_parent_type(&self)
source§impl ReadableStream
impl ReadableStream
sourcefn new_inherited(controller: ControllerType) -> ReadableStream
fn new_inherited(controller: ControllerType) -> ReadableStream
fn new_with_proto( global: &GlobalScope, proto: Option<SafeHandleObject<'_>>, controller: ControllerType, can_gc: CanGc, ) -> Root<Dom<ReadableStream>>
sourcepub fn set_default_controller(
&self,
controller: &ReadableStreamDefaultController,
)
pub fn set_default_controller( &self, controller: &ReadableStreamDefaultController, )
sourcepub fn assert_no_controller(&self)
pub fn assert_no_controller(&self)
sourcepub fn new_from_bytes(
global: &GlobalScope,
bytes: Vec<u8>,
can_gc: CanGc,
) -> Root<Dom<ReadableStream>>
pub fn new_from_bytes( global: &GlobalScope, bytes: Vec<u8>, can_gc: CanGc, ) -> Root<Dom<ReadableStream>>
Build a stream backed by a Rust source that has already been read into memory.
sourcepub fn new_with_external_underlying_source(
global: &GlobalScope,
source: UnderlyingSourceType,
can_gc: CanGc,
) -> Root<Dom<ReadableStream>>
pub fn new_with_external_underlying_source( global: &GlobalScope, source: UnderlyingSourceType, can_gc: CanGc, ) -> Root<Dom<ReadableStream>>
Build a stream backed by a Rust underlying source. Note: external sources are always paired with a default controller.
sourcepub fn perform_release_steps(&self)
pub fn perform_release_steps(&self)
Call into the release steps of the controller,
sourcepub fn perform_pull_steps(&self, read_request: &ReadRequest, can_gc: CanGc)
pub fn perform_pull_steps(&self, read_request: &ReadRequest, can_gc: CanGc)
Call into the pull steps of the controller, as part of https://streams.spec.whatwg.org/#readable-stream-default-reader-read
sourcepub fn add_read_request(&self, read_request: &ReadRequest)
pub fn add_read_request(&self, read_request: &ReadRequest)
sourcepub fn get_js_stream(&self) -> NonNull<JSObject>
pub fn get_js_stream(&self) -> NonNull<JSObject>
Get a pointer to the underlying JS object.
TODO: remove,
by using at call point the ReadableStream
directly instead of a JSObject.
sourcepub fn enqueue_native(&self, bytes: Vec<u8>)
pub fn enqueue_native(&self, bytes: Vec<u8>)
Endpoint to enqueue chunks directly from Rust. Note: in other use cases this call happens via the controller.
sourcepub fn error(&self, e: SafeHandleValue<'_>)
pub fn error(&self, e: SafeHandleValue<'_>)
sourcepub fn get_stored_error(&self, handle_mut: SafeMutableHandleValue<'_>)
pub fn get_stored_error(&self, handle_mut: SafeMutableHandleValue<'_>)
sourcepub fn error_native(&self, error: Error)
pub fn error_native(&self, error: Error)
https://streams.spec.whatwg.org/#readable-stream-error Note: in other use cases this call happens via the controller.
sourcepub fn controller_close_native(&self)
pub fn controller_close_native(&self)
Call into the controller’s Close
method.
https://streams.spec.whatwg.org/#readable-stream-default-controller-close
sourcepub fn in_memory(&self) -> bool
pub fn in_memory(&self) -> bool
Returns a boolean reflecting whether the stream has all data in memory. Useful for native source integration only.
sourcepub fn get_in_memory_bytes(&self) -> Option<Vec<u8>>
pub fn get_in_memory_bytes(&self) -> Option<Vec<u8>>
Return bytes for synchronous use, if the stream has all data in memory. Useful for native source integration only.
sourcepub fn acquire_default_reader(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<ReadableStreamDefaultReader>>, Error>
pub fn acquire_default_reader( &self, can_gc: CanGc, ) -> Result<Root<Dom<ReadableStreamDefaultReader>>, Error>
Acquires a reader and locks the stream,
must be done before read_a_chunk
.
Native call to
https://streams.spec.whatwg.org/#acquire-readable-stream-reader
pub fn get_default_controller( &self, ) -> Root<Dom<ReadableStreamDefaultController>>
sourcepub fn read_a_chunk(&self, can_gc: CanGc) -> Rc<Promise>
pub fn read_a_chunk(&self, can_gc: CanGc) -> Rc<Promise>
Read a chunk from the stream,
must be called after start_reading
,
and before stop_reading
.
Native call to
https://streams.spec.whatwg.org/#readable-stream-default-reader-read
sourcepub fn stop_reading(&self)
pub fn stop_reading(&self)
Releases the lock on the reader,
must be done after start_reading
.
Native call to
https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaultreaderrelease
pub fn is_disturbed(&self) -> bool
pub fn set_is_disturbed(&self, disturbed: bool)
pub fn is_closed(&self) -> bool
pub fn is_errored(&self) -> bool
pub fn is_readable(&self) -> bool
pub fn has_default_reader(&self) -> bool
sourcepub fn get_num_read_requests(&self) -> usize
pub fn get_num_read_requests(&self) -> usize
sourcepub fn fulfill_read_request(&self, chunk: SafeHandleValue<'_>, done: bool)
pub fn fulfill_read_request(&self, chunk: SafeHandleValue<'_>, done: bool)
pub fn set_reader(&self, new_reader: Option<&ReadableStreamDefaultReader>)
sourcefn default_tee(
&self,
clone_for_branch_2: bool,
can_gc: CanGc,
) -> Result<Vec<Root<Dom<ReadableStream>>>, Error>
fn default_tee( &self, clone_for_branch_2: bool, can_gc: CanGc, ) -> Result<Vec<Root<Dom<ReadableStream>>>, Error>
Trait Implementations§
source§impl DomObject for ReadableStream
impl DomObject for ReadableStream
source§impl DomObjectWrap for ReadableStream
impl DomObjectWrap for ReadableStream
source§const WRAP: unsafe fn(_: SafeJSContext, _: &GlobalScope, _: Option<HandleObject<'_>>, _: Box<Self>, _: CanGc) -> Root<Dom<Self>> = {dom::bindings::codegen::Bindings::ReadableStreamBinding::ReadableStream_Binding::Wrap as for<'a, 'b> unsafe fn(script_runtime::JSContext, &'a dom::globalscope::GlobalScope, std::option::Option<js::rust::Handle<'b, *mut js::jsapi::JSObject>>, std::boxed::Box<dom::readablestream::ReadableStream>, script_runtime::CanGc) -> dom::bindings::root::Root<dom::bindings::root::Dom<dom::readablestream::ReadableStream>>}
const WRAP: unsafe fn(_: SafeJSContext, _: &GlobalScope, _: Option<HandleObject<'_>>, _: Box<Self>, _: CanGc) -> Root<Dom<Self>> = {dom::bindings::codegen::Bindings::ReadableStreamBinding::ReadableStream_Binding::Wrap as for<'a, 'b> unsafe fn(script_runtime::JSContext, &'a dom::globalscope::GlobalScope, std::option::Option<js::rust::Handle<'b, *mut js::jsapi::JSObject>>, std::boxed::Box<dom::readablestream::ReadableStream>, script_runtime::CanGc) -> dom::bindings::root::Root<dom::bindings::root::Dom<dom::readablestream::ReadableStream>>}
source§impl HasParent for ReadableStream
impl HasParent for ReadableStream
source§impl IDLInterface for ReadableStream
impl IDLInterface for ReadableStream
source§impl MallocSizeOf for ReadableStream
impl MallocSizeOf for ReadableStream
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl MutDomObject for ReadableStream
impl MutDomObject for ReadableStream
source§impl PartialEq for ReadableStream
impl PartialEq for ReadableStream
source§impl ReadableStreamMethods<DomTypeHolder> for ReadableStream
impl ReadableStreamMethods<DomTypeHolder> for ReadableStream
source§fn Constructor(
cx: SafeJSContext,
global: &GlobalScope,
proto: Option<SafeHandleObject<'_>>,
can_gc: CanGc,
underlying_source: Option<*mut JSObject>,
strategy: &QueuingStrategy,
) -> Result<Root<Dom<Self>>, Error>
fn Constructor( cx: SafeJSContext, global: &GlobalScope, proto: Option<SafeHandleObject<'_>>, can_gc: CanGc, underlying_source: Option<*mut JSObject>, strategy: &QueuingStrategy, ) -> Result<Root<Dom<Self>>, Error>
source§fn Cancel(
&self,
_cx: SafeJSContext,
reason: SafeHandleValue<'_>,
can_gc: CanGc,
) -> Rc<Promise>
fn Cancel( &self, _cx: SafeJSContext, reason: SafeHandleValue<'_>, can_gc: CanGc, ) -> Rc<Promise>
source§fn GetReader(
&self,
options: &ReadableStreamGetReaderOptions,
can_gc: CanGc,
) -> Result<ReadableStreamReader, Error>
fn GetReader( &self, options: &ReadableStreamGetReaderOptions, can_gc: CanGc, ) -> Result<ReadableStreamReader, Error>
source§impl ToJSValConvertible for ReadableStream
impl ToJSValConvertible for ReadableStream
source§impl Traceable for ReadableStream
impl Traceable for ReadableStream
impl Eq for ReadableStream
Auto Trait Implementations§
impl !Freeze for ReadableStream
impl !RefUnwindSafe for ReadableStream
impl !Send for ReadableStream
impl !Sync for ReadableStream
impl Unpin for ReadableStream
impl !UnwindSafe for ReadableStream
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more