pub struct RenderOptions {
pub field_overrides: HashMap<String, TemplateField>,
pub context: RenderContext,
}Fields§
§field_overrides: HashMap<String, TemplateField>§context: RenderContextImplementations§
Source§impl RenderOptions
impl RenderOptions
Sourcepub fn new(
field_overrides: HashMap<String, TemplateField>,
context: RenderContext,
) -> RenderOptions
pub fn new( field_overrides: HashMap<String, TemplateField>, context: RenderContext, ) -> RenderOptions
Constructs a new RenderOptions.
Source§impl RenderOptions
impl RenderOptions
Sourcepub fn with_field_overrides(
self,
value: HashMap<String, TemplateField>,
) -> RenderOptions
pub fn with_field_overrides( self, value: HashMap<String, TemplateField>, ) -> RenderOptions
Sets the field_overrides field of this struct.
Examples found in repository?
examples/workflow.rs (line 49)
7fn main() -> Result<(), Box<dyn Error>> {
8 let input = r#"#VRML_SIM R2025a utf8
9
10PROTO ContextAwareBox [
11 field SFInt32 count 2
12 field SFString label "default-label"
13]
14{
15 Group {
16 children [
17 WorldInfo { title "%<= fields.label.value >%|%<= fields.label.defaultValue >%|%<= context.os >%" }
18 %< for (let i = 0; i < fields.count.value; ++i) { >%
19 Transform {
20 translation %<= i >% 0 0
21 children [ Box { size 0.5 0.5 0.5 } ]
22 }
23 %< } >%
24 ]
25 }
26}
27"#;
28
29 let document: Proto = input.parse()?;
30 let diagnostics = document.validate()?;
31 println!("diagnostics: {}", diagnostics.len());
32
33 let mut field_overrides = HashMap::new();
34 field_overrides.insert("count".to_string(), TemplateField::SFInt32(3));
35 field_overrides.insert(
36 "label".to_string(),
37 TemplateField::SFString("override-label".to_string()),
38 );
39
40 let context = RenderContext::default()
41 .with_os("linux")
42 .with_world("/workspace/worlds/example.wbt")
43 .with_webots_version(RenderWebotsVersion::new(
44 "R2025a".to_string(),
45 "0".to_string(),
46 ));
47
48 let options = RenderOptions::default()
49 .with_field_overrides(field_overrides)
50 .with_context(context);
51
52 let rendered = document.render(&options)?;
53 println!("{rendered}");
54
55 Ok(())
56}Sourcepub fn with_context(self, value: RenderContext) -> RenderOptions
pub fn with_context(self, value: RenderContext) -> RenderOptions
Sets the context field of this struct.
Examples found in repository?
examples/workflow.rs (line 50)
7fn main() -> Result<(), Box<dyn Error>> {
8 let input = r#"#VRML_SIM R2025a utf8
9
10PROTO ContextAwareBox [
11 field SFInt32 count 2
12 field SFString label "default-label"
13]
14{
15 Group {
16 children [
17 WorldInfo { title "%<= fields.label.value >%|%<= fields.label.defaultValue >%|%<= context.os >%" }
18 %< for (let i = 0; i < fields.count.value; ++i) { >%
19 Transform {
20 translation %<= i >% 0 0
21 children [ Box { size 0.5 0.5 0.5 } ]
22 }
23 %< } >%
24 ]
25 }
26}
27"#;
28
29 let document: Proto = input.parse()?;
30 let diagnostics = document.validate()?;
31 println!("diagnostics: {}", diagnostics.len());
32
33 let mut field_overrides = HashMap::new();
34 field_overrides.insert("count".to_string(), TemplateField::SFInt32(3));
35 field_overrides.insert(
36 "label".to_string(),
37 TemplateField::SFString("override-label".to_string()),
38 );
39
40 let context = RenderContext::default()
41 .with_os("linux")
42 .with_world("/workspace/worlds/example.wbt")
43 .with_webots_version(RenderWebotsVersion::new(
44 "R2025a".to_string(),
45 "0".to_string(),
46 ));
47
48 let options = RenderOptions::default()
49 .with_field_overrides(field_overrides)
50 .with_context(context);
51
52 let rendered = document.render(&options)?;
53 println!("{rendered}");
54
55 Ok(())
56}Source§impl RenderOptions
impl RenderOptions
pub fn with_field_overrides_from<I, K, V>(self, overrides: I) -> RenderOptions
Trait Implementations§
Source§impl Clone for RenderOptions
impl Clone for RenderOptions
Source§fn clone(&self) -> RenderOptions
fn clone(&self) -> RenderOptions
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 Debug for RenderOptions
impl Debug for RenderOptions
Source§impl Default for RenderOptions
impl Default for RenderOptions
Source§fn default() -> RenderOptions
fn default() -> RenderOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RenderOptions
impl RefUnwindSafe for RenderOptions
impl Send for RenderOptions
impl Sync for RenderOptions
impl Unpin for RenderOptions
impl UnsafeUnpin for RenderOptions
impl UnwindSafe for RenderOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.