Rename rbx alisases to dom instead for roblox lib

This commit is contained in:
Filip Tibell 2023-03-18 09:29:53 +01:00
parent 5098b28ada
commit 560dc4acbe
No known key found for this signature in database
27 changed files with 260 additions and 265 deletions

View file

@ -1,21 +1,21 @@
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::{Variant as RbxVariant, VariantType as RbxVariantType}; use rbx_dom_weak::types::{Variant as DomValue, VariantType as DomType};
use crate::datatypes::extension::RbxVariantExt; use crate::datatypes::extension::DomValueExt;
use super::*; use super::*;
pub(crate) trait LuaToRbxVariant<'lua> { pub(crate) trait LuaToDomValue<'lua> {
fn lua_to_rbx_variant( fn lua_to_dom_value(
&self, &self,
lua: &'lua Lua, lua: &'lua Lua,
variant_type: RbxVariantType, variant_type: DomType,
) -> DatatypeConversionResult<RbxVariant>; ) -> DomConversionResult<DomValue>;
} }
pub(crate) trait RbxVariantToLua<'lua>: Sized { pub(crate) trait DomValueToLua<'lua>: Sized {
fn rbx_variant_to_lua(lua: &'lua Lua, variant: &RbxVariant) -> DatatypeConversionResult<Self>; fn dom_value_to_lua(lua: &'lua Lua, variant: &DomValue) -> DomConversionResult<Self>;
} }
/* /*
@ -28,27 +28,26 @@ pub(crate) trait RbxVariantToLua<'lua>: Sized {
*/ */
impl<'lua> RbxVariantToLua<'lua> for LuaValue<'lua> { impl<'lua> DomValueToLua<'lua> for LuaValue<'lua> {
fn rbx_variant_to_lua(lua: &'lua Lua, variant: &RbxVariant) -> DatatypeConversionResult<Self> { fn dom_value_to_lua(lua: &'lua Lua, variant: &DomValue) -> DomConversionResult<Self> {
use base64::engine::general_purpose::STANDARD_NO_PAD; use base64::engine::general_purpose::STANDARD_NO_PAD;
use base64::engine::Engine as _; use base64::engine::Engine as _;
use rbx_dom_weak::types as rbx; use rbx_dom_weak::types as dom;
use RbxVariant as Rbx;
match LuaAnyUserData::rbx_variant_to_lua(lua, variant) { match LuaAnyUserData::dom_value_to_lua(lua, variant) {
Ok(value) => Ok(LuaValue::UserData(value)), Ok(value) => Ok(LuaValue::UserData(value)),
Err(e) => match variant { Err(e) => match variant {
Rbx::Bool(b) => Ok(LuaValue::Boolean(*b)), DomValue::Bool(b) => Ok(LuaValue::Boolean(*b)),
Rbx::Int64(i) => Ok(LuaValue::Number(*i as f64)), DomValue::Int64(i) => Ok(LuaValue::Number(*i as f64)),
Rbx::Int32(i) => Ok(LuaValue::Number(*i as f64)), DomValue::Int32(i) => Ok(LuaValue::Number(*i as f64)),
Rbx::Float64(n) => Ok(LuaValue::Number(*n)), DomValue::Float64(n) => Ok(LuaValue::Number(*n)),
Rbx::Float32(n) => Ok(LuaValue::Number(*n as f64)), DomValue::Float32(n) => Ok(LuaValue::Number(*n as f64)),
Rbx::String(s) => Ok(LuaValue::String(lua.create_string(s)?)), DomValue::String(s) => Ok(LuaValue::String(lua.create_string(s)?)),
Rbx::Content(s) => Ok(LuaValue::String( DomValue::Content(s) => Ok(LuaValue::String(
lua.create_string(AsRef::<str>::as_ref(s))?, lua.create_string(AsRef::<str>::as_ref(s))?,
)), )),
Rbx::BinaryString(s) => { DomValue::BinaryString(s) => {
let encoded = STANDARD_NO_PAD.encode(AsRef::<[u8]>::as_ref(s)); let encoded = STANDARD_NO_PAD.encode(AsRef::<[u8]>::as_ref(s));
Ok(LuaValue::String(lua.create_string(&encoded)?)) Ok(LuaValue::String(lua.create_string(&encoded)?))
} }
@ -56,7 +55,7 @@ impl<'lua> RbxVariantToLua<'lua> for LuaValue<'lua> {
// NOTE: We need this special case here to handle default (nil) // NOTE: We need this special case here to handle default (nil)
// physical properties since our PhysicalProperties datatype // physical properties since our PhysicalProperties datatype
// implementation does not handle default at all, only custom // implementation does not handle default at all, only custom
Rbx::PhysicalProperties(rbx::PhysicalProperties::Default) => Ok(LuaValue::Nil), DomValue::PhysicalProperties(dom::PhysicalProperties::Default) => Ok(LuaValue::Nil),
_ => Err(e), _ => Err(e),
}, },
@ -64,50 +63,48 @@ impl<'lua> RbxVariantToLua<'lua> for LuaValue<'lua> {
} }
} }
impl<'lua> LuaToRbxVariant<'lua> for LuaValue<'lua> { impl<'lua> LuaToDomValue<'lua> for LuaValue<'lua> {
fn lua_to_rbx_variant( fn lua_to_dom_value(
&self, &self,
lua: &'lua Lua, lua: &'lua Lua,
variant_type: RbxVariantType, variant_type: DomType,
) -> DatatypeConversionResult<RbxVariant> { ) -> DomConversionResult<DomValue> {
use base64::engine::general_purpose::STANDARD_NO_PAD; use base64::engine::general_purpose::STANDARD_NO_PAD;
use base64::engine::Engine as _; use base64::engine::Engine as _;
use rbx_dom_weak::types as rbx; use rbx_dom_weak::types as dom;
use RbxVariant as Rbx;
use RbxVariantType as RbxType;
match (self, variant_type) { match (self, variant_type) {
(LuaValue::Boolean(b), RbxType::Bool) => Ok(Rbx::Bool(*b)), (LuaValue::Boolean(b), DomType::Bool) => Ok(DomValue::Bool(*b)),
(LuaValue::Integer(i), RbxType::Int64) => Ok(Rbx::Int64(*i as i64)), (LuaValue::Integer(i), DomType::Int64) => Ok(DomValue::Int64(*i as i64)),
(LuaValue::Integer(i), RbxType::Int32) => Ok(Rbx::Int32(*i)), (LuaValue::Integer(i), DomType::Int32) => Ok(DomValue::Int32(*i)),
(LuaValue::Integer(i), RbxType::Float64) => Ok(Rbx::Float64(*i as f64)), (LuaValue::Integer(i), DomType::Float64) => Ok(DomValue::Float64(*i as f64)),
(LuaValue::Integer(i), RbxType::Float32) => Ok(Rbx::Float32(*i as f32)), (LuaValue::Integer(i), DomType::Float32) => Ok(DomValue::Float32(*i as f32)),
(LuaValue::Number(n), RbxType::Int64) => Ok(Rbx::Int64(*n as i64)), (LuaValue::Number(n), DomType::Int64) => Ok(DomValue::Int64(*n as i64)),
(LuaValue::Number(n), RbxType::Int32) => Ok(Rbx::Int32(*n as i32)), (LuaValue::Number(n), DomType::Int32) => Ok(DomValue::Int32(*n as i32)),
(LuaValue::Number(n), RbxType::Float64) => Ok(Rbx::Float64(*n)), (LuaValue::Number(n), DomType::Float64) => Ok(DomValue::Float64(*n)),
(LuaValue::Number(n), RbxType::Float32) => Ok(Rbx::Float32(*n as f32)), (LuaValue::Number(n), DomType::Float32) => Ok(DomValue::Float32(*n as f32)),
(LuaValue::String(s), RbxType::String) => Ok(Rbx::String(s.to_str()?.to_string())), (LuaValue::String(s), DomType::String) => Ok(DomValue::String(s.to_str()?.to_string())),
(LuaValue::String(s), RbxType::Content) => { (LuaValue::String(s), DomType::Content) => {
Ok(Rbx::Content(s.to_str()?.to_string().into())) Ok(DomValue::Content(s.to_str()?.to_string().into()))
} }
(LuaValue::String(s), RbxType::BinaryString) => { (LuaValue::String(s), DomType::BinaryString) => {
Ok(Rbx::BinaryString(STANDARD_NO_PAD.decode(s)?.into())) Ok(DomValue::BinaryString(STANDARD_NO_PAD.decode(s)?.into()))
} }
// NOTE: We need this special case here to handle default (nil) // NOTE: We need this special case here to handle default (nil)
// physical properties since our PhysicalProperties datatype // physical properties since our PhysicalProperties datatype
// implementation does not handle default at all, only custom // implementation does not handle default at all, only custom
(LuaValue::Nil, RbxType::PhysicalProperties) => { (LuaValue::Nil, DomType::PhysicalProperties) => Ok(DomValue::PhysicalProperties(
Ok(Rbx::PhysicalProperties(rbx::PhysicalProperties::Default)) dom::PhysicalProperties::Default,
} )),
(LuaValue::UserData(u), d) => u.lua_to_rbx_variant(lua, d), (LuaValue::UserData(u), d) => u.lua_to_dom_value(lua, d),
(v, d) => Err(DatatypeConversionError::ToRbxVariant { (v, d) => Err(DomConversionError::ToDomValue {
to: d.variant_name(), to: d.variant_name(),
from: v.type_name(), from: v.type_name(),
detail: None, detail: None,
@ -126,13 +123,12 @@ impl<'lua> LuaToRbxVariant<'lua> for LuaValue<'lua> {
*/ */
impl<'lua> RbxVariantToLua<'lua> for LuaAnyUserData<'lua> { impl<'lua> DomValueToLua<'lua> for LuaAnyUserData<'lua> {
#[rustfmt::skip] #[rustfmt::skip]
fn rbx_variant_to_lua(lua: &'lua Lua, variant: &RbxVariant) -> DatatypeConversionResult<Self> { fn dom_value_to_lua(lua: &'lua Lua, variant: &DomValue) -> DomConversionResult<Self> {
use super::types::*; use super::types::*;
use rbx_dom_weak::types as rbx; use rbx_dom_weak::types as dom;
use RbxVariant as Rbx;
/* /*
NOTES: NOTES:
@ -147,45 +143,45 @@ impl<'lua> RbxVariantToLua<'lua> for LuaAnyUserData<'lua> {
*/ */
Ok(match variant.clone() { Ok(match variant.clone() {
Rbx::Axes(value) => lua.create_userdata(Axes::from(value))?, DomValue::Axes(value) => lua.create_userdata(Axes::from(value))?,
Rbx::Faces(value) => lua.create_userdata(Faces::from(value))?, DomValue::Faces(value) => lua.create_userdata(Faces::from(value))?,
Rbx::CFrame(value) => lua.create_userdata(CFrame::from(value))?, DomValue::CFrame(value) => lua.create_userdata(CFrame::from(value))?,
Rbx::BrickColor(value) => lua.create_userdata(BrickColor::from(value))?, DomValue::BrickColor(value) => lua.create_userdata(BrickColor::from(value))?,
Rbx::Color3(value) => lua.create_userdata(Color3::from(value))?, DomValue::Color3(value) => lua.create_userdata(Color3::from(value))?,
Rbx::Color3uint8(value) => lua.create_userdata(Color3::from(value))?, DomValue::Color3uint8(value) => lua.create_userdata(Color3::from(value))?,
Rbx::ColorSequence(value) => lua.create_userdata(ColorSequence::from(value))?, DomValue::ColorSequence(value) => lua.create_userdata(ColorSequence::from(value))?,
Rbx::Font(value) => lua.create_userdata(Font::from(value))?, DomValue::Font(value) => lua.create_userdata(Font::from(value))?,
Rbx::NumberRange(value) => lua.create_userdata(NumberRange::from(value))?, DomValue::NumberRange(value) => lua.create_userdata(NumberRange::from(value))?,
Rbx::NumberSequence(value) => lua.create_userdata(NumberSequence::from(value))?, DomValue::NumberSequence(value) => lua.create_userdata(NumberSequence::from(value))?,
Rbx::Ray(value) => lua.create_userdata(Ray::from(value))?, DomValue::Ray(value) => lua.create_userdata(Ray::from(value))?,
Rbx::Rect(value) => lua.create_userdata(Rect::from(value))?, DomValue::Rect(value) => lua.create_userdata(Rect::from(value))?,
Rbx::UDim(value) => lua.create_userdata(UDim::from(value))?, DomValue::UDim(value) => lua.create_userdata(UDim::from(value))?,
Rbx::UDim2(value) => lua.create_userdata(UDim2::from(value))?, DomValue::UDim2(value) => lua.create_userdata(UDim2::from(value))?,
Rbx::Region3(value) => lua.create_userdata(Region3::from(value))?, DomValue::Region3(value) => lua.create_userdata(Region3::from(value))?,
Rbx::Region3int16(value) => lua.create_userdata(Region3int16::from(value))?, DomValue::Region3int16(value) => lua.create_userdata(Region3int16::from(value))?,
Rbx::Vector2(value) => lua.create_userdata(Vector2::from(value))?, DomValue::Vector2(value) => lua.create_userdata(Vector2::from(value))?,
Rbx::Vector2int16(value) => lua.create_userdata(Vector2int16::from(value))?, DomValue::Vector2int16(value) => lua.create_userdata(Vector2int16::from(value))?,
Rbx::Vector3(value) => lua.create_userdata(Vector3::from(value))?, DomValue::Vector3(value) => lua.create_userdata(Vector3::from(value))?,
Rbx::Vector3int16(value) => lua.create_userdata(Vector3int16::from(value))?, DomValue::Vector3int16(value) => lua.create_userdata(Vector3int16::from(value))?,
Rbx::OptionalCFrame(value) => match value { DomValue::OptionalCFrame(value) => match value {
Some(value) => lua.create_userdata(CFrame::from(value))?, Some(value) => lua.create_userdata(CFrame::from(value))?,
None => lua.create_userdata(CFrame::IDENTITY)? None => lua.create_userdata(CFrame::IDENTITY)?
}, },
Rbx::PhysicalProperties(rbx::PhysicalProperties::Custom(value)) => { DomValue::PhysicalProperties(dom::PhysicalProperties::Custom(value)) => {
lua.create_userdata(PhysicalProperties::from(value))? lua.create_userdata(PhysicalProperties::from(value))?
}, },
v => { v => {
return Err(DatatypeConversionError::FromRbxVariant { return Err(DomConversionError::FromDomValue {
from: v.variant_name(), from: v.variant_name(),
to: "userdata", to: "userdata",
detail: Some("Type not supported".to_string()), detail: Some("Type not supported".to_string()),
@ -195,63 +191,63 @@ impl<'lua> RbxVariantToLua<'lua> for LuaAnyUserData<'lua> {
} }
} }
impl<'lua> LuaToRbxVariant<'lua> for LuaAnyUserData<'lua> { impl<'lua> LuaToDomValue<'lua> for LuaAnyUserData<'lua> {
#[rustfmt::skip] #[rustfmt::skip]
fn lua_to_rbx_variant( fn lua_to_dom_value(
&self, &self,
_: &'lua Lua, _: &'lua Lua,
variant_type: RbxVariantType, variant_type: DomType,
) -> DatatypeConversionResult<RbxVariant> { ) -> DomConversionResult<DomValue> {
use super::types::*; use super::types::*;
use rbx_dom_weak::types as rbx; use rbx_dom_weak::types as dom;
let f = match variant_type { let f = match variant_type {
RbxVariantType::Axes => convert::<Axes, rbx::Axes>, DomType::Axes => convert::<Axes, dom::Axes>,
RbxVariantType::Faces => convert::<Faces, rbx::Faces>, DomType::Faces => convert::<Faces, dom::Faces>,
RbxVariantType::CFrame => convert::<CFrame, rbx::CFrame>, DomType::CFrame => convert::<CFrame, dom::CFrame>,
RbxVariantType::BrickColor => convert::<BrickColor, rbx::BrickColor>, DomType::BrickColor => convert::<BrickColor, dom::BrickColor>,
RbxVariantType::Color3 => convert::<Color3, rbx::Color3>, DomType::Color3 => convert::<Color3, dom::Color3>,
RbxVariantType::Color3uint8 => convert::<Color3, rbx::Color3uint8>, DomType::Color3uint8 => convert::<Color3, dom::Color3uint8>,
RbxVariantType::ColorSequence => convert::<ColorSequence, rbx::ColorSequence>, DomType::ColorSequence => convert::<ColorSequence, dom::ColorSequence>,
RbxVariantType::Enum => convert::<EnumItem, rbx::Enum>, DomType::Enum => convert::<EnumItem, dom::Enum>,
RbxVariantType::Font => convert::<Font, rbx::Font>, DomType::Font => convert::<Font, dom::Font>,
RbxVariantType::NumberRange => convert::<NumberRange, rbx::NumberRange>, DomType::NumberRange => convert::<NumberRange, dom::NumberRange>,
RbxVariantType::NumberSequence => convert::<NumberSequence, rbx::NumberSequence>, DomType::NumberSequence => convert::<NumberSequence, dom::NumberSequence>,
RbxVariantType::Rect => convert::<Rect, rbx::Rect>, DomType::Rect => convert::<Rect, dom::Rect>,
RbxVariantType::UDim => convert::<UDim, rbx::UDim>, DomType::UDim => convert::<UDim, dom::UDim>,
RbxVariantType::UDim2 => convert::<UDim2, rbx::UDim2>, DomType::UDim2 => convert::<UDim2, dom::UDim2>,
RbxVariantType::Ray => convert::<Ray, rbx::Ray>, DomType::Ray => convert::<Ray, dom::Ray>,
RbxVariantType::Region3 => convert::<Region3, rbx::Region3>, DomType::Region3 => convert::<Region3, dom::Region3>,
RbxVariantType::Region3int16 => convert::<Region3int16, rbx::Region3int16>, DomType::Region3int16 => convert::<Region3int16, dom::Region3int16>,
RbxVariantType::Vector2 => convert::<Vector2, rbx::Vector2>, DomType::Vector2 => convert::<Vector2, dom::Vector2>,
RbxVariantType::Vector2int16 => convert::<Vector2int16, rbx::Vector2int16>, DomType::Vector2int16 => convert::<Vector2int16, dom::Vector2int16>,
RbxVariantType::Vector3 => convert::<Vector3, rbx::Vector3>, DomType::Vector3 => convert::<Vector3, dom::Vector3>,
RbxVariantType::Vector3int16 => convert::<Vector3int16, rbx::Vector3int16>, DomType::Vector3int16 => convert::<Vector3int16, dom::Vector3int16>,
RbxVariantType::OptionalCFrame => return match self.borrow::<CFrame>() { DomType::OptionalCFrame => return match self.borrow::<CFrame>() {
Ok(value) => Ok(RbxVariant::OptionalCFrame(Some(rbx::CFrame::from(*value)))), Ok(value) => Ok(DomValue::OptionalCFrame(Some(dom::CFrame::from(*value)))),
Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)), Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)),
}, },
RbxVariantType::PhysicalProperties => return match self.borrow::<PhysicalProperties>() { DomType::PhysicalProperties => return match self.borrow::<PhysicalProperties>() {
Ok(value) => { Ok(value) => {
let props = rbx::CustomPhysicalProperties::from(*value); let props = dom::CustomPhysicalProperties::from(*value);
let custom = rbx::PhysicalProperties::Custom(props); let custom = dom::PhysicalProperties::Custom(props);
Ok(RbxVariant::PhysicalProperties(custom)) Ok(DomValue::PhysicalProperties(custom))
}, },
Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)), Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)),
}, },
_ => return Err(DatatypeConversionError::ToRbxVariant { _ => return Err(DomConversionError::ToDomValue {
to: variant_type.variant_name(), to: variant_type.variant_name(),
from: "userdata", from: "userdata",
detail: Some("Type not supported".to_string()), detail: Some("Type not supported".to_string()),
@ -262,31 +258,31 @@ impl<'lua> LuaToRbxVariant<'lua> for LuaAnyUserData<'lua> {
} }
} }
fn convert<Datatype, RbxType>( fn convert<TypeFrom, TypeTo>(
userdata: &LuaAnyUserData, userdata: &LuaAnyUserData,
variant_type: RbxVariantType, variant_type: DomType,
) -> DatatypeConversionResult<RbxVariant> ) -> DomConversionResult<DomValue>
where where
Datatype: LuaUserData + Clone + 'static, TypeFrom: LuaUserData + Clone + 'static,
RbxType: From<Datatype> + Into<RbxVariant>, TypeTo: From<TypeFrom> + Into<DomValue>,
{ {
match userdata.borrow::<Datatype>() { match userdata.borrow::<TypeFrom>() {
Ok(value) => Ok(RbxType::from(value.clone()).into()), Ok(value) => Ok(TypeTo::from(value.clone()).into()),
Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)), Err(e) => Err(lua_userdata_error_to_conversion_error(variant_type, e)),
} }
} }
fn lua_userdata_error_to_conversion_error( fn lua_userdata_error_to_conversion_error(
variant_type: RbxVariantType, variant_type: DomType,
error: LuaError, error: LuaError,
) -> DatatypeConversionError { ) -> DomConversionError {
match error { match error {
LuaError::UserDataTypeMismatch => DatatypeConversionError::ToRbxVariant { LuaError::UserDataTypeMismatch => DomConversionError::ToDomValue {
to: variant_type.variant_name(), to: variant_type.variant_name(),
from: "userdata", from: "userdata",
detail: Some("Type mismatch".to_string()), detail: Some("Type mismatch".to_string()),
}, },
e => DatatypeConversionError::ToRbxVariant { e => DomConversionError::ToDomValue {
to: variant_type.variant_name(), to: variant_type.variant_name(),
from: "userdata", from: "userdata",
detail: Some(format!("Internal error: {e}")), detail: Some(format!("Internal error: {e}")),

View file

@ -1,12 +1,12 @@
use super::*; use super::*;
pub(super) trait RbxVariantExt { pub(super) trait DomValueExt {
fn variant_name(&self) -> &'static str; fn variant_name(&self) -> &'static str;
} }
impl RbxVariantExt for RbxVariantType { impl DomValueExt for DomType {
fn variant_name(&self) -> &'static str { fn variant_name(&self) -> &'static str {
use RbxVariantType::*; use DomType::*;
match self { match self {
Axes => "Axes", Axes => "Axes",
BinaryString => "BinaryString", BinaryString => "BinaryString",
@ -45,7 +45,7 @@ impl RbxVariantExt for RbxVariantType {
} }
} }
impl RbxVariantExt for RbxVariant { impl DomValueExt for DomValue {
fn variant_name(&self) -> &'static str { fn variant_name(&self) -> &'static str {
self.ty().variant_name() self.ty().variant_name()
} }

View file

@ -1,4 +1,4 @@
pub(crate) use rbx_dom_weak::types::{Variant as RbxVariant, VariantType as RbxVariantType}; pub(crate) use rbx_dom_weak::types::{Variant as DomValue, VariantType as DomType};
mod conversion; mod conversion;
mod extension; mod extension;

View file

@ -7,24 +7,24 @@ use mlua::Error as LuaError;
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub(crate) enum DatatypeConversionError { pub(crate) enum DomConversionError {
LuaError(LuaError), LuaError(LuaError),
External { External {
message: String, message: String,
}, },
FromRbxVariant { FromDomValue {
from: &'static str, from: &'static str,
to: &'static str, to: &'static str,
detail: Option<String>, detail: Option<String>,
}, },
ToRbxVariant { ToDomValue {
to: &'static str, to: &'static str,
from: &'static str, from: &'static str,
detail: Option<String>, detail: Option<String>,
}, },
} }
impl fmt::Display for DatatypeConversionError { impl fmt::Display for DomConversionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!( write!(
f, f,
@ -32,8 +32,7 @@ impl fmt::Display for DatatypeConversionError {
match self { match self {
Self::LuaError(error) => error.to_string(), Self::LuaError(error) => error.to_string(),
Self::External { message } => message.to_string(), Self::External { message } => message.to_string(),
Self::FromRbxVariant { from, to, detail } Self::FromDomValue { from, to, detail } | Self::ToDomValue { from, to, detail } => {
| Self::ToRbxVariant { from, to, detail } => {
match detail { match detail {
Some(d) => format!("Failed to convert from '{from}' into '{to}' - {d}"), Some(d) => format!("Failed to convert from '{from}' into '{to}' - {d}"),
None => format!("Failed to convert from '{from}' into '{to}'",), None => format!("Failed to convert from '{from}' into '{to}'",),
@ -44,28 +43,28 @@ impl fmt::Display for DatatypeConversionError {
} }
} }
impl Error for DatatypeConversionError {} impl Error for DomConversionError {}
impl From<LuaError> for DatatypeConversionError { impl From<LuaError> for DomConversionError {
fn from(value: LuaError) -> Self { fn from(value: LuaError) -> Self {
Self::LuaError(value) Self::LuaError(value)
} }
} }
impl From<IoError> for DatatypeConversionError { impl From<IoError> for DomConversionError {
fn from(value: IoError) -> Self { fn from(value: IoError) -> Self {
DatatypeConversionError::External { DomConversionError::External {
message: value.to_string(), message: value.to_string(),
} }
} }
} }
impl From<base64::DecodeError> for DatatypeConversionError { impl From<base64::DecodeError> for DomConversionError {
fn from(value: base64::DecodeError) -> Self { fn from(value: base64::DecodeError) -> Self {
DatatypeConversionError::External { DomConversionError::External {
message: value.to_string(), message: value.to_string(),
} }
} }
} }
pub(crate) type DatatypeConversionResult<T> = Result<T, DatatypeConversionError>; pub(crate) type DomConversionResult<T> = Result<T, DomConversionError>;

View file

@ -1,7 +1,7 @@
use core::fmt; use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Axes as RbxAxes; use rbx_dom_weak::types::Axes as DomAxes;
use super::{super::*, EnumItem}; use super::{super::*, EnumItem};
@ -96,8 +96,8 @@ impl fmt::Display for Axes {
} }
} }
impl From<RbxAxes> for Axes { impl From<DomAxes> for Axes {
fn from(v: RbxAxes) -> Self { fn from(v: DomAxes) -> Self {
let bits = v.bits(); let bits = v.bits();
Self { Self {
x: (bits & 1) == 1, x: (bits & 1) == 1,
@ -107,12 +107,12 @@ impl From<RbxAxes> for Axes {
} }
} }
impl From<Axes> for RbxAxes { impl From<Axes> for DomAxes {
fn from(v: Axes) -> Self { fn from(v: Axes) -> Self {
let mut bits = 0; let mut bits = 0;
bits += v.x as u8; bits += v.x as u8;
bits += (v.y as u8) << 1; bits += (v.y as u8) << 1;
bits += (v.z as u8) << 2; bits += (v.z as u8) << 2;
RbxAxes::from_bits(bits).expect("Invalid bits") DomAxes::from_bits(bits).expect("Invalid bits")
} }
} }

View file

@ -2,7 +2,7 @@ use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use rbx_dom_weak::types::BrickColor as RbxBrickColor; use rbx_dom_weak::types::BrickColor as DomBrickColor;
use super::{super::*, Color3}; use super::{super::*, Color3};
@ -13,7 +13,7 @@ use super::{super::*, Color3};
*/ */
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct BrickColor { pub struct BrickColor {
// Unfortunately we can't use RbxBrickColor as the backing type here // Unfortunately we can't use DomBrickColor as the backing type here
// because it does not expose any way of getting the actual rgb colors :-( // because it does not expose any way of getting the actual rgb colors :-(
pub(crate) number: u16, pub(crate) number: u16,
pub(crate) name: &'static str, pub(crate) name: &'static str,
@ -124,15 +124,15 @@ impl From<BrickColor> for Color3 {
} }
} }
impl From<RbxBrickColor> for BrickColor { impl From<DomBrickColor> for BrickColor {
fn from(v: RbxBrickColor) -> Self { fn from(v: DomBrickColor) -> Self {
color_from_name(v.to_string()) color_from_name(v.to_string())
} }
} }
impl From<BrickColor> for RbxBrickColor { impl From<BrickColor> for DomBrickColor {
fn from(v: BrickColor) -> Self { fn from(v: BrickColor) -> Self {
RbxBrickColor::from_number(v.number).unwrap_or(RbxBrickColor::MediumStoneGrey) DomBrickColor::from_number(v.number).unwrap_or(DomBrickColor::MediumStoneGrey)
} }
} }

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::{EulerRot, Mat4, Quat, Vec3}; use glam::{EulerRot, Mat4, Quat, Vec3};
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::{CFrame as RbxCFrame, Matrix3 as RbxMatrix3, Vector3 as RbxVector3}; use rbx_dom_weak::types::{CFrame as DomCFrame, Matrix3 as DomMatrix3, Vector3 as DomVector3};
use super::{super::*, Vector3}; use super::{super::*, Vector3};
@ -305,8 +305,8 @@ impl ops::Sub<Vector3> for CFrame {
} }
} }
impl From<RbxCFrame> for CFrame { impl From<DomCFrame> for CFrame {
fn from(v: RbxCFrame) -> Self { fn from(v: DomCFrame) -> Self {
CFrame(Mat4::from_cols( CFrame(Mat4::from_cols(
Vector3::from(v.orientation.x).0.extend(0.0), Vector3::from(v.orientation.x).0.extend(0.0),
Vector3::from(v.orientation.y).0.extend(0.0), Vector3::from(v.orientation.y).0.extend(0.0),
@ -316,15 +316,15 @@ impl From<RbxCFrame> for CFrame {
} }
} }
impl From<CFrame> for RbxCFrame { impl From<CFrame> for DomCFrame {
fn from(v: CFrame) -> Self { fn from(v: CFrame) -> Self {
let (rx, ry, rz) = v.orientation(); let (rx, ry, rz) = v.orientation();
RbxCFrame { DomCFrame {
position: RbxVector3::from(Vector3(v.position())), position: DomVector3::from(Vector3(v.position())),
orientation: RbxMatrix3::new( orientation: DomMatrix3::new(
RbxVector3::from(Vector3(rx)), DomVector3::from(Vector3(rx)),
RbxVector3::from(Vector3(ry)), DomVector3::from(Vector3(ry)),
RbxVector3::from(Vector3(rz)), DomVector3::from(Vector3(rz)),
), ),
} }
} }

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::Vec3; use glam::Vec3;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::{Color3 as RbxColor3, Color3uint8 as RbxColor3uint8}; use rbx_dom_weak::types::{Color3 as DomColor3, Color3uint8 as DomColor3uint8};
use super::super::*; use super::super::*;
@ -261,8 +261,8 @@ impl ops::Div<f32> for Color3 {
} }
} }
impl From<RbxColor3> for Color3 { impl From<DomColor3> for Color3 {
fn from(v: RbxColor3) -> Self { fn from(v: DomColor3) -> Self {
Self { Self {
r: v.r, r: v.r,
g: v.g, g: v.g,
@ -271,7 +271,7 @@ impl From<RbxColor3> for Color3 {
} }
} }
impl From<Color3> for RbxColor3 { impl From<Color3> for DomColor3 {
fn from(v: Color3) -> Self { fn from(v: Color3) -> Self {
Self { Self {
r: v.r, r: v.r,
@ -281,8 +281,8 @@ impl From<Color3> for RbxColor3 {
} }
} }
impl From<RbxColor3uint8> for Color3 { impl From<DomColor3uint8> for Color3 {
fn from(v: RbxColor3uint8) -> Self { fn from(v: DomColor3uint8) -> Self {
Self { Self {
r: (v.r as f32) / 255f32, r: (v.r as f32) / 255f32,
g: (v.g as f32) / 255f32, g: (v.g as f32) / 255f32,
@ -291,7 +291,7 @@ impl From<RbxColor3uint8> for Color3 {
} }
} }
impl From<Color3> for RbxColor3uint8 { impl From<Color3> for DomColor3uint8 {
fn from(v: Color3) -> Self { fn from(v: Color3) -> Self {
Self { Self {
r: v.r.clamp(u8::MIN as f32, u8::MAX as f32) as u8, r: v.r.clamp(u8::MIN as f32, u8::MAX as f32) as u8,

View file

@ -2,7 +2,7 @@ use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::{ use rbx_dom_weak::types::{
ColorSequence as RbxColorSequence, ColorSequenceKeypoint as RbxColorSequenceKeypoint, ColorSequence as DomColorSequence, ColorSequenceKeypoint as DomColorSequenceKeypoint,
}; };
use super::{super::*, Color3, ColorSequenceKeypoint}; use super::{super::*, Color3, ColorSequenceKeypoint};
@ -82,8 +82,8 @@ impl fmt::Display for ColorSequence {
} }
} }
impl From<RbxColorSequence> for ColorSequence { impl From<DomColorSequence> for ColorSequence {
fn from(v: RbxColorSequence) -> Self { fn from(v: DomColorSequence) -> Self {
Self { Self {
keypoints: v keypoints: v
.keypoints .keypoints
@ -95,14 +95,14 @@ impl From<RbxColorSequence> for ColorSequence {
} }
} }
impl From<ColorSequence> for RbxColorSequence { impl From<ColorSequence> for DomColorSequence {
fn from(v: ColorSequence) -> Self { fn from(v: ColorSequence) -> Self {
Self { Self {
keypoints: v keypoints: v
.keypoints .keypoints
.iter() .iter()
.cloned() .cloned()
.map(RbxColorSequenceKeypoint::from) .map(DomColorSequenceKeypoint::from)
.collect(), .collect(),
} }
} }

View file

@ -1,7 +1,7 @@
use core::fmt; use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::ColorSequenceKeypoint as RbxColorSequenceKeypoint; use rbx_dom_weak::types::ColorSequenceKeypoint as DomColorSequenceKeypoint;
use super::{super::*, Color3}; use super::{super::*, Color3};
@ -46,8 +46,8 @@ impl fmt::Display for ColorSequenceKeypoint {
} }
} }
impl From<RbxColorSequenceKeypoint> for ColorSequenceKeypoint { impl From<DomColorSequenceKeypoint> for ColorSequenceKeypoint {
fn from(v: RbxColorSequenceKeypoint) -> Self { fn from(v: DomColorSequenceKeypoint) -> Self {
Self { Self {
time: v.time, time: v.time,
color: v.color.into(), color: v.color.into(),
@ -55,7 +55,7 @@ impl From<RbxColorSequenceKeypoint> for ColorSequenceKeypoint {
} }
} }
impl From<ColorSequenceKeypoint> for RbxColorSequenceKeypoint { impl From<ColorSequenceKeypoint> for DomColorSequenceKeypoint {
fn from(v: ColorSequenceKeypoint) -> Self { fn from(v: ColorSequenceKeypoint) -> Self {
Self { Self {
time: v.time, time: v.time,

View file

@ -1,8 +1,8 @@
use core::fmt; use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Enum as RbxEnum; use rbx_dom_weak::types::Enum as DomEnum;
use rbx_reflection::DataType as RbxDataType; use rbx_reflection::DataType as DomDataType;
use super::{super::*, Enum}; use super::{super::*, Enum};
@ -64,7 +64,7 @@ impl EnumItem {
.properties .properties
.get(prop_name.as_ref())?; .get(prop_name.as_ref())?;
let prop_enum = match &prop.data_type { let prop_enum = match &prop.data_type {
RbxDataType::Enum(name) => db.enums.get(name.as_ref()), DomDataType::Enum(name) => db.enums.get(name.as_ref()),
_ => None, _ => None,
}?; }?;
let enum_name = prop_enum.items.iter().find_map(|(name, v)| { let enum_name = prop_enum.items.iter().find_map(|(name, v)| {
@ -107,8 +107,8 @@ impl PartialEq for EnumItem {
} }
} }
impl From<EnumItem> for RbxEnum { impl From<EnumItem> for DomEnum {
fn from(v: EnumItem) -> Self { fn from(v: EnumItem) -> Self {
RbxEnum::from_u32(v.value) DomEnum::from_u32(v.value)
} }
} }

View file

@ -1,7 +1,7 @@
use core::fmt; use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Faces as RbxFaces; use rbx_dom_weak::types::Faces as DomFaces;
use super::{super::*, EnumItem}; use super::{super::*, EnumItem};
@ -105,8 +105,8 @@ impl fmt::Display for Faces {
} }
} }
impl From<RbxFaces> for Faces { impl From<DomFaces> for Faces {
fn from(v: RbxFaces) -> Self { fn from(v: DomFaces) -> Self {
let bits = v.bits(); let bits = v.bits();
Self { Self {
right: (bits & 1) == 1, right: (bits & 1) == 1,
@ -119,7 +119,7 @@ impl From<RbxFaces> for Faces {
} }
} }
impl From<Faces> for RbxFaces { impl From<Faces> for DomFaces {
fn from(v: Faces) -> Self { fn from(v: Faces) -> Self {
let mut bits = 0; let mut bits = 0;
bits += v.right as u8; bits += v.right as u8;
@ -128,6 +128,6 @@ impl From<Faces> for RbxFaces {
bits += (v.left as u8) << 3; bits += (v.left as u8) << 3;
bits += (v.bottom as u8) << 4; bits += (v.bottom as u8) << 4;
bits += (v.front as u8) << 5; bits += (v.front as u8) << 5;
RbxFaces::from_bits(bits).expect("Invalid bits") DomFaces::from_bits(bits).expect("Invalid bits")
} }
} }

View file

@ -3,7 +3,7 @@ use std::str::FromStr;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::{ use rbx_dom_weak::types::{
Font as RbxFont, FontStyle as RbxFontStyle, FontWeight as RbxFontWeight, Font as DomFont, FontStyle as DomFontStyle, FontWeight as DomFontWeight,
}; };
use super::{super::*, EnumItem}; use super::{super::*, EnumItem};
@ -135,8 +135,8 @@ impl fmt::Display for Font {
} }
} }
impl From<RbxFont> for Font { impl From<DomFont> for Font {
fn from(v: RbxFont) -> Self { fn from(v: DomFont) -> Self {
Self { Self {
family: v.family, family: v.family,
weight: v.weight.into(), weight: v.weight.into(),
@ -146,9 +146,9 @@ impl From<RbxFont> for Font {
} }
} }
impl From<Font> for RbxFont { impl From<Font> for DomFont {
fn from(v: Font) -> Self { fn from(v: Font) -> Self {
RbxFont { DomFont {
family: v.family, family: v.family,
weight: v.weight.into(), weight: v.weight.into(),
style: v.style.into(), style: v.style.into(),
@ -157,27 +157,27 @@ impl From<Font> for RbxFont {
} }
} }
impl From<RbxFontWeight> for FontWeight { impl From<DomFontWeight> for FontWeight {
fn from(v: RbxFontWeight) -> Self { fn from(v: DomFontWeight) -> Self {
FontWeight::from_u16(v.as_u16()).expect("Missing font weight") FontWeight::from_u16(v.as_u16()).expect("Missing font weight")
} }
} }
impl From<FontWeight> for RbxFontWeight { impl From<FontWeight> for DomFontWeight {
fn from(v: FontWeight) -> Self { fn from(v: FontWeight) -> Self {
RbxFontWeight::from_u16(v.as_u16()).expect("Missing rbx font weight") DomFontWeight::from_u16(v.as_u16()).expect("Missing rbx font weight")
} }
} }
impl From<RbxFontStyle> for FontStyle { impl From<DomFontStyle> for FontStyle {
fn from(v: RbxFontStyle) -> Self { fn from(v: DomFontStyle) -> Self {
FontStyle::from_u8(v.as_u8()).expect("Missing font weight") FontStyle::from_u8(v.as_u8()).expect("Missing font weight")
} }
} }
impl From<FontStyle> for RbxFontStyle { impl From<FontStyle> for DomFontStyle {
fn from(v: FontStyle) -> Self { fn from(v: FontStyle) -> Self {
RbxFontStyle::from_u8(v.as_u8()).expect("Missing rbx font weight") DomFontStyle::from_u8(v.as_u8()).expect("Missing rbx font weight")
} }
} }

View file

@ -1,7 +1,7 @@
use core::fmt; use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::NumberRange as RbxNumberRange; use rbx_dom_weak::types::NumberRange as DomNumberRange;
use super::super::*; use super::super::*;
@ -51,8 +51,8 @@ impl fmt::Display for NumberRange {
} }
} }
impl From<RbxNumberRange> for NumberRange { impl From<DomNumberRange> for NumberRange {
fn from(v: RbxNumberRange) -> Self { fn from(v: DomNumberRange) -> Self {
Self { Self {
min: v.min, min: v.min,
max: v.max, max: v.max,
@ -60,7 +60,7 @@ impl From<RbxNumberRange> for NumberRange {
} }
} }
impl From<NumberRange> for RbxNumberRange { impl From<NumberRange> for DomNumberRange {
fn from(v: NumberRange) -> Self { fn from(v: NumberRange) -> Self {
Self { Self {
min: v.min, min: v.min,

View file

@ -2,7 +2,7 @@ use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::{ use rbx_dom_weak::types::{
NumberSequence as RbxNumberSequence, NumberSequenceKeypoint as RbxNumberSequenceKeypoint, NumberSequence as DomNumberSequence, NumberSequenceKeypoint as DomNumberSequenceKeypoint,
}; };
use super::{super::*, NumberSequenceKeypoint}; use super::{super::*, NumberSequenceKeypoint};
@ -92,8 +92,8 @@ impl fmt::Display for NumberSequence {
} }
} }
impl From<RbxNumberSequence> for NumberSequence { impl From<DomNumberSequence> for NumberSequence {
fn from(v: RbxNumberSequence) -> Self { fn from(v: DomNumberSequence) -> Self {
Self { Self {
keypoints: v keypoints: v
.keypoints .keypoints
@ -105,14 +105,14 @@ impl From<RbxNumberSequence> for NumberSequence {
} }
} }
impl From<NumberSequence> for RbxNumberSequence { impl From<NumberSequence> for DomNumberSequence {
fn from(v: NumberSequence) -> Self { fn from(v: NumberSequence) -> Self {
Self { Self {
keypoints: v keypoints: v
.keypoints .keypoints
.iter() .iter()
.cloned() .cloned()
.map(RbxNumberSequenceKeypoint::from) .map(DomNumberSequenceKeypoint::from)
.collect(), .collect(),
} }
} }

View file

@ -1,7 +1,7 @@
use core::fmt; use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::NumberSequenceKeypoint as RbxNumberSequenceKeypoint; use rbx_dom_weak::types::NumberSequenceKeypoint as DomNumberSequenceKeypoint;
use super::super::*; use super::super::*;
@ -52,8 +52,8 @@ impl fmt::Display for NumberSequenceKeypoint {
} }
} }
impl From<RbxNumberSequenceKeypoint> for NumberSequenceKeypoint { impl From<DomNumberSequenceKeypoint> for NumberSequenceKeypoint {
fn from(v: RbxNumberSequenceKeypoint) -> Self { fn from(v: DomNumberSequenceKeypoint) -> Self {
Self { Self {
time: v.time, time: v.time,
value: v.value, value: v.value,
@ -62,7 +62,7 @@ impl From<RbxNumberSequenceKeypoint> for NumberSequenceKeypoint {
} }
} }
impl From<NumberSequenceKeypoint> for RbxNumberSequenceKeypoint { impl From<NumberSequenceKeypoint> for DomNumberSequenceKeypoint {
fn from(v: NumberSequenceKeypoint) -> Self { fn from(v: NumberSequenceKeypoint) -> Self {
Self { Self {
time: v.time, time: v.time,

View file

@ -1,7 +1,7 @@
use core::fmt; use core::fmt;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::CustomPhysicalProperties as RbxCustomPhysicalProperties; use rbx_dom_weak::types::CustomPhysicalProperties as DomCustomPhysicalProperties;
use super::{super::*, EnumItem}; use super::{super::*, EnumItem};
@ -109,8 +109,8 @@ impl fmt::Display for PhysicalProperties {
} }
} }
impl From<RbxCustomPhysicalProperties> for PhysicalProperties { impl From<DomCustomPhysicalProperties> for PhysicalProperties {
fn from(v: RbxCustomPhysicalProperties) -> Self { fn from(v: DomCustomPhysicalProperties) -> Self {
Self { Self {
density: v.density, density: v.density,
friction: v.friction, friction: v.friction,
@ -121,9 +121,9 @@ impl From<RbxCustomPhysicalProperties> for PhysicalProperties {
} }
} }
impl From<PhysicalProperties> for RbxCustomPhysicalProperties { impl From<PhysicalProperties> for DomCustomPhysicalProperties {
fn from(v: PhysicalProperties) -> Self { fn from(v: PhysicalProperties) -> Self {
RbxCustomPhysicalProperties { DomCustomPhysicalProperties {
density: v.density, density: v.density,
friction: v.friction, friction: v.friction,
friction_weight: v.friction_weight, friction_weight: v.friction_weight,

View file

@ -2,7 +2,7 @@ use core::fmt;
use glam::Vec3; use glam::Vec3;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Ray as RbxRay; use rbx_dom_weak::types::Ray as DomRay;
use super::{super::*, Vector3}; use super::{super::*, Vector3};
@ -73,8 +73,8 @@ impl fmt::Display for Ray {
} }
} }
impl From<RbxRay> for Ray { impl From<DomRay> for Ray {
fn from(v: RbxRay) -> Self { fn from(v: DomRay) -> Self {
Ray { Ray {
origin: Vector3::from(v.origin).0, origin: Vector3::from(v.origin).0,
direction: Vector3::from(v.direction).0, direction: Vector3::from(v.direction).0,
@ -82,9 +82,9 @@ impl From<RbxRay> for Ray {
} }
} }
impl From<Ray> for RbxRay { impl From<Ray> for DomRay {
fn from(v: Ray) -> Self { fn from(v: Ray) -> Self {
RbxRay { DomRay {
origin: Vector3(v.origin).into(), origin: Vector3(v.origin).into(),
direction: Vector3(v.direction).into(), direction: Vector3(v.direction).into(),
} }

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::Vec2; use glam::Vec2;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Rect as RbxRect; use rbx_dom_weak::types::Rect as DomRect;
use super::{super::*, Vector2}; use super::{super::*, Vector2};
@ -99,8 +99,8 @@ impl ops::Sub for Rect {
} }
} }
impl From<RbxRect> for Rect { impl From<DomRect> for Rect {
fn from(v: RbxRect) -> Self { fn from(v: DomRect) -> Self {
Rect { Rect {
min: Vec2::new(v.min.x, v.min.y), min: Vec2::new(v.min.x, v.min.y),
max: Vec2::new(v.max.x, v.max.y), max: Vec2::new(v.max.x, v.max.y),
@ -108,9 +108,9 @@ impl From<RbxRect> for Rect {
} }
} }
impl From<Rect> for RbxRect { impl From<Rect> for DomRect {
fn from(v: Rect) -> Self { fn from(v: Rect) -> Self {
RbxRect { DomRect {
min: Vector2(v.min).into(), min: Vector2(v.min).into(),
max: Vector2(v.max).into(), max: Vector2(v.max).into(),
} }

View file

@ -2,7 +2,7 @@ use core::fmt;
use glam::{Mat4, Vec3}; use glam::{Mat4, Vec3};
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Region3 as RbxRegion3; use rbx_dom_weak::types::Region3 as DomRegion3;
use super::{super::*, CFrame, Vector3}; use super::{super::*, CFrame, Vector3};
@ -60,8 +60,8 @@ impl fmt::Display for Region3 {
} }
} }
impl From<RbxRegion3> for Region3 { impl From<DomRegion3> for Region3 {
fn from(v: RbxRegion3) -> Self { fn from(v: DomRegion3) -> Self {
Region3 { Region3 {
min: Vector3::from(v.min).0, min: Vector3::from(v.min).0,
max: Vector3::from(v.max).0, max: Vector3::from(v.max).0,
@ -69,9 +69,9 @@ impl From<RbxRegion3> for Region3 {
} }
} }
impl From<Region3> for RbxRegion3 { impl From<Region3> for DomRegion3 {
fn from(v: Region3) -> Self { fn from(v: Region3) -> Self {
RbxRegion3 { DomRegion3 {
min: Vector3(v.min).into(), min: Vector3(v.min).into(),
max: Vector3(v.max).into(), max: Vector3(v.max).into(),
} }

View file

@ -2,7 +2,7 @@ use core::fmt;
use glam::IVec3; use glam::IVec3;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Region3int16 as RbxRegion3int16; use rbx_dom_weak::types::Region3int16 as DomRegion3int16;
use super::{super::*, Vector3int16}; use super::{super::*, Vector3int16};
@ -50,8 +50,8 @@ impl fmt::Display for Region3int16 {
} }
} }
impl From<RbxRegion3int16> for Region3int16 { impl From<DomRegion3int16> for Region3int16 {
fn from(v: RbxRegion3int16) -> Self { fn from(v: DomRegion3int16) -> Self {
Region3int16 { Region3int16 {
min: Vector3int16::from(v.min).0, min: Vector3int16::from(v.min).0,
max: Vector3int16::from(v.max).0, max: Vector3int16::from(v.max).0,
@ -59,9 +59,9 @@ impl From<RbxRegion3int16> for Region3int16 {
} }
} }
impl From<Region3int16> for RbxRegion3int16 { impl From<Region3int16> for DomRegion3int16 {
fn from(v: Region3int16) -> Self { fn from(v: Region3int16) -> Self {
RbxRegion3int16 { DomRegion3int16 {
min: Vector3int16(v.min).into(), min: Vector3int16(v.min).into(),
max: Vector3int16(v.max).into(), max: Vector3int16(v.max).into(),
} }

View file

@ -2,7 +2,7 @@ use core::fmt;
use std::ops; use std::ops;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::UDim as RbxUDim; use rbx_dom_weak::types::UDim as DomUDim;
use super::super::*; use super::super::*;
@ -95,8 +95,8 @@ impl ops::Sub for UDim {
} }
} }
impl From<RbxUDim> for UDim { impl From<DomUDim> for UDim {
fn from(v: RbxUDim) -> Self { fn from(v: DomUDim) -> Self {
UDim { UDim {
scale: v.scale, scale: v.scale,
offset: v.offset, offset: v.offset,
@ -104,9 +104,9 @@ impl From<RbxUDim> for UDim {
} }
} }
impl From<UDim> for RbxUDim { impl From<UDim> for DomUDim {
fn from(v: UDim) -> Self { fn from(v: UDim) -> Self {
RbxUDim { DomUDim {
scale: v.scale, scale: v.scale,
offset: v.offset, offset: v.offset,
} }

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::Vec2; use glam::Vec2;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::UDim2 as RbxUDim2; use rbx_dom_weak::types::UDim2 as DomUDim2;
use super::{super::*, UDim}; use super::{super::*, UDim};
@ -140,8 +140,8 @@ impl ops::Sub for UDim2 {
} }
} }
impl From<RbxUDim2> for UDim2 { impl From<DomUDim2> for UDim2 {
fn from(v: RbxUDim2) -> Self { fn from(v: DomUDim2) -> Self {
UDim2 { UDim2 {
x: v.x.into(), x: v.x.into(),
y: v.y.into(), y: v.y.into(),
@ -149,9 +149,9 @@ impl From<RbxUDim2> for UDim2 {
} }
} }
impl From<UDim2> for RbxUDim2 { impl From<UDim2> for DomUDim2 {
fn from(v: UDim2) -> Self { fn from(v: UDim2) -> Self {
RbxUDim2 { DomUDim2 {
x: v.x.into(), x: v.x.into(),
y: v.y.into(), y: v.y.into(),
} }

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::{Vec2, Vec3}; use glam::{Vec2, Vec3};
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Vector2 as RbxVector2; use rbx_dom_weak::types::Vector2 as DomVector2;
use super::super::*; use super::super::*;
@ -128,14 +128,14 @@ impl ops::Div<f32> for Vector2 {
} }
} }
impl From<RbxVector2> for Vector2 { impl From<DomVector2> for Vector2 {
fn from(v: RbxVector2) -> Self { fn from(v: DomVector2) -> Self {
Vector2(Vec2 { x: v.x, y: v.y }) Vector2(Vec2 { x: v.x, y: v.y })
} }
} }
impl From<Vector2> for RbxVector2 { impl From<Vector2> for DomVector2 {
fn from(v: Vector2) -> Self { fn from(v: Vector2) -> Self {
RbxVector2 { x: v.0.x, y: v.0.y } DomVector2 { x: v.0.x, y: v.0.y }
} }
} }

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::IVec2; use glam::IVec2;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Vector2int16 as RbxVector2int16; use rbx_dom_weak::types::Vector2int16 as DomVector2int16;
use super::super::*; use super::super::*;
@ -103,8 +103,8 @@ impl ops::Div<i32> for Vector2int16 {
} }
} }
impl From<RbxVector2int16> for Vector2int16 { impl From<DomVector2int16> for Vector2int16 {
fn from(v: RbxVector2int16) -> Self { fn from(v: DomVector2int16) -> Self {
Vector2int16(IVec2 { Vector2int16(IVec2 {
x: v.x.clamp(i16::MIN, i16::MAX) as i32, x: v.x.clamp(i16::MIN, i16::MAX) as i32,
y: v.y.clamp(i16::MIN, i16::MAX) as i32, y: v.y.clamp(i16::MIN, i16::MAX) as i32,
@ -112,9 +112,9 @@ impl From<RbxVector2int16> for Vector2int16 {
} }
} }
impl From<Vector2int16> for RbxVector2int16 { impl From<Vector2int16> for DomVector2int16 {
fn from(v: Vector2int16) -> Self { fn from(v: Vector2int16) -> Self {
RbxVector2int16 { DomVector2int16 {
x: v.0.x.clamp(i16::MIN as i32, i16::MAX as i32) as i16, x: v.0.x.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
y: v.0.y.clamp(i16::MIN as i32, i16::MAX as i32) as i16, y: v.0.y.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
} }

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::Vec3; use glam::Vec3;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Vector3 as RbxVector3; use rbx_dom_weak::types::Vector3 as DomVector3;
use super::{super::*, EnumItem}; use super::{super::*, EnumItem};
@ -190,8 +190,8 @@ impl ops::Div<f32> for Vector3 {
} }
} }
impl From<RbxVector3> for Vector3 { impl From<DomVector3> for Vector3 {
fn from(v: RbxVector3) -> Self { fn from(v: DomVector3) -> Self {
Vector3(Vec3 { Vector3(Vec3 {
x: v.x, x: v.x,
y: v.y, y: v.y,
@ -200,9 +200,9 @@ impl From<RbxVector3> for Vector3 {
} }
} }
impl From<Vector3> for RbxVector3 { impl From<Vector3> for DomVector3 {
fn from(v: Vector3) -> Self { fn from(v: Vector3) -> Self {
RbxVector3 { DomVector3 {
x: v.0.x, x: v.0.x,
y: v.0.y, y: v.0.y,
z: v.0.z, z: v.0.z,

View file

@ -3,7 +3,7 @@ use std::ops;
use glam::IVec3; use glam::IVec3;
use mlua::prelude::*; use mlua::prelude::*;
use rbx_dom_weak::types::Vector3int16 as RbxVector3int16; use rbx_dom_weak::types::Vector3int16 as DomVector3int16;
use super::super::*; use super::super::*;
@ -105,8 +105,8 @@ impl ops::Div<i32> for Vector3int16 {
} }
} }
impl From<RbxVector3int16> for Vector3int16 { impl From<DomVector3int16> for Vector3int16 {
fn from(v: RbxVector3int16) -> Self { fn from(v: DomVector3int16) -> Self {
Vector3int16(IVec3 { Vector3int16(IVec3 {
x: v.x.clamp(i16::MIN, i16::MAX) as i32, x: v.x.clamp(i16::MIN, i16::MAX) as i32,
y: v.y.clamp(i16::MIN, i16::MAX) as i32, y: v.y.clamp(i16::MIN, i16::MAX) as i32,
@ -115,9 +115,9 @@ impl From<RbxVector3int16> for Vector3int16 {
} }
} }
impl From<Vector3int16> for RbxVector3int16 { impl From<Vector3int16> for DomVector3int16 {
fn from(v: Vector3int16) -> Self { fn from(v: Vector3int16) -> Self {
RbxVector3int16 { DomVector3int16 {
x: v.0.x.clamp(i16::MIN as i32, i16::MAX as i32) as i16, x: v.0.x.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
y: v.0.y.clamp(i16::MIN as i32, i16::MAX as i32) as i16, y: v.0.y.clamp(i16::MIN as i32, i16::MAX as i32) as i16,
z: v.0.z.clamp(i16::MIN as i32, i16::MAX as i32) as i16, z: v.0.z.clamp(i16::MIN as i32, i16::MAX as i32) as i16,