pub struct GoCodeGen<'model> { /* private fields */ }Implementations§
Trait Implementations§
Source§impl<'model> CodeGen for GoCodeGen<'model>
impl<'model> CodeGen for GoCodeGen<'model>
Source§fn init(
&mut self,
model: Option<&Model>,
_lc: &LanguageConfig,
_output_dir: Option<&Path>,
_renderer: &mut Renderer<'_>,
) -> Result<(), Error>
fn init( &mut self, model: Option<&Model>, _lc: &LanguageConfig, _output_dir: Option<&Path>, _renderer: &mut Renderer<'_>, ) -> Result<(), Error>
Initialize code generator and renderer for language output.j This hook is called before any code is generated and can be used to initialize code generator and/or perform additional processing before output files are created.
Source§fn source_formatter(
&self,
args: Vec<String>,
) -> Result<Box<dyn SourceFormatter>>
fn source_formatter( &self, args: Vec<String>, ) -> Result<Box<dyn SourceFormatter>>
Set up go formatter based on ‘tinygo.formatter’ settings in codegen.toml
Source§fn init_file(
&mut self,
w: &mut Writer,
model: &Model,
file_config: &OutputFile,
params: &BTreeMap<String, Value>,
) -> Result<()>
fn init_file( &mut self, w: &mut Writer, model: &Model, file_config: &OutputFile, params: &BTreeMap<String, Value>, ) -> Result<()>
Perform any initialization required prior to code generation for a file
model may be used to check model metadata
namespace is the namespace in the model to generate
Source§fn finalize(&mut self, w: &mut Writer) -> Result<Bytes>
fn finalize(&mut self, w: &mut Writer) -> Result<Bytes>
Complete generation and return the output bytes
Source§fn write_comment(&mut self, w: &mut Writer, _kind: CommentKind, line: &str)
fn write_comment(&mut self, w: &mut Writer, _kind: CommentKind, line: &str)
Write a single-line comment
Source§fn to_method_name_case(&self, name: &str) -> String
fn to_method_name_case(&self, name: &str) -> String
generate Go method name: capitalized to make public
Source§fn to_field_name_case(&self, name: &str) -> String
fn to_field_name_case(&self, name: &str) -> String
generate Go field name: capitalized to make public
Source§fn to_type_name_case(&self, name: &str) -> String
fn to_type_name_case(&self, name: &str) -> String
generate Go type name: PascalCase
Source§fn get_file_extension(&self) -> &'static str
fn get_file_extension(&self) -> &'static str
returns Go source file extension
Source§fn output_language(&self) -> OutputLanguage
fn output_language(&self) -> OutputLanguage
Returns current output language
Source§fn write_source_file_header(
&mut self,
w: &mut Writer,
_model: &Model,
_params: &BTreeMap<String, Value>,
) -> Result<()>
fn write_source_file_header( &mut self, w: &mut Writer, _model: &Model, _params: &BTreeMap<String, Value>, ) -> Result<()>
generate the source file header
Source§fn declare_types(
&mut self,
w: &mut Writer,
model: &Model,
params: &BTreeMap<String, Value>,
) -> Result<()>
fn declare_types( &mut self, w: &mut Writer, model: &Model, params: &BTreeMap<String, Value>, ) -> Result<()>
Write declarations for simple types, maps, and structures
Source§fn write_services(
&mut self,
w: &mut Writer,
model: &Model,
_params: &BTreeMap<String, Value>,
) -> Result<()>
fn write_services( &mut self, w: &mut Writer, model: &Model, _params: &BTreeMap<String, Value>, ) -> Result<()>
Write service declarations and implementation stubs
Source§fn generate_file(
&mut self,
w: &mut Writer,
model: &Model,
file_config: &OutputFile,
params: &BTreeMap<String, Value>,
) -> Result<Bytes>
fn generate_file( &mut self, w: &mut Writer, model: &Model, file_config: &OutputFile, params: &BTreeMap<String, Value>, ) -> Result<Bytes>
This entrypoint drives output-file-specific code generation.
This default implementation invokes
init_file, write_source_file_header, declare_types, write_services, and finalize.
The return value is Bytes containing the data that should be written to the output file.Source§fn write_documentation(&mut self, w: &mut Writer, _id: &Identifier, text: &str)
fn write_documentation(&mut self, w: &mut Writer, _id: &Identifier, text: &str)
Write documentation for item
fn write_ident(&self, w: &mut Writer, id: &Identifier)
Source§fn write_ident_with_suffix(
&mut self,
w: &mut Writer,
id: &Identifier,
suffix: &str,
) -> Result<()>
fn write_ident_with_suffix( &mut self, w: &mut Writer, id: &Identifier, suffix: &str, ) -> Result<()>
append suffix to type name, for example “Game”, “Context” -> “GameContext”
fn has_rename_trait(&self, traits: &AppliedTraits) -> Option<String>
Source§fn to_method_name(
&self,
method_id: &Identifier,
method_traits: &AppliedTraits,
) -> String
fn to_method_name( &self, method_id: &Identifier, method_traits: &AppliedTraits, ) -> String
Convert method name to its target-language-idiomatic case style
implementors should override to_method_name_case
Source§fn to_field_name(
&self,
member_id: &Identifier,
member_traits: &AppliedTraits,
) -> Result<String, Error>
fn to_field_name( &self, member_id: &Identifier, member_traits: &AppliedTraits, ) -> Result<String, Error>
Convert field name to its target-language-idiomatic case style
implementors should override to_field_name_case
fn get_field_name_and_ser_name( &self, field: &NumberedMember, ) -> Result<(String, String)>
Source§fn op_dispatch_name(&self, id: &Identifier) -> String
fn op_dispatch_name(&self, id: &Identifier) -> String
The operation name used in dispatch, from method
The default implementation is provided and should not be overridden
Source§fn full_dispatch_name(
&self,
service_id: &Identifier,
method_id: &Identifier,
) -> String
fn full_dispatch_name( &self, service_id: &Identifier, method_id: &Identifier, ) -> String
The full operation name with service prefix
The default implementation is provided and should not be overridden
Auto Trait Implementations§
impl<'model> Freeze for GoCodeGen<'model>
impl<'model> RefUnwindSafe for GoCodeGen<'model>
impl<'model> Send for GoCodeGen<'model>
impl<'model> Sync for GoCodeGen<'model>
impl<'model> Unpin for GoCodeGen<'model>
impl<'model> UnwindSafe for GoCodeGen<'model>
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