pub struct Serializator { /* private fields */ }
Expand description

This struct contains information about the Serializator instance which is defined in scheme and starting with (serialization “name” …).

Implementations§

source§

impl Serializator

source

pub const SERIALIZATOR_FROM_MEMORY_PATH: &'static str = "from memory"

Returned instead of path when path is None

source

pub fn new(name: String) -> Self

Creates new instance of serializator and sets the name provided in the scheme.

source

pub fn set_file_path(&mut self, file_path: Option<PathBuf>)

Sets to the created instance a path to the file which was used to generate current instance.

source

pub fn get_file_path(&self) -> Option<&PathBuf>

Returns a reference to PathBuf inside Option. It contains the path to the file which was used to build the instance.

source

pub fn get_file_path_string_safe(&self) -> String

Returns a path or constant SERIALIZATOR_FROM_MEMORY_PATH if it was generated from memory.

source

pub fn get_defines_by_proc_dt( &self, proc_name: &String, arg_dt: ArgDataType ) -> Vec<Rc<Define>>

Returns a list of references to the Define instance by the defined parameters.

The Define instance is defined to be used in proc_name procedure and contain data with the exact arg_dt data type.

Arguments
  • proc_name - a name of the procedure.

  • arg_dt - a ArgDataType data type.

Return

A Vec of Rc items is returned.

source

pub fn resolve_path_to_struct( &self, source: Rc<Procedure>, path_to_label: &[String], full_path_to_lbl: &[String] ) -> StaticSchemeRes<(Rc<Structure>, Rc<Procedure>)>

Searches for a Structure (and Procedure) from the point specified by argument source which is Procedure.

This function is recursive!

Arguments
  • source - a point from where the item from argument path_to_label is resolved.

  • path_to_label - a path (by labels) to the target.

Returns

Returns a SchemeResult where:

source

pub fn resolve_path_to_proc( &self, source: Rc<Procedure>, path_to_label: &[String], full_path_to_lbl: &[String] ) -> StaticSchemeRes<(Option<Rc<Structure>>, Rc<Procedure>)>

Searches for the Procedure instance. A starting point is source. A path is full_path_to_lbl. path_to_label is a recursivly modified list from where on each recursion an item is removed.

Returns

An optional reference to Structure is returned in case if procedure is defined with structure.

source

pub fn resolve_path_to_enum( &self, source: Rc<Procedure>, path_to_label: &[String], full_path_to_lbl: &[String] ) -> StaticSchemeRes<(Rc<Enumerator>, Rc<Procedure>)>

Searches for a Enumerator (and Procedure) from the point specified by argument source which is Procedure.

This function is recursive!

Arguments
  • source - a point from where the item from argument path_to_label is resolved.

  • path_to_label - a path (by labels) to the target.

Returns

Returns a SchemeResult where:

source

pub fn resolve_path_to_arg( &self, source: Rc<Procedure>, path_to_label: &[String], full_path_to_lbl: &[String] ) -> StaticSchemeRes<Rc<Argument>>

Searches for a Argument from the point specified by argument source which is Procedure.

This function is recursive!

Arguments
  • source - a point from where the item from argument path_to_label is resolved.

  • path_to_label - a path (by labels) to the target.

Returns

Returns a SchemeResult where:

source

pub fn generate_rust_structs( &self, rust_code: &mut RustCode ) -> StaticSchemeRes<()>

Generates a Rust code (structures and enums) from the root of the document.

Arguments
  • rust_code - a mutable reference to RustCode instance which is used to collect result.
Returns

A SchemeResult is returned.

Examples found in repository?
examples/define_test.rs (line 24)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fn main()
{
    let mut curdir = std::env::current_dir().unwrap();
    curdir.push("examples/defines_init.shm");

    println!("{}", curdir.display());
    
    let lex = lexer::Lexer::from_file(curdir).unwrap();
    let schm = init::SchemeInit::new().unwrap();

    let res = schm.run(&lex, None).unwrap();

    println!("{:?}", res);

    let resser = res.get("defines").unwrap().clone();

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);

    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            println!("{}", e);
        }
    }
}
More examples
Hide additional examples
examples/complex_example_1/init_networking1.rs (line 44)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
fn main()
{
    let curdir = std::env::current_dir().unwrap();

    println!("{}", curdir.display());

    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    let res = schm.run_from_file("examples/complex_example_1/init_networking.shm", None).unwrap();

    let resser = res.get("networking").unwrap().clone();

    let anres = resser.analyze().unwrap();

    println!("errors:\n{}", anres);

    let mut curdir = std::env::current_dir().unwrap();

    curdir.push("examples/complex_example_1/init_networking_dyn1.shm");

    let lex = lexer::Lexer::from_file(curdir).unwrap();

    let dynenv = environment::DynEnvironment::new_root(resser.clone()).unwrap();

    let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap();

    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();

    let serialized = serde_json::to_string(&ret).unwrap();

    println!("Result:\n{}", serialized);

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);

    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            println!("{}", e);
        }
    }

}
examples/scheme_proc_enum/init_use1.rs (line 71)
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
fn main()
{
    let curdir = std::env::current_dir().unwrap();

    println!("{}", curdir.display());

    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    let res = schm.run_from_file("examples/scheme_proc_enum/init_use1.shm", None).unwrap();

    let resser = res.get("use1").unwrap().clone();

    let mut curdir = std::env::current_dir().unwrap();

    curdir.push("examples/scheme_proc_enum/init_use_dyn1.shm");

   // let lex = lexer::Lexer::from_file(curdir).unwrap();
    let (_dynenv, dyn_res) = 
        environment::DynEnvironment::from_file(curdir, resser.clone()).unwrap();
   // let dynenv = environment::DynEnvironment::new_root(resser.clone());

    //let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap();

    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();

    let serialized = serde_json::to_string(&ret).unwrap();

    println!("Result:\n{}", serialized);
    let local_inst = 
        TestUseEnum::ColorRgbaProfile
        {
            profile_name: "profile1".to_string(),
            col_r: 6,
            col_g: 5,
            col_b: 64,
            col_a: 100
        };

    let local_inst_ser = serde_json::to_string(&local_inst).unwrap();

    assert_eq!(local_inst_ser.as_str(), serialized.as_str());


    

    let deserialized: TestUseEnum = serde_json::from_str(&serialized).unwrap();

    println!("Deserialized result: \n{:?}", deserialized);

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);

    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            panic!("{}", e);
        }
    }

}
examples/scheme_enum/enumtest.rs (line 91)
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
fn main()
{
    let curdir = std::env::current_dir().unwrap();
    //curdir.push("examples/test3.shm");
    println!("{}", curdir.display());
   // let lex = lexer::Lexer::from_file(curdir).unwrap();
    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    let res = schm.run_from_file("examples/scheme_enum/init_enum.shm", None).unwrap();

    let resser = res.get("test1").unwrap().clone();

    println!("{:?}", res);

    let mut curdir = std::env::current_dir().unwrap();
    curdir.push("examples/scheme_enum/enum.shm");

    let lex = lexer::Lexer::from_file(curdir).unwrap();

    let dynenv = environment::DynEnvironment::new_root(resser.clone()).unwrap();

    let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap();

    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();

    //println!("dynproc:\n{:?}\n", dyn_res);

    let serialized = serde_json::to_string(&ret).unwrap();

    println!("Result:\n{}", serialized);

    let _deserialized: CommonLevels = serde_json::from_str(&serialized).unwrap();

    let lvls = 
        CommonLevels
        {
            enum1: MyEnum::Item1,
            enum2: OurEnum::Item2,
            enum3: MyEnum::Item2,
            enum4: vec![OurEnum::H_item1, OurEnum::Item2, OurEnum::C_item],
        };

    let serialized_nat = serde_json::to_string(&lvls).unwrap();

    println!("nat:{}", serialized_nat);
    println!("ser:{}", serialized);

    if serialized != serialized_nat
    {
        panic!("not equal");
    }

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);

    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            panic!("{}", e);
        }
    }
}
examples/common_search/common_search.rs (line 26)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
fn main()
{
    let curdir = std::env::current_dir().unwrap();

    println!("{}", curdir.display());

    // init parser instance
    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    // read a static scheme which describes our data structures i.e files filters.shm and logsmon.shm
    let mut res = schm.run_from_file("examples/common_search/filters.shm", None).unwrap();
    res.merge(schm.run_from_file("examples/common_search/logsmon.shm", None).unwrap());

    // get our serializator instance which was parsed from static file
    let resser = res.get("filters").unwrap().clone();

    // creating new `RustCode` instance where the data structs from serializator `filters` will be placed
    let mut rc1 = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
    resser.generate_rust_structs(&mut rc1).unwrap();

    // creating new `RustCode` instance where the data structs from serializator `logsmon` will be placed
    let resser = res.get("logsmon").unwrap().clone();
    let mut rc2 = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
    resser.generate_rust_structs(&mut rc2).unwrap();

    println!("after removing commons");

    // search for common structs/enums between RustCode instances for filter.shm and logsmon.shm
    let t = std::time::Instant::now();
    let com_res = RustCode::search_common("super::structs::struct_common", vec!(&mut rc1, &mut rc2), &["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
    let s = t.elapsed();
    println!("time taken: {:?}", s);
    println!("{}", rc1);

    println!("{}", rc2);
    
    // if something was found, then it will be stored in inner type of Option
    if com_res.is_some() == true
    {
        println!("Common structs: \n\n{}", com_res.unwrap());
    }
}
examples/test3.rs (line 89)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
fn main()
{
    let curdir = std::env::current_dir().unwrap();
    //curdir.push("examples/test3.shm");
    println!("{}", curdir.display());
   // let lex = lexer::Lexer::from_file(curdir).unwrap();
    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    let res = schm.run_from_file("examples/test3.shm", None).unwrap();

    let resser = res.get("test1").unwrap().clone();

    println!("{:?}", res);

    let mut curdir = std::env::current_dir().unwrap();
    curdir.push("examples/test2.shm");

    let lex = lexer::Lexer::from_file(curdir).unwrap();

    let dynenv = environment::DynEnvironment::new_root(resser.clone()).unwrap();

    let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap();

    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();

    //println!("dynproc:\n{:?}\n", dyn_res);

    let serialized = serde_json::to_string(&ret).unwrap();

    println!("Result:\n{}", serialized);

    let _deserialized: CommonLevels = serde_json::from_str(&serialized).unwrap();

    let lvls = 
        Levels
        {
            name: "testing1234".to_string(),
            ch_a: Some(100),
            ch_b: 2,
            g_type: vec![GeomType::Line(4, 6, 5), GeomType::Ray{l: 56, w: 44}, GeomType::Test],
        };

    let cl = CommonLevels{lvl: lvls};

    let serialized_nat = serde_json::to_string(&cl).unwrap();

    println!("nat:{}", serialized_nat);
    println!("ser:{}", serialized);

    if serialized != serialized_nat
    {
        println!("not equal");
    }

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);

    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            println!("{}", e);
        }
    }
}
source

pub fn generate_field_data_type( &self, rust_code: &mut RustCode, field: &FieldDecl, cur_proc_int: Rc<Procedure>, cur_enumer: Option<Rc<Enumerator>> ) -> StaticSchemeRes<RustCodeItemDataType>

Generates a field’s (Rust) datatype.

Arguments
  • rust_code - a mutable reference to RustCode instance which is used to build code.

  • field - a reference to FieldDecl with the field description from serialization information.

  • cur_proc_int - a related Procedure to the serialized data.

Returns

A SchemeResult is returned.

source

pub fn get_name(&self) -> &String

Returns a title of the serializer.

source

pub fn clone_name(&self) -> Rc<String>

Clones a title of the serializer.

source

pub fn new_root_proc(&mut self, proc: Procedure) -> StaticSchemeRes<()>

Declares new procedure

source

pub fn new_proc(&mut self, proc: Procedure) -> StaticSchemeRes<()>

Declares new procedure.

source

pub fn symbol_define(&mut self, def: Define) -> StaticSchemeRes<()>

Declares symbol.

source

pub fn symbol_enum_define(&mut self, def: DefineEnum) -> StaticSchemeRes<()>

source

pub fn set_root_serialization_struct( &mut self, ser: Structure ) -> StaticSchemeRes<()>

Sets the root serialization descriptor.

source

pub fn add_serialization_struct(&mut self, ser: Structure)

Declares serialization information for structure.

source

pub fn add_serialization_enum(&mut self, enm: Enumerator)

Declares a serialization information for enum.

source

pub fn get_serialization_struct_by_procname( &self, proc_name: &String ) -> StaticSchemeRes<Rc<Structure>>

Searches for the Structure by the proc_name which is a procedure name.

Arguments
  • proc_name - a reference to String which contains title of the procedure.
Returns

A SchemeResult with result is returned.

source

pub fn get_serialization_struct_by_procname_opt( &self, proc_name: &String ) -> Option<Rc<Structure>>

source

pub fn get_serialization_struct_by_name( &self, struct_name: &str ) -> StaticSchemeRes<Rc<Structure>>

source

pub fn get_serialization_enum_by_procname( &self, proc_name: &String ) -> SerializationPartialRes<&Enumerator>

Searches for the Enumerator serialization information for enum by the procedure name which enumerator instance is serializing.

Arguments
  • proc_name - a reference to String which points to procedure name.
Returns

A SchemeResult is returned with:

source

pub fn get_procedure_by_name( &self, proc_name: &String ) -> Option<&Rc<Procedure>>

source

pub fn get_root_ser(&self) -> Option<Rc<Structure>>

Returns root serialization structure if was defined

source

pub fn get_root_proc(&self) -> Option<Rc<Procedure>>

Returns root procedure.

The Rc inside Option is cloned.

source

pub fn get_define_list_iter(&self) -> Iter<'_, Rc<String>, Rc<Define>>

Returns iterator to defined symbols.

source

pub fn get_enum_define_list_iter(&self) -> Iter<'_, Rc<String>, Rc<DefineEnum>>

Returns iterator to defined enum symbols.

source

pub fn get_enum_define_value_by_key( &self, key: &String ) -> Option<&Rc<DefineEnum>>

source

pub fn get_procedure_list_iter(&self) -> Iter<'_, Rc<String>, Rc<Procedure>>

Returns iterator to all defined procedures.

source§

impl Serializator

source

pub fn analyze(&self) -> SerializationPartialRes<AnalyzerErrors>

Performs analysis of static scheme. At the moment it is able to find unused procedures and arguments.

Returns

Function returns Result as SerializationPartialRes.

Examples found in repository?
examples/analyzer_error/test_err.rs (line 19)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main()
{
    let curdir = std::env::current_dir().unwrap();

    println!("{}", curdir.display());

    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    let res = 
        schm.run_from_file("examples/analyzer_error/schm_init.shm", None).unwrap();

    let scheme = res.get("test_auto").unwrap();

    let anres = scheme.analyze().unwrap();

    println!("{}", anres);

}
More examples
Hide additional examples
examples/complex_example_1/init_networking1.rs (line 21)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
fn main()
{
    let curdir = std::env::current_dir().unwrap();

    println!("{}", curdir.display());

    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    let res = schm.run_from_file("examples/complex_example_1/init_networking.shm", None).unwrap();

    let resser = res.get("networking").unwrap().clone();

    let anres = resser.analyze().unwrap();

    println!("errors:\n{}", anres);

    let mut curdir = std::env::current_dir().unwrap();

    curdir.push("examples/complex_example_1/init_networking_dyn1.shm");

    let lex = lexer::Lexer::from_file(curdir).unwrap();

    let dynenv = environment::DynEnvironment::new_root(resser.clone()).unwrap();

    let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap();

    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();

    let serialized = serde_json::to_string(&ret).unwrap();

    println!("Result:\n{}", serialized);

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);

    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            println!("{}", e);
        }
    }

}
examples/another/another.rs (line 34)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
fn main()
{
    let curdir = std::env::current_dir().unwrap();

    println!("{}", curdir.display());

    let schm = init::SchemeInit::new_with_path(curdir).unwrap();

    let res = schm.run_from_file("examples/another/init_l.shm", None).unwrap();

    let resser = res.get("logsmon").unwrap().clone();

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);
    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            println!("{}", e);
        }
    }

    let anres = resser.analyze().unwrap();

    println!("errors:\n{}", anres);

    let mut curdir = std::env::current_dir().unwrap();

    curdir.push("examples/another/data_l.shm");

    let lex = lexer::Lexer::from_file(curdir).unwrap();

    let dynenv = environment::DynEnvironment::new_root(resser.clone()).unwrap();

    let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap();

    /*let resser = res.get("logsmon").unwrap().clone();

    let anres = resser.analyze().unwrap();

    println!("errors:\n{}", anres);

    let mut curdir = std::env::current_dir().unwrap();

    curdir.push("examples/complex_example_1/init_networking_dyn1.shm");

    let lex = lexer::Lexer::from_file(curdir).unwrap();

    let dynenv = environment::DynEnvironment::new_root(resser.clone());

    let dyn_res = environment::DynEnvironment::run(&lex, dynenv).unwrap();

    let ret = serializator::Serialization::serialize(resser.clone(), dyn_res.clone()).unwrap();

    let serialized = serde_json::to_string(&ret).unwrap();

    println!("Result:\n{}", serialized);

    let mut rc = RustCode::new(&["Clone", "Debug", "Serialize", "Deserialize"], &["Clone", "Debug", "Serialize", "Deserialize"]);

    println!("Structures: ");
    match resser.generate_rust_structs(&mut rc)
    {
        Ok(_) => 
        {
            println!("{}", rc);
        },
        Err(e) => 
        {
            println!("{}", e);
        }
    }
*/
}

Trait Implementations§

source§

impl Clone for Serializator

A dummy clone. This instance must never be clonned.

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Serializator

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Serializator

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Serializator

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,