@@ -25,6 +25,7 @@ use crate::export::NativeClass;
25
25
use crate :: private:: { get_api, ManuallyManagedClassPlaceholder , ReferenceCountedClassPlaceholder } ;
26
26
use crate :: sys;
27
27
28
+ pub use as_arg:: * ;
28
29
pub use instance:: * ;
29
30
pub use new_ref:: NewRef ;
30
31
pub use raw:: RawObject ;
@@ -33,6 +34,7 @@ pub mod bounds;
33
34
pub mod memory;
34
35
pub mod ownership;
35
36
37
+ mod as_arg;
36
38
mod instance;
37
39
mod new_ref;
38
40
mod raw;
@@ -305,8 +307,6 @@ unsafe impl<T: GodotObject, Own: Ownership + Send> Send for Ref<T, Own> {}
305
307
/// `Ref` is `Sync` if the thread access is `Shared`.
306
308
unsafe impl < T : GodotObject , Own : Ownership + Sync > Sync for Ref < T , Own > { }
307
309
308
- impl < T : GodotObject , Own : Ownership > private:: Sealed for Ref < T , Own > { }
309
-
310
310
/// `Ref` is `Copy` if the underlying object is manually-managed, and the access is not
311
311
/// `Unique`.
312
312
impl < T , Own > Copy for Ref < T , Own >
@@ -994,39 +994,6 @@ impl<'a, T: GodotObject> TRef<'a, T, Shared> {
994
994
}
995
995
}
996
996
997
- /// Trait for safe conversion from Godot object references into API method arguments. This is
998
- /// a sealed trait with no public interface.
999
- ///
1000
- /// In order to enforce thread safety statically, the ability to be passed to the engine is only
1001
- /// given to some reference types. Specifically, they are:
1002
- ///
1003
- /// - All *owned* `Ref<T, Unique>` references. The `Unique` access is lost if passed into a
1004
- /// method.
1005
- /// - Owned and borrowed `Shared` references, including temporary ones (`TRef`).
1006
- ///
1007
- /// It's unsound to pass `ThreadLocal` references to the engine because there is no guarantee
1008
- /// that the reference will stay on the same thread.
1009
- ///
1010
- /// To explicitly pass a null reference to the engine, use `Null::null` or `GodotObject::null`.
1011
- pub trait AsArg < T > : private:: Sealed {
1012
- #[ doc( hidden) ]
1013
- fn as_arg_ptr ( & self ) -> * mut sys:: godot_object ;
1014
-
1015
- #[ doc( hidden) ]
1016
- #[ inline]
1017
- unsafe fn to_arg_variant ( & self ) -> crate :: core_types:: Variant {
1018
- crate :: core_types:: Variant :: from_object_ptr ( self . as_arg_ptr ( ) )
1019
- }
1020
- }
1021
-
1022
- /// Trait for safe conversion from Godot object references into Variant. This is
1023
- /// a sealed trait with no public interface.
1024
- ///
1025
- /// Used for `Variant` methods and implementations as a trait bound to improve type inference.
1026
- pub trait AsVariant : AsArg < <Self as AsVariant >:: Target > {
1027
- type Target ;
1028
- }
1029
-
1030
997
/// Represents an explicit null reference in method arguments. This works around type inference
1031
998
/// issues with `Option`. You may create `Null`s with `Null::null` or `GodotObject::null`.
1032
999
pub struct Null < T > ( PhantomData < T > ) ;
@@ -1040,76 +1007,3 @@ impl<T: GodotObject> Null<T> {
1040
1007
Null ( PhantomData )
1041
1008
}
1042
1009
}
1043
-
1044
- impl < ' a , T > private:: Sealed for Null < T > { }
1045
- impl < ' a , T : GodotObject > AsArg < T > for Null < T > {
1046
- #[ inline]
1047
- fn as_arg_ptr ( & self ) -> * mut sys:: godot_object {
1048
- std:: ptr:: null_mut ( )
1049
- }
1050
- }
1051
- impl < ' a , T : GodotObject > AsVariant for Null < T > {
1052
- type Target = T ;
1053
- }
1054
-
1055
- impl < ' a , T : GodotObject > private:: Sealed for TRef < ' a , T , Shared > { }
1056
- impl < ' a , T , U > AsArg < U > for TRef < ' a , T , Shared >
1057
- where
1058
- T : GodotObject + SubClass < U > ,
1059
- U : GodotObject ,
1060
- {
1061
- #[ inline]
1062
- fn as_arg_ptr ( & self ) -> * mut sys:: godot_object {
1063
- self . as_ptr ( )
1064
- }
1065
- }
1066
- impl < ' a , T : GodotObject > AsVariant for TRef < ' a , T , Shared > {
1067
- type Target = T ;
1068
- }
1069
-
1070
- impl < T , U > AsArg < U > for Ref < T , Shared >
1071
- where
1072
- T : GodotObject + SubClass < U > ,
1073
- U : GodotObject ,
1074
- {
1075
- #[ inline]
1076
- fn as_arg_ptr ( & self ) -> * mut sys:: godot_object {
1077
- self . as_ptr ( )
1078
- }
1079
- }
1080
- impl < T : GodotObject > AsVariant for Ref < T , Shared > {
1081
- type Target = T ;
1082
- }
1083
-
1084
- impl < T , U > AsArg < U > for Ref < T , Unique >
1085
- where
1086
- T : GodotObject + SubClass < U > ,
1087
- U : GodotObject ,
1088
- {
1089
- #[ inline]
1090
- fn as_arg_ptr ( & self ) -> * mut sys:: godot_object {
1091
- self . as_ptr ( )
1092
- }
1093
- }
1094
- impl < T : GodotObject > AsVariant for Ref < T , Unique > {
1095
- type Target = T ;
1096
- }
1097
-
1098
- impl < ' a , T : GodotObject > private:: Sealed for & ' a Ref < T , Shared > { }
1099
- impl < ' a , T , U > AsArg < U > for & ' a Ref < T , Shared >
1100
- where
1101
- T : GodotObject + SubClass < U > ,
1102
- U : GodotObject ,
1103
- {
1104
- #[ inline]
1105
- fn as_arg_ptr ( & self ) -> * mut sys:: godot_object {
1106
- self . as_ptr ( )
1107
- }
1108
- }
1109
- impl < ' a , T : GodotObject > AsVariant for & ' a Ref < T , Shared > {
1110
- type Target = T ;
1111
- }
1112
-
1113
- mod private {
1114
- pub trait Sealed { }
1115
- }
0 commit comments