forked from extern/nushell
Rename Value::CustomValue
to Value::Custom
(#12309)
# Description The second `Value` is redundant and will consume five extra bytes on each transmission of a custom value to/from a plugin. # User-Facing Changes This is a breaking change to the plugin protocol. The [example in the protocol reference](https://www.nushell.sh/contributor-book/plugin_protocol_reference.html#value) becomes ```json { "Custom": { "val": { "type": "PluginCustomValue", "name": "database", "data": [36, 190, 127, 40, 12, 3, 46, 83], "notify_on_drop": true }, "span": { "start": 320, "end": 340 } } } ``` instead of ```json { "CustomValue": { ... } } ``` # After Submitting Update plugin protocol reference
This commit is contained in:
committed by
GitHub
parent
dfbbacfdf8
commit
b19da158d5
@ -226,7 +226,7 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value {
|
||||
},
|
||||
span,
|
||||
),
|
||||
Value::CustomValue { val, .. } => {
|
||||
Value::Custom { val, .. } => {
|
||||
// Only custom values that have a base value that can be converted to string are
|
||||
// accepted.
|
||||
val.to_base_value(input.span())
|
||||
|
@ -69,7 +69,7 @@ impl SQLiteDatabase {
|
||||
pub fn try_from_value(value: Value) -> Result<Self, ShellError> {
|
||||
let span = value.span();
|
||||
match value {
|
||||
Value::CustomValue { val, .. } => match val.as_any().downcast_ref::<Self>() {
|
||||
Value::Custom { val, .. } => match val.as_any().downcast_ref::<Self>() {
|
||||
Some(db) => Ok(Self {
|
||||
path: db.path.clone(),
|
||||
ctrlc: db.ctrlc.clone(),
|
||||
@ -97,7 +97,7 @@ impl SQLiteDatabase {
|
||||
|
||||
pub fn into_value(self, span: Span) -> Value {
|
||||
let db = Box::new(self);
|
||||
Value::custom_value(db, span)
|
||||
Value::custom(db, span)
|
||||
}
|
||||
|
||||
pub fn query(
|
||||
@ -357,7 +357,7 @@ impl CustomValue for SQLiteDatabase {
|
||||
ctrlc: self.ctrlc.clone(),
|
||||
};
|
||||
|
||||
Value::custom_value(Box::new(cloned), span)
|
||||
Value::custom(Box::new(cloned), span)
|
||||
}
|
||||
|
||||
fn type_name(&self) -> String {
|
||||
|
@ -293,7 +293,7 @@ pub fn debug_string_without_formatting(value: &Value) -> String {
|
||||
Value::CellPath { val, .. } => val.to_string(),
|
||||
// If we fail to collapse the custom value, just print <{type_name}> - failure is not
|
||||
// that critical here
|
||||
Value::CustomValue { val, .. } => val
|
||||
Value::Custom { val, .. } => val
|
||||
.to_base_value(value.span())
|
||||
.map(|val| debug_string_without_formatting(&val))
|
||||
.unwrap_or_else(|_| format!("<{}>", val.type_name())),
|
||||
|
@ -94,7 +94,7 @@ fn getcol(
|
||||
.into_pipeline_data(ctrlc)
|
||||
.set_metadata(metadata))
|
||||
}
|
||||
Value::CustomValue { val, .. } => {
|
||||
Value::Custom { val, .. } => {
|
||||
// TODO: should we get CustomValue to expose columns in a more efficient way?
|
||||
// Would be nice to be able to get columns without generating the whole value
|
||||
let input_as_base_value = val.to_base_value(span)?;
|
||||
|
@ -531,7 +531,7 @@ fn value_should_be_printed(
|
||||
| Value::Glob { .. }
|
||||
| Value::List { .. }
|
||||
| Value::CellPath { .. }
|
||||
| Value::CustomValue { .. } => term_contains_value(term, &lower_value, span),
|
||||
| Value::Custom { .. } => term_contains_value(term, &lower_value, span),
|
||||
Value::Record { val, .. } => {
|
||||
record_matches_term(val, columns_to_search, filter_config, term, span)
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ fn values(
|
||||
.into_pipeline_data_with_metadata(metadata, ctrlc)),
|
||||
Err(err) => Err(err),
|
||||
},
|
||||
Value::CustomValue { val, .. } => {
|
||||
Value::Custom { val, .. } => {
|
||||
let input_as_base_value = val.to_base_value(span)?;
|
||||
match get_values(&[input_as_base_value], head, span) {
|
||||
Ok(cols) => Ok(cols
|
||||
|
@ -115,7 +115,7 @@ fn to_string_tagged_value(
|
||||
| Value::Int { .. }
|
||||
| Value::Duration { .. }
|
||||
| Value::Binary { .. }
|
||||
| Value::CustomValue { .. }
|
||||
| Value::Custom { .. }
|
||||
| Value::Filesize { .. }
|
||||
| Value::CellPath { .. }
|
||||
| Value::Float { .. } => Ok(v.clone().to_abbreviated_string(config)),
|
||||
|
@ -139,7 +139,7 @@ pub fn value_to_json_value(v: &Value) -> Result<nu_json::Value, ShellError> {
|
||||
let collected = val.collect()?;
|
||||
value_to_json_value(&collected)?
|
||||
}
|
||||
Value::CustomValue { val, .. } => {
|
||||
Value::Custom { val, .. } => {
|
||||
let collected = val.to_base_value(span)?;
|
||||
value_to_json_value(&collected)?
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ pub fn value_to_string(
|
||||
msg_span: span,
|
||||
input_span: v.span(),
|
||||
}),
|
||||
Value::CustomValue { .. } => Err(ShellError::UnsupportedInput {
|
||||
Value::Custom { .. } => Err(ShellError::UnsupportedInput {
|
||||
msg: "custom values are currently not nuon-compatible".to_string(),
|
||||
input: "value originates from here".into(),
|
||||
msg_span: span,
|
||||
|
@ -147,7 +147,7 @@ fn local_into_string(value: Value, separator: &str, config: &Config) -> String {
|
||||
Value::CellPath { val, .. } => val.to_string(),
|
||||
// If we fail to collapse the custom value, just print <{type_name}> - failure is not
|
||||
// that critical here
|
||||
Value::CustomValue { val, .. } => val
|
||||
Value::Custom { val, .. } => val
|
||||
.to_base_value(span)
|
||||
.map(|val| local_into_string(val, separator, config))
|
||||
.unwrap_or_else(|_| format!("<{}>", val.type_name())),
|
||||
|
@ -93,7 +93,7 @@ fn helper(engine_state: &EngineState, v: &Value) -> Result<toml::Value, ShellErr
|
||||
})
|
||||
.collect::<Result<Vec<toml::Value>, ShellError>>()?,
|
||||
),
|
||||
Value::CustomValue { .. } => toml::Value::String("<Custom Value>".to_string()),
|
||||
Value::Custom { .. } => toml::Value::String("<Custom Value>".to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ pub fn value_to_yaml_value(v: &Value) -> Result<serde_yaml::Value, ShellError> {
|
||||
})
|
||||
.collect::<Result<Vec<serde_yaml::Value>, ShellError>>()?,
|
||||
),
|
||||
Value::CustomValue { .. } => serde_yaml::Value::Null,
|
||||
Value::Custom { .. } => serde_yaml::Value::Null,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ pub fn sort_value(
|
||||
|
||||
Ok(Value::list(vals, span))
|
||||
}
|
||||
Value::CustomValue { val, .. } => {
|
||||
Value::Custom { val, .. } => {
|
||||
let base_val = val.to_base_value(span)?;
|
||||
sort_value(&base_val, sort_columns, ascending, insensitive, natural)
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ impl Command for StorCreate {
|
||||
|
||||
process(table_name, span, &db, columns)?;
|
||||
// dbg!(db.clone());
|
||||
Ok(Value::custom_value(db, span).into_pipeline_data())
|
||||
Ok(Value::custom(db, span).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ impl Command for StorDelete {
|
||||
}
|
||||
}
|
||||
// dbg!(db.clone());
|
||||
Ok(Value::custom_value(db, span).into_pipeline_data())
|
||||
Ok(Value::custom(db, span).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ impl Command for StorExport {
|
||||
})?;
|
||||
}
|
||||
// dbg!(db.clone());
|
||||
Ok(Value::custom_value(db, span).into_pipeline_data())
|
||||
Ok(Value::custom(db, span).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ impl Command for StorImport {
|
||||
})?;
|
||||
}
|
||||
// dbg!(db.clone());
|
||||
Ok(Value::custom_value(db, span).into_pipeline_data())
|
||||
Ok(Value::custom(db, span).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ impl Command for StorInsert {
|
||||
};
|
||||
}
|
||||
// dbg!(db.clone());
|
||||
Ok(Value::custom_value(db, span).into_pipeline_data())
|
||||
Ok(Value::custom(db, span).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ impl Command for StorReset {
|
||||
})?;
|
||||
}
|
||||
// dbg!(db.clone());
|
||||
Ok(Value::custom_value(db, span).into_pipeline_data())
|
||||
Ok(Value::custom(db, span).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ impl Command for StorUpdate {
|
||||
};
|
||||
}
|
||||
// dbg!(db.clone());
|
||||
Ok(Value::custom_value(db, span).into_pipeline_data())
|
||||
Ok(Value::custom(db, span).into_pipeline_data())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ fn handle_table_command(
|
||||
// instead of stdout.
|
||||
Err(*error)
|
||||
}
|
||||
PipelineData::Value(Value::CustomValue { val, .. }, ..) => {
|
||||
PipelineData::Value(Value::Custom { val, .. }, ..) => {
|
||||
let base_pipeline = val.to_base_value(span)?.into_pipeline_data();
|
||||
Table.run(input.engine_state, input.stack, input.call, base_pipeline)
|
||||
}
|
||||
|
Reference in New Issue
Block a user