httk.core.views.view¶
Classes¶
A set of views allow manipulating data and state of a backend through different interfaces. |
Module Contents¶
- class httk.core.views.view.View[BackendT: httk.core.views.backend.Backend][source]¶
A set of views allow manipulating data and state of a backend through different interfaces. Hence, creating a View from a Backend, or from another View, allows to read and operate on the data through the interface of that view, even if it is not the natural representation of the underlying data.
Important: views are always meant to reference the data and state of the same underlying object, hence, e.g.:
If a function is given an X object, and the function applies an Xvariant1View and then calls, e.g., close() via that view, the excpectation should be that the original X object is now also closed.
When, e.g., a TextstreamStringView is created on an already partially read stream, only the unread data will appear through that string interface.
All backends and views of the same kind of data (X) should be combined into a type union XLike that functions use to declare they support this kind of data. Such functions should start with creating a View on the passed data, giving them access to the data in a single desired format.
- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.