pub trait ProtocolModel {
// Required methods
fn init_model(&mut self, pipes: HashMap<String, PipeDescriptor>) -> bool;
fn new_protocol_model(type_model: TypeModelObject) -> Self;
}
Expand description
The trait for the protocol model, which defines what field we want to read/write to the typed Plumber pipe port.
This is the high-level Rust wrapper for the PSTD’s type model object, which keep tracking the memory layout of the typed port and memorize the method that we can use to interept the typed data. See the Plumber documentaiton of pstd_type_model_t for the details.
This trait is usually implemented by the macro protodef!
.
It’s rare that you have to manually implement the data model class.
See the documentaiton for protodef!
macro for details.
Required Methods§
Sourcefn init_model(&mut self, pipes: HashMap<String, PipeDescriptor>) -> bool
fn init_model(&mut self, pipes: HashMap<String, PipeDescriptor>) -> bool
Initialize the model, which assign the actual pipe to the model’s pipe.
This function is desgined to be called in the servlet’s init function and it actually does some initialization, such as requires a accessor from the lower level pstd_type_model_t object, etc.
pipes
: A map that contains the map from the pipe name to pipe descriptor
Returns if or not this model has been successfully initialized
Sourcefn new_protocol_model(type_model: TypeModelObject) -> Self
fn new_protocol_model(type_model: TypeModelObject) -> Self
Create a new protocol model, which is the high-level wrapper of the Type Model object
type_model
: The low-level type model object
Return the newly created type model object
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.