#[repr(C)]pub(crate) 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(crate) fn set_default_controller(
&self,
controller: &ReadableStreamDefaultController,
)
pub(crate) fn set_default_controller( &self, controller: &ReadableStreamDefaultController, )
sourcepub(crate) fn assert_no_controller(&self)
pub(crate) fn assert_no_controller(&self)
sourcepub(crate) fn new_from_bytes(
global: &GlobalScope,
bytes: Vec<u8>,
can_gc: CanGc,
) -> Result<Root<Dom<ReadableStream>>, Error>
pub(crate) fn new_from_bytes( global: &GlobalScope, bytes: Vec<u8>, can_gc: CanGc, ) -> Result<Root<Dom<ReadableStream>>, Error>
Build a stream backed by a Rust source that has already been read into memory.
sourcepub(crate) fn new_with_external_underlying_source(
global: &GlobalScope,
source: UnderlyingSourceType,
can_gc: CanGc,
) -> Result<Root<Dom<ReadableStream>>, Error>
pub(crate) fn new_with_external_underlying_source( global: &GlobalScope, source: UnderlyingSourceType, can_gc: CanGc, ) -> Result<Root<Dom<ReadableStream>>, Error>
Build a stream backed by a Rust underlying source. Note: external sources are always paired with a default controller.
sourcepub(crate) fn perform_release_steps(&self) -> Result<(), Error>
pub(crate) fn perform_release_steps(&self) -> Result<(), Error>
Call into the release steps of the controller,
sourcepub(crate) fn perform_pull_steps(
&self,
read_request: &ReadRequest,
can_gc: CanGc,
)
pub(crate) 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(crate) fn add_read_request(&self, read_request: &ReadRequest)
pub(crate) fn add_read_request(&self, read_request: &ReadRequest)
sourcepub(crate) fn enqueue_native(&self, bytes: Vec<u8>)
pub(crate) 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(crate) fn error(&self, e: SafeHandleValue<'_>)
pub(crate) fn error(&self, e: SafeHandleValue<'_>)
sourcepub(crate) fn get_stored_error(&self, handle_mut: SafeMutableHandleValue<'_>)
pub(crate) fn get_stored_error(&self, handle_mut: SafeMutableHandleValue<'_>)
sourcepub(crate) fn error_native(&self, error: Error)
pub(crate) 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(crate) fn controller_close_native(&self)
pub(crate) fn controller_close_native(&self)
Call into the controller’s Close
method.
https://streams.spec.whatwg.org/#readable-stream-default-controller-close
sourcepub(crate) fn in_memory(&self) -> bool
pub(crate) fn in_memory(&self) -> bool
Returns a boolean reflecting whether the stream has all data in memory. Useful for native source integration only.
sourcepub(crate) fn get_in_memory_bytes(&self) -> Option<Vec<u8>>
pub(crate) 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(crate) fn acquire_default_reader(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<ReadableStreamDefaultReader>>, Error>
pub(crate) 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
sourcepub(crate) fn acquire_byob_reader(
&self,
can_gc: CanGc,
) -> Result<Root<Dom<ReadableStreamBYOBReader>>, Error>
pub(crate) fn acquire_byob_reader( &self, can_gc: CanGc, ) -> Result<Root<Dom<ReadableStreamBYOBReader>>, Error>
pub(crate) fn get_default_controller( &self, ) -> Root<Dom<ReadableStreamDefaultController>>
sourcepub(crate) fn read_a_chunk(&self, can_gc: CanGc) -> Rc<Promise>
pub(crate) 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(crate) fn stop_reading(&self)
pub(crate) 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(crate) fn is_disturbed(&self) -> bool
pub(crate) fn set_is_disturbed(&self, disturbed: bool)
pub(crate) fn is_closed(&self) -> bool
pub(crate) fn is_errored(&self) -> bool
pub(crate) fn is_readable(&self) -> bool
pub(crate) fn has_default_reader(&self) -> bool
pub(crate) fn has_byte_controller(&self) -> bool
sourcepub(crate) fn get_num_read_requests(&self) -> usize
pub(crate) fn get_num_read_requests(&self) -> usize
sourcepub(crate) fn fulfill_read_request(
&self,
chunk: SafeHandleValue<'_>,
done: bool,
)
pub(crate) fn fulfill_read_request( &self, chunk: SafeHandleValue<'_>, done: bool, )
pub(crate) fn set_reader(&self, new_reader: Option<ReaderType>)
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§fn global(&self) -> Root<Dom<GlobalScope>>where
Self: Sized,
fn global(&self) -> Root<Dom<GlobalScope>>where
Self: Sized,
GlobalScope
of the realm that the DomObject
was created in. If this
object is a Node
, this will be different from it’s owning Document
if adopted by. For
Node
s it’s almost always better to use NodeTraits::owning_global
.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