forked from rojo-rbx/rojo
Support setting referent properties via attributes (#843)
Co-authored-by: Kenneth Loeffler <kenloef@gmail.com>
This commit is contained in:
30
src/rojo_ref.rs
Normal file
30
src/rojo_ref.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use std::{fmt, sync::Arc};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const REF_ID_ATTRIBUTE_NAME: &str = "Rojo_Id";
|
||||
pub const REF_POINTER_ATTRIBUTE_PREFIX: &str = "Rojo_Target_";
|
||||
|
||||
// TODO add an internment strategy for RojoRefs
|
||||
// Something like what rbx-dom does for SharedStrings probably works
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Hash, Clone, Serialize, Deserialize, Eq)]
|
||||
pub struct RojoRef(Arc<String>);
|
||||
|
||||
impl RojoRef {
|
||||
#[inline]
|
||||
pub fn new(id: String) -> Self {
|
||||
Self(Arc::from(id))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.0.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for RojoRef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.as_str())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user