Skip to content

Commit 0c83286

Browse files
committed
Attempt to use a generic Device for BufferHandle impl
1 parent a7429b7 commit 0c83286

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/device/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,34 +185,37 @@ impl<D: Device, T> fmt::Debug for BufferHandle<D, T> {
185185
}
186186
}
187187

188-
impl<T> BufferHandle<back::GlDevice, T> {
188+
impl<D: Device, T> BufferHandle<D, T> {
189189
/// Create a type-safe BufferHandle from a RawBufferHandle
190-
pub fn from_raw(handle: RawBufferHandle<back::GlDevice>) -> BufferHandle<back::GlDevice, T> {
190+
pub fn from_raw(handle: RawBufferHandle<D>) -> BufferHandle<D, T> {
191191
BufferHandle {
192192
raw: handle,
193193
}
194194
}
195195

196196
/// Cast the type this BufferHandle references
197-
pub fn cast<U>(self) -> BufferHandle<back::GlDevice, U> {
197+
pub fn cast<U>(self) -> BufferHandle<D, U> {
198198
BufferHandle::from_raw(self.raw)
199199
}
200200

201-
/// Get the underlying GL name for this BufferHandle
202-
pub fn get_name(&self) -> back::Buffer {
201+
/// Get the underlying name for this BufferHandle
202+
pub fn get_name(&self) -> <D as Device>::Buffer {
203203
self.raw.get_name()
204204
}
205205

206+
/// Get the underlying raw Handle
207+
pub fn raw(&self) -> RawBufferHandle<D> {
208+
self.raw
209+
}
210+
}
211+
212+
// FIXME: These should be implemented over a generic `Device`, but we get a lifetime error
213+
impl<T> BufferHandle<back::GlDevice, T> {
206214
/// Get the associated information about the buffer
207215
pub fn get_info(&self) -> &BufferInfo {
208216
self.raw.get_info()
209217
}
210218

211-
/// Get the underlying raw Handle
212-
pub fn raw(&self) -> RawBufferHandle<back::GlDevice> {
213-
self.raw
214-
}
215-
216219
/// Get the number of elements in the buffer.
217220
///
218221
/// Fails if `T` is zero-sized.

0 commit comments

Comments
 (0)