pub trait Target: Debug + SecretTarget {
// Required methods
fn target_insert(
&mut self,
path: &OwnedTargetPath,
value: Value,
) -> Result<(), String>;
fn target_get(
&self,
path: &OwnedTargetPath,
) -> Result<Option<&Value>, String>;
fn target_get_mut(
&mut self,
path: &OwnedTargetPath,
) -> Result<Option<&mut Value>, String>;
fn target_remove(
&mut self,
path: &OwnedTargetPath,
compact: bool,
) -> Result<Option<Value>, String>;
}Expand description
Any target object you want to remap using VRL has to implement this trait.
Required Methods§
Sourcefn target_insert(
&mut self,
path: &OwnedTargetPath,
value: Value,
) -> Result<(), String>
fn target_insert( &mut self, path: &OwnedTargetPath, value: Value, ) -> Result<(), String>
Insert a given Value in the provided Target.
The path parameter determines where in the given target the value
should be inserted.
A path consists of “path segments”. Each segment can be one of:
-
regular path segments:
.foo.bar.baz -
quoted path segments:
.foo."bar.baz" -
path indices:
.foo[2][-1]
§Errors
Error indicating insertion failure.
Sourcefn target_get(&self, path: &OwnedTargetPath) -> Result<Option<&Value>, String>
fn target_get(&self, path: &OwnedTargetPath) -> Result<Option<&Value>, String>
Get a value for a given path, or None if no value is found.
See Target::target_insert for more details.
§Errors
Error indicating retrieval failure.
Sourcefn target_get_mut(
&mut self,
path: &OwnedTargetPath,
) -> Result<Option<&mut Value>, String>
fn target_get_mut( &mut self, path: &OwnedTargetPath, ) -> Result<Option<&mut Value>, String>
Get a mutable reference to the value for a given path, or None if no
value is found.
See Target::target_insert for more details.
§Errors
Error indicating retrieval failure.
Sourcefn target_remove(
&mut self,
path: &OwnedTargetPath,
compact: bool,
) -> Result<Option<Value>, String>
fn target_remove( &mut self, path: &OwnedTargetPath, compact: bool, ) -> Result<Option<Value>, String>
Remove the given path from the object.
Returns the removed object, if any.
If compact is true, after deletion, if an empty object or array is
left behind, it should be removed as well, cascading up to the root.
§Errors
Error indicating removal failure.