Consider adding PhantomData to Image and Pipe memory objects
Closed this issue · 2 comments
kenba commented
Consider adding PhantomData to Image and Pipe memory objects to match the Buffer implementation of pull request #1.
kenba commented
PhantomData was added to Buffer
because a Buffer
refers to an array/Vector of data of a given type and the PhantomData is used to hold the type information to help the Rust compiler's type checking.
Image
and Pipe
are different in that they refer to the underlying data in different ways:
- An
Image
refers to the underlying image incl_image_format
andcl_image_desc
structures. - A
Pipe
only refers to thepipe_packet_size
, i.e. thesizeof
the type of data being sent down thePipe
.
There is nothing to be gained by storing type information in Image
or Pipe
, so they do not require a PhantomData variable.
There is also no reason for any Image
or Pipe
methods to be declared as template functions, so the templates should be removed.