Skip to main content

meta_language/translation/rust/
source_profiles.rs

1//! Existing independently selected Rust source factories.
2//! Public reexports preserve the frontend API and shared parser implementation.
3use super::{Result, SProgram, SourceProfiles, parse_rust_with_selected_profiles};
4
5/// Read a complete emitted Rust runtime under its independent owned interpretation.
6///
7/// # Errors
8/// Refuses unknown selectors and unproved runtime operations or source context.
9pub fn parse_rust_with_runtime_shell_model(source: &str, model: &str) -> Result<SProgram> {
10    crate::translation::runtime_shell::parse_source(source, model)
11}
12
13/// Reads a Rust program.
14///
15/// # Errors
16/// On syntax errors and on constructs outside the portable core.
17pub fn parse_rust(source: &str) -> Result<SProgram> {
18    parse_rust_with_array_result_model(source, "")
19}
20
21/// Read Rust under an explicit versioned scalar vector result admission model.
22///
23/// The empty model retains the original array result refusals. The fresh model
24/// admits constructor tails of owned vectors of direct scalar Copy values.
25///
26/// # Errors
27/// On unknown models, syntax errors and unsupported ownership or result proofs.
28pub fn parse_rust_with_array_result_model(source: &str, model: &str) -> Result<SProgram> {
29    parse_rust_with_source_models(source, model, "")
30}
31
32/// Read closed guarded returns under an explicitly selected source profile.
33///
34/// # Errors
35/// Refuses unknown models and unsupported or escaping completions.
36pub fn parse_rust_with_completion_model(source: &str, model: &str) -> Result<SProgram> {
37    parse_rust_with_source_models(source, "", model)
38}
39
40/// Read Rust with independently selected array-result and completion profiles.
41///
42/// Empty strings retain each corresponding legacy source-admission contract.
43///
44/// # Errors
45/// Refuses unknown models and propagates precise source-admission diagnostics.
46pub fn parse_rust_with_source_models(
47    source: &str,
48    array_result_model: &str,
49    completion_model: &str,
50) -> Result<SProgram> {
51    parse_rust_with_source_profiles(source, array_result_model, completion_model, "")
52}
53
54/// Capture actual structured source header facts under an explicit model.
55///
56/// # Errors
57/// Refuses unknown source models and unsupported source declarations.
58pub fn parse_rust_with_source_signature_model(source: &str, model: &str) -> Result<SProgram> {
59    parse_rust_with_source_profiles(source, "", "", model)
60}
61
62/// Read independently selected array, completion and source signature models.
63///
64/// # Errors
65/// Propagates model, syntax and source admission diagnostics.
66pub fn parse_rust_with_source_profiles(
67    source: &str,
68    array_result_model: &str,
69    completion_model: &str,
70    source_signature_model: &str,
71) -> Result<SProgram> {
72    parse_rust_with_loop_profiles(
73        source,
74        array_result_model,
75        completion_model,
76        source_signature_model,
77        "",
78    )
79}
80
81/// Read an explicitly selected closed primitive scalar loop interpretation.
82///
83/// # Errors
84/// Refuses unknown models, unproved owners and unsupported loop state or effects.
85pub fn parse_rust_with_scalar_loop_model(source: &str, model: &str) -> Result<SProgram> {
86    parse_rust_with_loop_profiles(source, "", "", "", model)
87}
88
89pub fn parse_rust_with_loop_profiles(
90    source: &str,
91    array_result_model: &str,
92    completion_model: &str,
93    source_signature_model: &str,
94    scalar_loop_model: &str,
95) -> Result<SProgram> {
96    parse_rust_with_primitive_profiles(
97        source,
98        array_result_model,
99        completion_model,
100        source_signature_model,
101        scalar_loop_model,
102        "",
103    )
104}
105
106/// Read the explicitly selected standard binary64 source owner interpretation.
107///
108/// # Errors
109/// Refuses unproved qualified paths, aliases, ownership and primitive contexts.
110pub fn parse_rust_with_primitive_owner_model(
111    source: &str,
112    model: &str,
113    source_signature_model: &str,
114) -> Result<SProgram> {
115    parse_rust_with_primitive_profiles(source, "", "", source_signature_model, "", model)
116}
117
118fn parse_rust_with_primitive_profiles(
119    source: &str,
120    array_result_model: &str,
121    completion_model: &str,
122    source_signature_model: &str,
123    scalar_loop_model: &str,
124    primitive_owner_model: &str,
125) -> Result<SProgram> {
126    parse_rust_with_admitted_profiles(
127        source,
128        array_result_model,
129        completion_model,
130        source_signature_model,
131        scalar_loop_model,
132        primitive_owner_model,
133        "",
134    )
135}
136
137/// Read the explicit closed empty primitive option source interpretation.
138///
139/// # Errors
140/// Refuses unknown models, nonstandard owners and bodies outside the empty profile.
141pub fn parse_rust_with_empty_option_source_model(source: &str, model: &str) -> Result<SProgram> {
142    parse_rust_with_admitted_profiles(source, "", "", "", "", "", model)
143}
144
145fn parse_rust_with_admitted_profiles(
146    source: &str,
147    array_result_model: &str,
148    completion_model: &str,
149    source_signature_model: &str,
150    scalar_loop_model: &str,
151    primitive_owner_model: &str,
152    empty_option_source_model: &str,
153) -> Result<SProgram> {
154    parse_rust_with_selected_profiles(
155        source,
156        SourceProfiles {
157            array_result: array_result_model,
158            completion: completion_model,
159            source_signature: source_signature_model,
160            scalar_loop: scalar_loop_model,
161            primitive_owner: primitive_owner_model,
162            empty_option_source: empty_option_source_model,
163            ..SourceProfiles::default()
164        },
165    )
166}
167
168/// Read Rust with actual source type-namespace ownership and ordered spellings.
169///
170/// # Errors
171/// Refuses unknown selectors, unowned source bindings and unsupported positions.
172pub fn parse_rust_with_type_namespace_model(
173    source: &str,
174    model: &str,
175    source_signature_model: &str,
176) -> Result<SProgram> {
177    parse_rust_with_selected_profiles(
178        source,
179        SourceProfiles {
180            type_namespace: model,
181            source_signature: source_signature_model,
182            ..SourceProfiles::default()
183        },
184    )
185}
186
187/// Read complete closed pure Unit programs under the independently selected model.
188///
189/// # Errors
190/// Refuses unknown selectors, unsupported source context and unproved Unit calls.
191pub fn parse_rust_with_pure_unit_call_model(source: &str, model: &str) -> Result<SProgram> {
192    parse_rust_with_selected_profiles(
193        source,
194        SourceProfiles {
195            pure_unit_call: model,
196            ..SourceProfiles::default()
197        },
198    )
199}