Skip to main content

SchemaConverter

Struct SchemaConverter 

Source
pub struct SchemaConverter {
    pub emit_local_placeholders: bool,
    pub type_prefix: String,
    pub is_private: bool,
}
Expand description

Converts a JSON Schema document into LuaLS (EmmyLua) annotation strings.

Fields§

§emit_local_placeholders: bool

If true, emit local X = {} after each class definition so that the annotations have a symbol to attach to.

§type_prefix: String

Prefix to add to all class and alias names (e.g. “schema.”).

§is_private: bool

Implementations§

Source§

impl SchemaConverter

Source

pub fn new(is_private: bool) -> Self

Source

pub fn convert(&self, schema: &Value) -> ConvertResult

Convert a JSON Schema (as serde_json::Value) into EmmyLua annotation text.

Source

pub fn convert_from_str(&self, json_str: &str) -> Result<ConvertResult, Error>

Convert a JSON Schema string into LuaLS annotation text.

Trait Implementations§

Source§

impl Default for SchemaConverter

Source§

fn default() -> Self

Returns the “default value” for a type. 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.