diff --git a/src/lib.rs b/src/lib.rs index 6ca3e38..2148c47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,7 @@ pub enum CompressedPixelUnpackData<'a> { Slice(&'a [u8]), } -pub trait HasContext { +pub trait HasContext : __private::Sealed { type Shader: Copy + Clone + Debug + Eq + Hash + Ord + PartialEq + PartialOrd; type Program: Copy + Clone + Debug + Eq + Hash + Ord + PartialEq + PartialOrd; type Buffer: Copy + Clone + Debug + Eq + Hash + Ord + PartialEq + PartialOrd; @@ -4175,3 +4175,9 @@ pub const XOR: u32 = 0x1506; pub const ZERO: u32 = 0; pub const ZERO_TO_ONE: u32 = 0x935F; + +mod __private { + /// Prevents [`HasContext`] from being implemented outside of this crate. + #[doc(hidden)] + pub trait Sealed {} +} diff --git a/src/native.rs b/src/native.rs index 3604bdb..231fcd6 100644 --- a/src/native.rs +++ b/src/native.rs @@ -176,6 +176,8 @@ pub struct NativeUniformLocation(pub native_gl::GLuint); #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct NativeTransformFeedback(pub NonZeroU32); +impl crate::__private::Sealed for Context {} + impl HasContext for Context { type Shader = NativeShader; type Program = NativeProgram; diff --git a/src/web_sys.rs b/src/web_sys.rs index 1ca7792..4cb4581 100644 --- a/src/web_sys.rs +++ b/src/web_sys.rs @@ -1359,6 +1359,8 @@ new_key_type! { pub struct WebRenderbufferKey; } new_key_type! { pub struct WebQueryKey; } new_key_type! { pub struct WebTransformFeedbackKey; } +impl crate::__private::Sealed for Context {} + impl HasContext for Context { type Shader = WebShaderKey; type Program = WebProgramKey;