Closed clouds56 closed 6 months ago
I see now DataObj
and DataArray
is not cloneable, is it by design?
When refactoring from_raw
for data.rs
, I keep current behavior (no clone), it's easy to make it cloneable
as uncomment @addref
version of impl_ptr_wrapper
// use this to make `DataObj` clonable since it has `obs_data_addref`.
// which means it's underlying pointer is managed by reference count.
impl_ptr_wrapper!(DataObj<'_>, obs_data_t, @addref: obs_data_addref, obs_data_release);
// when `get_ref` set to `@identity`, it means we could not add reference count for underlying pointer,
// so `impl_ptr_wrapper` would not generate `Clone` trait for this
impl_ptr_wrapper!(DataObj<'_>, obs_data_t, @identity, obs_data_release);
Awesome work, thank you!
I see now DataObj and DataArray is not cloneable, is it by design?
Probably not by design - likely just being cautious with the underlying pointers. I'm happy for you to choose and go with either version.
from_raw
andfrom_raw_unchecked
from_raw
for object own/managed in C, a temporary pointer is returned (e.g.obs_filter_get_target
).from_raw_unchecked
for object own/managed in Rust, will notaddref
the pointer, in order to handle with thing likeobs_data_create()
.DataObj<'_>
,DataArray<'_>
,Properties
areimpl_ptr_wrapper
with no CloneDisplayRef
,SourceRef
,OutputRef
,SceneRef
,SceneItemRef
areimpl_ptr_wrapper
ModuleRef
is special since it has no release.from_raw
andfrom_raw_uncheced
would returnOption<Self>
and convert to nullptr toNone
.SourceContext
toSourceRef
,ModuleContext
toModuleRef
, in order to keep consistence with otherAudioRef
,VideoRef
. NowContext
means state in rust andRef
means a pointer and the state in C. (we could add alias in order to keep backward compatibility).display()
toObsString
SceneRef
andDisplayRef
for correspondingobs_scene_t
andobs_display_t
.native_enum