pub struct RecursiveTransform<T>(pub T);
Expand description
A helper struct that can wrap a non-recursive Transform
(i.e. one that does not apply to
subschemas) into a recursive one.
Its implementation of Transform
will first apply the inner transform to the “parent” schema,
and then its subschemas (and their subschemas, and so on).
§Example
use schemars::transform::{Transform, RecursiveTransform};
let mut transform = RecursiveTransform(|schema: &mut Schema| {
schema.insert("my_property".to_string(), "hello world".into());
});
let mut schema = json_schema!({
"type": "array",
"items": {}
});
transform.transform(&mut schema);
assert_eq!(
schema,
json_schema!({
"type": "array",
"items": {
"my_property": "hello world"
},
"my_property": "hello world"
})
);
Tuple Fields§
§0: T
Trait Implementations§
Source§impl<T: Clone> Clone for RecursiveTransform<T>
impl<T: Clone> Clone for RecursiveTransform<T>
Source§fn clone(&self) -> RecursiveTransform<T>
fn clone(&self) -> RecursiveTransform<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for RecursiveTransform<T>
impl<T: Debug> Debug for RecursiveTransform<T>
Auto Trait Implementations§
impl<T> Freeze for RecursiveTransform<T>where
T: Freeze,
impl<T> RefUnwindSafe for RecursiveTransform<T>where
T: RefUnwindSafe,
impl<T> Send for RecursiveTransform<T>where
T: Send,
impl<T> Sync for RecursiveTransform<T>where
T: Sync,
impl<T> Unpin for RecursiveTransform<T>where
T: Unpin,
impl<T> UnwindSafe for RecursiveTransform<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more