pub struct Class {
pub name: String,
pub type_id: TypeId,
pub register_hooks: Vec<RegisterHook>,
/* private fields */
}Expand description
Class that can be registered with Oso.
A class represents an entity, such as an actor or a resource. It is typically backed by a Rust struct and can carry some internal state, as well as have methods that can be made accessible from within the policy file.
While the instance of the class itself is stored as a PolarValue::Instance, the Class
struct contains metadata, such as the constructor, attributes, instance methods, comparison
functions as well as the name.
Fields§
§name: StringThe class name. Defaults to std::any::type_name.
type_id: TypeIdType ID of the class.
register_hooks: Vec<RegisterHook>Hooks to be called on the class once it’s been registered with host.
Implementations§
Source§impl Class
impl Class
Sourcepub fn builder<T: 'static>() -> ClassBuilder<T>
pub fn builder<T: 'static>() -> ClassBuilder<T>
Builder instance to build class.
Use this when you want to hook your own class into Oso.
See ClassBuilder for usage examples.
Sourcepub fn init(&self, fields: Vec<PolarValue>) -> Result<Instance>
pub fn init(&self, fields: Vec<PolarValue>) -> Result<Instance>
Initialize new class instance.
Sourcepub fn call(&self, attr: &str, args: Vec<PolarValue>) -> Result<PolarValue>
pub fn call(&self, attr: &str, args: Vec<PolarValue>) -> Result<PolarValue>
Call class method attr on self with arguments from args.
Returns the result as a PolarValue.
Trait Implementations§
Source§impl PolarClass for Class
impl PolarClass for Class
Source§fn get_polar_class() -> Class
fn get_polar_class() -> Class
Class ready for registrationSource§fn get_polar_class_builder() -> ClassBuilder<Self>
fn get_polar_class_builder() -> ClassBuilder<Self>
Class for this type. Read more