Wrappers provide a factory method that is responsible for returning a stream when it the wrapper is invoked using:

Wrappers can to store a pointer to their own instance specific data in stream->wrapperthis.

Make sure that you use the stream_closer hook to release any resources allocated by your wrapper when the stream is shutdown.

You can also override the fstat() call for the stream (useful when the actual implementation !== the actual resource).