GoCodeGen

Struct GoCodeGen 

Source
pub struct GoCodeGen<'model> { /* private fields */ }

Implementations§

Source§

impl<'model> GoCodeGen<'model>

Source

pub fn new(model: Option<&'model Model>, is_tinygo: bool) -> Self

Trait Implementations§

Source§

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>

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

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<()>

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>

Complete generation and return the output bytes

Source§

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

generate Go method name: capitalized to make public

Source§

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

generate Go type name: PascalCase

Source§

fn get_file_extension(&self) -> &'static str

returns Go source file extension

Source§

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<()>

generate the source file header
Source§

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<()>

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>

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)

Write documentation for item
Source§

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<()>

append suffix to type name, for example “Game”, “Context” -> “GameContext”
Source§

fn has_rename_trait(&self, traits: &AppliedTraits) -> Option<String>

Source§

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>

Convert field name to its target-language-idiomatic case style implementors should override to_field_name_case
Source§

fn get_field_name_and_ser_name( &self, field: &NumberedMember, ) -> Result<(String, String)>

Source§

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

The full operation name with service prefix The default implementation is provided and should not be overridden
Source§

fn format(&mut self, files: Vec<PathBuf>, lc: &LanguageConfig) -> Result<()>

After code generation has completed for all files, this method is called once per output language to allow code formatters to run. The files parameter contains a list of all files written or updated.
Source§

impl<'model> Default for GoCodeGen<'model>

Source§

fn default() -> GoCodeGen<'model>

Returns the “default value” for a type. Read more

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,