MCPcopy Create free account
hub / github.com/base/base / encode_and_drain

Method encode_and_drain

crates/batcher/encoder/src/encoder.rs:149–162  ·  view source on GitHub ↗

Step the encoder until idle, force-close the current channel, and return all frames from every available submission. Convenience wrapper for tests and one-shot batch pipelines that have already added all blocks via [`BatchPipeline::add_block`] and want all output frames in a single call. # Errors Returns the first [`StepError`] encountered during encoding. On error the encoder state is left as-

(&mut self)

Source from the content-addressed store, hash-verified

147 /// encoder state is left as-is; previously ready submissions remain available
148 /// via [`BatchPipeline::next_submission`].
149 pub fn encode_and_drain(&mut self) -> Result<Vec<Arc<Frame>>, StepError> {
150 loop {
151 match self.step()? {
152 StepResult::Idle => break,
153 StepResult::BlockEncoded | StepResult::SpanFlushed | StepResult::ChannelClosed => {}
154 }
155 }
156 self.close_current_channel("force")?;
157 let mut frames = Vec::new();
158 while let Some(sub) = self.next_submission() {
159 frames.extend(sub.frames);
160 }
161 Ok(frames)
162 }
163
164 /// Build a span batch from the current accumulator.
165 fn build_span_batch(&self) -> Result<SpanBatch, StepError> {

Calls 4

close_current_channelMethod · 0.80
extendMethod · 0.80
stepMethod · 0.45
next_submissionMethod · 0.45