pub struct RenderContext {
pub world: Option<String>,
pub proto: Option<String>,
pub project_path: Option<String>,
pub webots_version: Option<RenderWebotsVersion>,
pub webots_home: Option<String>,
pub temporary_files_path: Option<String>,
pub os: Option<String>,
pub id: Option<String>,
pub coordinate_system: Option<String>,
}Fields§
§world: Option<String>§proto: Option<String>§project_path: Option<String>§webots_version: Option<RenderWebotsVersion>§webots_home: Option<String>§temporary_files_path: Option<String>§os: Option<String>§id: Option<String>§coordinate_system: Option<String>Implementations§
Source§impl RenderContext
impl RenderContext
Sourcepub fn with_world(self, value: impl Into<String>) -> RenderContext
pub fn with_world(self, value: impl Into<String>) -> RenderContext
Sets the world field of this struct.
Examples found in repository?
examples/workflow.rs (line 42)
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_proto(self, value: impl Into<String>) -> RenderContext
pub fn with_proto(self, value: impl Into<String>) -> RenderContext
Sets the proto field of this struct.
Sourcepub fn with_project_path(self, value: impl Into<String>) -> RenderContext
pub fn with_project_path(self, value: impl Into<String>) -> RenderContext
Sets the project_path field of this struct.
Sourcepub fn with_webots_version(
self,
value: impl Into<RenderWebotsVersion>,
) -> RenderContext
pub fn with_webots_version( self, value: impl Into<RenderWebotsVersion>, ) -> RenderContext
Sets the webots_version field of this struct.
Examples found in repository?
examples/workflow.rs (lines 43-46)
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_webots_home(self, value: impl Into<String>) -> RenderContext
pub fn with_webots_home(self, value: impl Into<String>) -> RenderContext
Sets the webots_home field of this struct.
Sourcepub fn with_temporary_files_path(
self,
value: impl Into<String>,
) -> RenderContext
pub fn with_temporary_files_path( self, value: impl Into<String>, ) -> RenderContext
Sets the temporary_files_path field of this struct.
Sourcepub fn with_os(self, value: impl Into<String>) -> RenderContext
pub fn with_os(self, value: impl Into<String>) -> RenderContext
Sets the os field of this struct.
Examples found in repository?
examples/workflow.rs (line 41)
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_id(self, value: impl Into<String>) -> RenderContext
pub fn with_id(self, value: impl Into<String>) -> RenderContext
Sets the id field of this struct.
Sourcepub fn with_coordinate_system(self, value: impl Into<String>) -> RenderContext
pub fn with_coordinate_system(self, value: impl Into<String>) -> RenderContext
Sets the coordinate_system field of this struct.
Trait Implementations§
Source§impl Clone for RenderContext
impl Clone for RenderContext
Source§fn clone(&self) -> RenderContext
fn clone(&self) -> RenderContext
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 RenderContext
impl Debug for RenderContext
Source§impl Default for RenderContext
impl Default for RenderContext
Source§fn default() -> RenderContext
fn default() -> RenderContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RenderContext
impl RefUnwindSafe for RenderContext
impl Send for RenderContext
impl Sync for RenderContext
impl Unpin for RenderContext
impl UnsafeUnpin for RenderContext
impl UnwindSafe for RenderContext
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.