Struct SchemeInit

Source
pub struct SchemeInit<'nr> { /* private fields */ }

Implementations§

Source§

impl<'nr> SchemeInit<'nr>

Source

pub fn new_with_path<P: AsRef<Path>>(init_root_path: P) -> StaticSchemeRes<Self>

Creates a new instance with the base FS path which will allow to use (include) procedure and open from file.

Examples found in repository?
examples/analyzer_error/test_err.rs (line 12)
6fn main()
7{
8    let curdir = std::env::current_dir().unwrap();
9
10    println!("{}", curdir.display());
11
12    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
13
14    let res = 
15        schm.run_from_file("examples/analyzer_error/schm_init.shm", None).unwrap();
16
17    let scheme = res.get("test_auto").unwrap();
18
19    let anres = scheme.analyze().unwrap();
20
21    println!("{}", anres);
22
23}
More examples
Hide additional examples
examples/another/another.rs (line 15)
9fn main()
10{
11    let curdir = std::env::current_dir().unwrap();
12
13    println!("{}", curdir.display());
14
15    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
16
17    let res = schm.run_from_file("examples/another/init_l.shm", None).unwrap();
18
19    let resser = res.get("logsmon").unwrap().clone();
20
21    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
22    println!("Structures: ");
23    match resser.generate_rust_code(&mut rc)
24    {
25        Ok(_) => 
26        {
27            println!("{}", rc);
28        },
29        Err(e) => 
30        {
31            println!("{}", e);
32        }
33    }
34
35    let anres = resser.analyze().unwrap();
36
37    println!("errors:\n{}", anres);
38
39    let mut curdir = std::env::current_dir().unwrap();
40
41    curdir.push("examples/another/data_l.shm");
42
43    let (_, _dyn_res) = environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
44
45    let resser = res.get("logsmon").unwrap().clone();
46
47    let anres = resser.analyze().unwrap();
48
49    println!("errors:\n{}", anres);
50
51
52
53}
examples/complex_example_1/init_networking1.rs (line 16)
10fn main()
11{
12    let curdir = std::env::current_dir().unwrap();
13
14    println!("{}", curdir.display());
15
16    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
17
18    let res = schm.run_from_file("examples/complex_example_1/init_networking.shm", None).unwrap();
19
20    let resser = res.get("networking").unwrap().clone();
21
22    let anres = resser.analyze().unwrap();
23
24    println!("errors:\n{}", anres);
25
26    let mut curdir = std::env::current_dir().unwrap();
27
28    curdir.push("examples/complex_example_1/init_networking_dyn1.shm");
29
30    let (_, dyn_res) = environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
31
32    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();
33
34    let serialized = serde_json::to_string(&ret).unwrap();
35
36    println!("Result:\n{}", serialized);
37
38    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
39
40    println!("Structures: ");
41    match resser.generate_rust_code(&mut rc)
42    {
43        Ok(_) => 
44        {
45            println!("{}", rc);
46        },
47        Err(e) => 
48        {
49            println!("{}", e);
50        }
51    }
52
53}
examples/struct_to_scheme/advanced3/struct2scheme.rs (line 191)
183pub fn main()
184{
185
186// static
187    let mut curdir = std::env::current_dir().unwrap();
188    curdir.push("examples/struct_to_scheme/advanced3");
189    println!("{}", curdir.display());
190
191    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
192    let res = schm.run_from_file("filters.shm", None).unwrap();
193    let resser = res.get("filters").unwrap().clone();
194
195// dynamic
196    let mut curdir = std::env::current_dir().unwrap();
197    curdir.push("examples/struct_to_scheme/advanced3/nginx.shm");
198    let (_, dynres) = 
199        environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
200
201// serialize dyn
202    let ret = serializator::Serialization::serialize(resser.clone(), dynres.clone()).unwrap();
203
204    let serialized = serde_json::to_string(&ret).unwrap();
205
206/*
207    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
208    println!("Structures: ");
209    match resser.generate_rust_structs(&mut rc)
210    {
211        Ok(_) => 
212        {
213            println!("{}", rc);
214        },
215        Err(e) => 
216        {
217            println!("{}", e);
218        }
219    }
220*/
221
222    let n: LdFilter = serde_json::from_str(&serialized).unwrap();
223
224    let resser = from_struct(n, resser);
225    
226    if resser.is_err() == true
227    {
228        panic!("{}", resser.err().unwrap());
229    }
230    else
231    {
232        println!("{}", resser.unwrap());
233    }
234}
examples/struct_to_scheme/advanced2/struct2scheme.rs (line 64)
56pub fn main()
57{
58
59// static
60    let mut curdir = std::env::current_dir().unwrap();
61    curdir.push("examples/struct_to_scheme/advanced2");
62    println!("{}", curdir.display());
63
64    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
65    let res = schm.run_from_file("logformats.shm", None).unwrap();
66    let resser = res.get("logformats").unwrap().clone();
67
68// dynamic
69    let mut curdir = std::env::current_dir().unwrap();
70    curdir.push("examples/struct_to_scheme/advanced2/nginx.shm");
71    let (_, dynres) = 
72        environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
73
74// serialize dyn
75    let ret = serializator::Serialization::serialize(resser.clone(), dynres.clone()).unwrap();
76
77    let serialized = serde_json::to_string(&ret).unwrap();
78
79  /*  let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
80    println!("Structures: ");
81    match resser.generate_rust_structs(&mut rc)
82    {
83        Ok(_) => 
84        {
85            println!("{}", rc);
86        },
87        Err(e) => 
88        {
89            println!("{}", e);
90        }
91    }
92*/
93    let n: LdLogStructFormat = serde_json::from_str(&serialized).unwrap();
94
95    let resser = from_struct(n, resser);
96    
97    if resser.is_err() == true
98    {
99        panic!("{}", resser.err().unwrap());
100    }
101    else
102    {
103        println!("{}", resser.unwrap());
104    }
105}
examples/scheme_enum/enumtest.rs (line 45)
39fn main()
40{
41    let curdir = std::env::current_dir().unwrap();
42    //curdir.push("examples/test3.shm");
43    println!("{}", curdir.display());
44   // let lex = lexer::Lexer::from_file(curdir).unwrap();
45    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
46
47    let res = schm.run_from_file("examples/scheme_enum/init_enum.shm", None).unwrap();
48
49    let resser = res.get("test1").unwrap().clone();
50
51    println!("{:?}", res);
52
53    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
54
55    println!("Structures: ");
56    match resser.generate_rust_code(&mut rc)
57    {
58        Ok(_) => 
59        {
60            println!("{}", rc);
61        },
62        Err(e) => 
63        {
64            panic!("{}", e);
65        }
66    }
67
68    let mut curdir = std::env::current_dir().unwrap();
69    curdir.push("examples/scheme_enum/enum.shm");
70
71    let (_, dyn_res) = environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
72
73    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();
74
75    //println!("dynproc:\n{:?}\n", dyn_res);
76
77    let serialized = serde_json::to_string(&ret).unwrap();
78
79    println!("Result:\n{}", serialized);
80
81    let _deserialized: CommonLevels = serde_json::from_str(&serialized).unwrap();
82
83    let lvls = 
84        CommonLevels
85        {
86            enum1: MyEnum::Item1,
87            enum2: OurEnum::Item2,
88            enum3: MyEnum::Item2,
89            enum4: vec![OurEnum::HItem1, OurEnum::Item2, OurEnum::CItem],
90        };
91
92    let serialized_nat = serde_json::to_string(&lvls).unwrap();
93
94    println!("nat:{}", serialized_nat);
95    println!("ser:{}", serialized);
96
97    if serialized != serialized_nat
98    {
99        panic!("not equal");
100    }
101
102
103}
Source

pub fn new() -> StaticSchemeRes<Self>

Creates a new instance. Procedure (include) will not work.

Examples found in repository?
examples/scheme_error_test/error_test.rs (line 15)
8pub fn main()
9{
10    let mut curdir = std::env::current_dir().unwrap();
11    curdir.push("examples/scheme_error_test/error_test.shm");
12    println!("{}", curdir.display());
13
14    let lex = lexer::Lexer::from_file(curdir).unwrap();
15    let schm = init::SchemeInit::new().unwrap();
16
17    let _res = schm.run(&lex, None).unwrap();
18
19}
More examples
Hide additional examples
examples/error_descr_test/errtest.rs (line 13)
6fn main()
7{
8    let mut curdir = std::env::current_dir().unwrap();
9    curdir.push("examples/error_descr_test/incorr_schm.shm");
10    println!("{}", curdir.display());
11
12    let lex = Lexer::from_file(curdir).unwrap();
13    let schm = SchemeInit::new().unwrap();
14
15    let res = schm.run(&lex, None).unwrap();
16
17    let ser = res.get("errtest1").unwrap().clone();
18
19
20    let mut curdir = std::env::current_dir().unwrap();
21    curdir.push("examples/error_descr_test/incor_data.shm");
22
23    let (_dynenv, _dyn_res) = 
24        DynEnvironment::from_file(curdir, ser.clone()).unwrap();
25
26}
examples/test2.rs (line 29)
22fn main1() -> SchemeResult<()>
23{
24    let mut curdir = std::env::current_dir().unwrap();
25    curdir.push("examples/test1.shm");
26    println!("{}", curdir.display());
27
28    let lex = lexer::Lexer::from_file(curdir)?;
29    let schm = init::SchemeInit::new()?;
30
31    let res = schm.run(&lex, None)?;
32
33    let resser = res.get("test1").unwrap().clone();
34
35    println!("Static: \n{:?}\n", res);
36
37    let mut curdir = std::env::current_dir().unwrap();
38    curdir.push("examples/test2.shm");
39
40    let dynres = environment::DynEnvironment::from_file(curdir, resser);
41
42    println!("Dynamic: \n{:?}\n", dynres);
43
44
45    return Ok(());
46
47}
examples/define_test.rs (line 14)
6fn main()
7{
8    let mut curdir = std::env::current_dir().unwrap();
9    curdir.push("examples/defines_init.shm");
10
11    println!("{}", curdir.display());
12    
13    let lex = lexer::Lexer::from_file(curdir).unwrap();
14    let schm = init::SchemeInit::new().unwrap();
15
16    let res = schm.run(&lex, None).unwrap();
17
18    println!("{:?}", res);
19
20    let resser = res.get("defines").unwrap().clone();
21
22    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
23
24    println!("Structures: ");
25    match resser.generate_rust_code(&mut rc)
26    {
27        Ok(_) => 
28        {
29            println!("{}", rc);
30        },
31        Err(e) => 
32        {
33            println!("{}", e);
34        }
35    }
36}
examples/struct_to_scheme/vector_arg/struct2scheme.rs (line 35)
28pub fn main()
29{
30    let mut curdir = std::env::current_dir().unwrap();
31    curdir.push("examples/struct_to_scheme/vector_arg/test_vec1.shm");
32    println!("{}", curdir.display());
33
34    let lex = lexer::Lexer::from_file(curdir).unwrap();
35    let schm = init::SchemeInit::new().unwrap();
36
37    let res = schm.run(&lex, None).unwrap();
38
39    let resser = res.get("test10").unwrap().clone();
40
41    println!("Static: \n{:?}\n", res);
42
43
44    let mut curdir = std::env::current_dir().unwrap();
45    curdir.push("examples/struct_to_scheme/vector_arg/test_vec1_data.shm");
46
47
48    let (_, dynres) = environment::DynEnvironment::from_file(&curdir, resser.clone()).unwrap();
49
50    let ret = serializator::Serialization::serialize(resser.clone(), dynres.clone()).unwrap();
51
52    let serialized = serde_json::to_string(&ret).unwrap();
53
54
55    let n: CommonLevels = serde_json::from_str(&serialized).unwrap();
56
57    let resreser = from_struct(n, resser);
58    
59    if resreser.is_err() == true
60    {
61        panic!("{}", resreser.err().unwrap());
62    }
63    else
64    {
65        println!("{}", resreser.unwrap());
66    }
67}
examples/test10.rs (line 23)
16pub fn main()
17{
18    let mut curdir = std::env::current_dir().unwrap();
19    curdir.push("examples/test4.shm");
20    println!("{}", curdir.display());
21
22    let lex = lexer::Lexer::from_file(curdir).unwrap();
23    let schm = init::SchemeInit::new().unwrap();
24
25    let res = schm.run(&lex, None).unwrap();
26
27    let resser = res.get("test10").unwrap().clone();
28
29    println!("Static: \n{:?}\n", res);
30
31    let mut curdir = std::env::current_dir().unwrap();
32    curdir.push("examples/test11.shm");
33
34
35    let (_, dynres) = environment::DynEnvironment::from_file(&curdir, resser.clone()).unwrap();
36
37    println!("Dynamic: \n{:?}\n", dynres);
38
39    let ret = serializator::Serialization::serialize(resser, dynres.clone()).unwrap();
40
41    let serialized = serde_json::to_string(&ret).unwrap();
42
43
44    let tr = CommonLevels{lvl_a: -2..8, lvl_b: 4..=5};
45
46    let res = serde_json::to_string(&tr).unwrap();
47
48    println!("control: {}", res);
49
50    let deser: CommonLevels = serde_json::from_str(&serialized).unwrap();
51
52    println!("{:?}", deser);
53
54    if deser != tr 
55    {
56        println!("did not match!");
57    }
58}
Source

pub fn get_root_path(&self) -> Option<&Path>

Source

pub fn run_from_file<P>( &self, path: P, confver: Option<i64>, ) -> StaticSchemeRes<StaticSchemes>
where P: AsRef<Path>,

Parses static scheme which describes how to read and serialize scheme configs. It calls lexer to parse file. This function requires that instance is created using new_with_path().

Examples found in repository?
examples/analyzer_error/test_err.rs (line 15)
6fn main()
7{
8    let curdir = std::env::current_dir().unwrap();
9
10    println!("{}", curdir.display());
11
12    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
13
14    let res = 
15        schm.run_from_file("examples/analyzer_error/schm_init.shm", None).unwrap();
16
17    let scheme = res.get("test_auto").unwrap();
18
19    let anres = scheme.analyze().unwrap();
20
21    println!("{}", anres);
22
23}
More examples
Hide additional examples
examples/another/another.rs (line 17)
9fn main()
10{
11    let curdir = std::env::current_dir().unwrap();
12
13    println!("{}", curdir.display());
14
15    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
16
17    let res = schm.run_from_file("examples/another/init_l.shm", None).unwrap();
18
19    let resser = res.get("logsmon").unwrap().clone();
20
21    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
22    println!("Structures: ");
23    match resser.generate_rust_code(&mut rc)
24    {
25        Ok(_) => 
26        {
27            println!("{}", rc);
28        },
29        Err(e) => 
30        {
31            println!("{}", e);
32        }
33    }
34
35    let anres = resser.analyze().unwrap();
36
37    println!("errors:\n{}", anres);
38
39    let mut curdir = std::env::current_dir().unwrap();
40
41    curdir.push("examples/another/data_l.shm");
42
43    let (_, _dyn_res) = environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
44
45    let resser = res.get("logsmon").unwrap().clone();
46
47    let anres = resser.analyze().unwrap();
48
49    println!("errors:\n{}", anres);
50
51
52
53}
examples/complex_example_1/init_networking1.rs (line 18)
10fn main()
11{
12    let curdir = std::env::current_dir().unwrap();
13
14    println!("{}", curdir.display());
15
16    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
17
18    let res = schm.run_from_file("examples/complex_example_1/init_networking.shm", None).unwrap();
19
20    let resser = res.get("networking").unwrap().clone();
21
22    let anres = resser.analyze().unwrap();
23
24    println!("errors:\n{}", anres);
25
26    let mut curdir = std::env::current_dir().unwrap();
27
28    curdir.push("examples/complex_example_1/init_networking_dyn1.shm");
29
30    let (_, dyn_res) = environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
31
32    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();
33
34    let serialized = serde_json::to_string(&ret).unwrap();
35
36    println!("Result:\n{}", serialized);
37
38    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
39
40    println!("Structures: ");
41    match resser.generate_rust_code(&mut rc)
42    {
43        Ok(_) => 
44        {
45            println!("{}", rc);
46        },
47        Err(e) => 
48        {
49            println!("{}", e);
50        }
51    }
52
53}
examples/struct_to_scheme/advanced3/struct2scheme.rs (line 192)
183pub fn main()
184{
185
186// static
187    let mut curdir = std::env::current_dir().unwrap();
188    curdir.push("examples/struct_to_scheme/advanced3");
189    println!("{}", curdir.display());
190
191    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
192    let res = schm.run_from_file("filters.shm", None).unwrap();
193    let resser = res.get("filters").unwrap().clone();
194
195// dynamic
196    let mut curdir = std::env::current_dir().unwrap();
197    curdir.push("examples/struct_to_scheme/advanced3/nginx.shm");
198    let (_, dynres) = 
199        environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
200
201// serialize dyn
202    let ret = serializator::Serialization::serialize(resser.clone(), dynres.clone()).unwrap();
203
204    let serialized = serde_json::to_string(&ret).unwrap();
205
206/*
207    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
208    println!("Structures: ");
209    match resser.generate_rust_structs(&mut rc)
210    {
211        Ok(_) => 
212        {
213            println!("{}", rc);
214        },
215        Err(e) => 
216        {
217            println!("{}", e);
218        }
219    }
220*/
221
222    let n: LdFilter = serde_json::from_str(&serialized).unwrap();
223
224    let resser = from_struct(n, resser);
225    
226    if resser.is_err() == true
227    {
228        panic!("{}", resser.err().unwrap());
229    }
230    else
231    {
232        println!("{}", resser.unwrap());
233    }
234}
examples/struct_to_scheme/advanced2/struct2scheme.rs (line 65)
56pub fn main()
57{
58
59// static
60    let mut curdir = std::env::current_dir().unwrap();
61    curdir.push("examples/struct_to_scheme/advanced2");
62    println!("{}", curdir.display());
63
64    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
65    let res = schm.run_from_file("logformats.shm", None).unwrap();
66    let resser = res.get("logformats").unwrap().clone();
67
68// dynamic
69    let mut curdir = std::env::current_dir().unwrap();
70    curdir.push("examples/struct_to_scheme/advanced2/nginx.shm");
71    let (_, dynres) = 
72        environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
73
74// serialize dyn
75    let ret = serializator::Serialization::serialize(resser.clone(), dynres.clone()).unwrap();
76
77    let serialized = serde_json::to_string(&ret).unwrap();
78
79  /*  let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
80    println!("Structures: ");
81    match resser.generate_rust_structs(&mut rc)
82    {
83        Ok(_) => 
84        {
85            println!("{}", rc);
86        },
87        Err(e) => 
88        {
89            println!("{}", e);
90        }
91    }
92*/
93    let n: LdLogStructFormat = serde_json::from_str(&serialized).unwrap();
94
95    let resser = from_struct(n, resser);
96    
97    if resser.is_err() == true
98    {
99        panic!("{}", resser.err().unwrap());
100    }
101    else
102    {
103        println!("{}", resser.unwrap());
104    }
105}
examples/scheme_enum/enumtest.rs (line 47)
39fn main()
40{
41    let curdir = std::env::current_dir().unwrap();
42    //curdir.push("examples/test3.shm");
43    println!("{}", curdir.display());
44   // let lex = lexer::Lexer::from_file(curdir).unwrap();
45    let schm = init::SchemeInit::new_with_path(curdir).unwrap();
46
47    let res = schm.run_from_file("examples/scheme_enum/init_enum.shm", None).unwrap();
48
49    let resser = res.get("test1").unwrap().clone();
50
51    println!("{:?}", res);
52
53    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
54
55    println!("Structures: ");
56    match resser.generate_rust_code(&mut rc)
57    {
58        Ok(_) => 
59        {
60            println!("{}", rc);
61        },
62        Err(e) => 
63        {
64            panic!("{}", e);
65        }
66    }
67
68    let mut curdir = std::env::current_dir().unwrap();
69    curdir.push("examples/scheme_enum/enum.shm");
70
71    let (_, dyn_res) = environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
72
73    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();
74
75    //println!("dynproc:\n{:?}\n", dyn_res);
76
77    let serialized = serde_json::to_string(&ret).unwrap();
78
79    println!("Result:\n{}", serialized);
80
81    let _deserialized: CommonLevels = serde_json::from_str(&serialized).unwrap();
82
83    let lvls = 
84        CommonLevels
85        {
86            enum1: MyEnum::Item1,
87            enum2: OurEnum::Item2,
88            enum3: MyEnum::Item2,
89            enum4: vec![OurEnum::HItem1, OurEnum::Item2, OurEnum::CItem],
90        };
91
92    let serialized_nat = serde_json::to_string(&lvls).unwrap();
93
94    println!("nat:{}", serialized_nat);
95    println!("ser:{}", serialized);
96
97    if serialized != serialized_nat
98    {
99        panic!("not equal");
100    }
101
102
103}
Source

pub fn run( &self, nodes: &DynNodeData, confver: Option<i64>, ) -> StaticSchemeRes<StaticSchemes>

Parses the scheme configuration init file from memeory. In case if lexer is called from other place.

Examples found in repository?
examples/scheme_error_test/error_test.rs (line 17)
8pub fn main()
9{
10    let mut curdir = std::env::current_dir().unwrap();
11    curdir.push("examples/scheme_error_test/error_test.shm");
12    println!("{}", curdir.display());
13
14    let lex = lexer::Lexer::from_file(curdir).unwrap();
15    let schm = init::SchemeInit::new().unwrap();
16
17    let _res = schm.run(&lex, None).unwrap();
18
19}
More examples
Hide additional examples
examples/error_descr_test/errtest.rs (line 15)
6fn main()
7{
8    let mut curdir = std::env::current_dir().unwrap();
9    curdir.push("examples/error_descr_test/incorr_schm.shm");
10    println!("{}", curdir.display());
11
12    let lex = Lexer::from_file(curdir).unwrap();
13    let schm = SchemeInit::new().unwrap();
14
15    let res = schm.run(&lex, None).unwrap();
16
17    let ser = res.get("errtest1").unwrap().clone();
18
19
20    let mut curdir = std::env::current_dir().unwrap();
21    curdir.push("examples/error_descr_test/incor_data.shm");
22
23    let (_dynenv, _dyn_res) = 
24        DynEnvironment::from_file(curdir, ser.clone()).unwrap();
25
26}
examples/test2.rs (line 31)
22fn main1() -> SchemeResult<()>
23{
24    let mut curdir = std::env::current_dir().unwrap();
25    curdir.push("examples/test1.shm");
26    println!("{}", curdir.display());
27
28    let lex = lexer::Lexer::from_file(curdir)?;
29    let schm = init::SchemeInit::new()?;
30
31    let res = schm.run(&lex, None)?;
32
33    let resser = res.get("test1").unwrap().clone();
34
35    println!("Static: \n{:?}\n", res);
36
37    let mut curdir = std::env::current_dir().unwrap();
38    curdir.push("examples/test2.shm");
39
40    let dynres = environment::DynEnvironment::from_file(curdir, resser);
41
42    println!("Dynamic: \n{:?}\n", dynres);
43
44
45    return Ok(());
46
47}
examples/define_test.rs (line 16)
6fn main()
7{
8    let mut curdir = std::env::current_dir().unwrap();
9    curdir.push("examples/defines_init.shm");
10
11    println!("{}", curdir.display());
12    
13    let lex = lexer::Lexer::from_file(curdir).unwrap();
14    let schm = init::SchemeInit::new().unwrap();
15
16    let res = schm.run(&lex, None).unwrap();
17
18    println!("{:?}", res);
19
20    let resser = res.get("defines").unwrap().clone();
21
22    let mut rc = RustCode::new(vec![RustCodeDerives::Debug], vec![], None);
23
24    println!("Structures: ");
25    match resser.generate_rust_code(&mut rc)
26    {
27        Ok(_) => 
28        {
29            println!("{}", rc);
30        },
31        Err(e) => 
32        {
33            println!("{}", e);
34        }
35    }
36}
examples/struct_to_scheme/vector_arg/struct2scheme.rs (line 37)
28pub fn main()
29{
30    let mut curdir = std::env::current_dir().unwrap();
31    curdir.push("examples/struct_to_scheme/vector_arg/test_vec1.shm");
32    println!("{}", curdir.display());
33
34    let lex = lexer::Lexer::from_file(curdir).unwrap();
35    let schm = init::SchemeInit::new().unwrap();
36
37    let res = schm.run(&lex, None).unwrap();
38
39    let resser = res.get("test10").unwrap().clone();
40
41    println!("Static: \n{:?}\n", res);
42
43
44    let mut curdir = std::env::current_dir().unwrap();
45    curdir.push("examples/struct_to_scheme/vector_arg/test_vec1_data.shm");
46
47
48    let (_, dynres) = environment::DynEnvironment::from_file(&curdir, resser.clone()).unwrap();
49
50    let ret = serializator::Serialization::serialize(resser.clone(), dynres.clone()).unwrap();
51
52    let serialized = serde_json::to_string(&ret).unwrap();
53
54
55    let n: CommonLevels = serde_json::from_str(&serialized).unwrap();
56
57    let resreser = from_struct(n, resser);
58    
59    if resreser.is_err() == true
60    {
61        panic!("{}", resreser.err().unwrap());
62    }
63    else
64    {
65        println!("{}", resreser.unwrap());
66    }
67}
examples/test10.rs (line 25)
16pub fn main()
17{
18    let mut curdir = std::env::current_dir().unwrap();
19    curdir.push("examples/test4.shm");
20    println!("{}", curdir.display());
21
22    let lex = lexer::Lexer::from_file(curdir).unwrap();
23    let schm = init::SchemeInit::new().unwrap();
24
25    let res = schm.run(&lex, None).unwrap();
26
27    let resser = res.get("test10").unwrap().clone();
28
29    println!("Static: \n{:?}\n", res);
30
31    let mut curdir = std::env::current_dir().unwrap();
32    curdir.push("examples/test11.shm");
33
34
35    let (_, dynres) = environment::DynEnvironment::from_file(&curdir, resser.clone()).unwrap();
36
37    println!("Dynamic: \n{:?}\n", dynres);
38
39    let ret = serializator::Serialization::serialize(resser, dynres.clone()).unwrap();
40
41    let serialized = serde_json::to_string(&ret).unwrap();
42
43
44    let tr = CommonLevels{lvl_a: -2..8, lvl_b: 4..=5};
45
46    let res = serde_json::to_string(&tr).unwrap();
47
48    println!("control: {}", res);
49
50    let deser: CommonLevels = serde_json::from_str(&serialized).unwrap();
51
52    println!("{:?}", deser);
53
54    if deser != tr 
55    {
56        println!("did not match!");
57    }
58}

Auto Trait Implementations§

§

impl<'nr> Freeze for SchemeInit<'nr>

§

impl<'nr> RefUnwindSafe for SchemeInit<'nr>

§

impl<'nr> Send for SchemeInit<'nr>

§

impl<'nr> Sync for SchemeInit<'nr>

§

impl<'nr> Unpin for SchemeInit<'nr>

§

impl<'nr> UnwindSafe for SchemeInit<'nr>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.