Skip to main content

TypeScriptBackend

Struct TypeScriptBackend 

Source
pub struct TypeScriptBackend;
Expand description

TypeScript code generation backend.

Wraps the existing TypeScript emitters and implements the language-agnostic CodegenBackend trait, enabling generate_all to be called generically.

Trait Implementations§

Source§

impl CodegenBackend for TypeScriptBackend

Source§

fn map_type(&self, capnp_type: &str) -> String

Map a Cap’n Proto type name to the target language’s type. Read more
Source§

fn setter_method(&self, type_name: &str) -> Option<String>

Return the setter method name on a builder for this type, if the runtime supports a direct method call. Returns None for types handled specially (struct pointers, enum ordinals, etc.).
Source§

fn getter_expr(&self, reader_var: &str, field: &FieldDef) -> String

Return an expression that reads a field’s value from a reader variable.
Source§

fn default_value(&self, type_name: &str) -> String

Return the default value expression for a type (used for optional field coalescing).
Source§

fn generate_service_file( &self, service_name: &str, schema: &ParsedSchema, ) -> String

Generate the complete source file content for a service schema.
Source§

fn runtime_file(&self) -> (String, String)

Return (filename, content) for the shared runtime file included in all output. Read more
Source§

fn file_extension(&self) -> &str

Return the file extension for generated service files (e.g., "ts", "py").
Source§

fn index_file( &self, all_names: &[String], client_names: &[String], module_contents: &[(String, String)], ) -> Option<(String, String)>

Return (filename, content) for an optional index/manifest file. 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, 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.