From a44866365bf254ba5a9e7730f3a7a4dd6c920595 Mon Sep 17 00:00:00 2001 From: Jan Klass Date: Thu, 1 May 2025 21:38:06 +0200 Subject: [PATCH] Fix plugins streaming sample Please verify as I am not very familiar with Rust. Tested working with a `seq` stream, a string, and a list of values as I would expect from the implementation. Content that follows on the page has not been tested or adjusted. Resolves #1734 --- contributor-book/plugins.md | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/contributor-book/plugins.md b/contributor-book/plugins.md index 34aab7a6b5..8971ad6ecb 100644 --- a/contributor-book/plugins.md +++ b/contributor-book/plugins.md @@ -328,27 +328,20 @@ impl PluginCommand for Len { Value::int(length as i64, call.head).into_pipeline_data() ) }, - input => { - // Handle a string - let span = input.span().unwrap_or(call.head); - let value = input.into_value(span); - match &value { - Value::String { val, .. } => Ok( - Value::int(val.len() as i64, value.span()).into_pipeline_data() - ), - _ => Err( - LabeledError::new( - "Expected String or iterable input from pipeline", - ).with_label( - format!( - "requires string or iterable input; got {}", - value.get_type(), - ), - call.head, - ) + PipelineData::Value(Value::String { val, .. }, _) => { + Ok(Value::int(val.len() as i64, call.head).into_pipeline_data()) + }, + _ => Err( + LabeledError::new( + "Expected String or iterable input from pipeline", + ).with_label( + format!( + "requires string or iterable input; got {}", + input.get_type(), ), - } - } + call.head, + ) + ), } } }