Skip to main content

ReadableStreamCore

Struct ReadableStreamCore 

Source
pub struct ReadableStreamCore<T> {
    pub state: StreamState,
    pub queue: VecDeque<T>,
    pub high_water_mark: f64,
    pub locked: bool,
}
Expand description

ReadableStream の純粋コア実装

Fields§

§state: StreamState§queue: VecDeque<T>§high_water_mark: f64§locked: bool

Implementations§

Source§

impl<T> ReadableStreamCore<T>

Source

pub fn new(high_water_mark: f64) -> Self

Source

pub fn from_chunks(chunks: Vec<T>) -> Self

バイト列またはデータ配列から直ちに生成するヘルパー

Source

pub fn desired_size(&self) -> f64

バックプレッシャー計算(desiredSize) キューが満杯なら 0 以下、受け入れ可能なら正の値を返す

Source

pub fn enqueue(&mut self, chunk: T) -> Result<(), StreamError>

チャンクをキューに追加(コントローラの enqueue 処理)

Source

pub fn close(&mut self) -> Result<(), StreamError>

ストリームを正常クローズ(コントローラの close 処理)

Source

pub fn error(&mut self, reason: &str)

ストリームをエラー状態に遷移

Source

pub fn acquire_reader(&mut self) -> Result<(), StreamError>

リーダーによる排他ロック取得(getReader)

Source

pub fn release_reader(&mut self) -> Result<(), StreamError>

リーダーのロック解放(releaseLock)

Source

pub fn read_chunk(&mut self) -> Result<ReadResult<T>, StreamError>

リーダーによるチャンク読み出し(read())

Source

pub fn cancel(&mut self, _reason: &str)

ストリームのキャンセル(cancel(reason))

Source

pub fn queue_len(&self) -> usize

キュー内の未読チャンク数

Source

pub fn pipe_to( &mut self, dest: &mut WritableStreamCore<T>, options: PipeOptions, ) -> Result<(), StreamError>

ReadableStreamCore から WritableStreamCore へデータをパイピングする

  1. 両ストリームの排他的ロックを確保
  2. キューからチャンクを順次取り出し宛先へ書き込み
  3. 転送完了後、オプションに応じて宛先のクローズ・両ストリームのロック解除を実施
Source

pub fn pipe_through<O, F>( &mut self, transform: &mut TransformStreamCore<T, O>, transform_fn: F, ) -> Result<(), StreamError>
where F: FnMut(T) -> Vec<O>,

ReadableStreamCore を TransformStreamCore を介して別型の ReadableStreamCore へパイピング

Trait Implementations§

Source§

impl<T: Clone> Clone for ReadableStreamCore<T>

Source§

fn clone(&self) -> ReadableStreamCore<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for ReadableStreamCore<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ReadableStreamCore<T>

§

impl<T> RefUnwindSafe for ReadableStreamCore<T>
where T: RefUnwindSafe,

§

impl<T> Send for ReadableStreamCore<T>
where T: Send,

§

impl<T> Sync for ReadableStreamCore<T>
where T: Sync,

§

impl<T> Unpin for ReadableStreamCore<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ReadableStreamCore<T>

§

impl<T> UnwindSafe for ReadableStreamCore<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.