mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:55:59 +02:00
Add bytes collect, bytes remove, bytes build cmd (#6008)
* add bytes collect * index_of support searching from end * add bytes remove * make bytes replace work better for empty pattern * add bytes build * remove comment * tweak words Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
@ -404,6 +404,27 @@ impl FromValue for Vec<u8> {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromValue for Spanned<Vec<u8>> {
|
||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
||||
match v {
|
||||
Value::Binary { val, span } => Ok(Spanned {
|
||||
item: val.clone(),
|
||||
span: *span,
|
||||
}),
|
||||
Value::String { val, span } => Ok(Spanned {
|
||||
item: val.bytes().collect(),
|
||||
span: *span,
|
||||
}),
|
||||
v => Err(ShellError::CantConvert(
|
||||
"binary data".into(),
|
||||
v.get_type().to_string(),
|
||||
v.span()?,
|
||||
None,
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromValue for Spanned<PathBuf> {
|
||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
||||
match v {
|
||||
|
Reference in New Issue
Block a user