Struct ConnectionGuard
pub struct ConnectionGuard<'a> { /* private fields */ }Expand description
An RAII guard for an open live websocket connection.
The connection is closed when the guard is dropped.
Methods from Deref<Target = Visu>§
pub fn config(&self) -> Config
pub fn config(&self) -> Config
Access the UI configuration write-access helper.
The returned helper builds live instructions for the scene, grid and logo
settings, e.g. visu.config().scene().grid().section_size(2.0).
pub fn add_line_basic_material(
&self,
color: [f64; 3],
options: LineBasicMaterialOptions,
) -> Result<LineBasicMaterial>
pub fn add_line_basic_material( &self, color: [f64; 3], options: LineBasicMaterialOptions, ) -> Result<LineBasicMaterial>
Adds a line basic material.
pub fn add_mesh_basic_material(
&self,
color: [f64; 3],
options: MeshBasicMaterialOptions,
) -> Result<MeshBasicMaterial>
pub fn add_mesh_basic_material( &self, color: [f64; 3], options: MeshBasicMaterialOptions, ) -> Result<MeshBasicMaterial>
Adds a mesh basic material.
pub fn add_mesh_standard_material(
&self,
color: [f64; 3],
options: MeshStandardMaterialOptions,
) -> Result<MeshStandardMaterial>
pub fn add_mesh_standard_material( &self, color: [f64; 3], options: MeshStandardMaterialOptions, ) -> Result<MeshStandardMaterial>
Adds a mesh standard material.
pub fn add_points_material(
&self,
color: [f64; 3],
options: PointsMaterialOptions,
) -> Result<PointsMaterial>
pub fn add_points_material( &self, color: [f64; 3], options: PointsMaterialOptions, ) -> Result<PointsMaterial>
Adds a points material.
pub fn add_axes(&self, options: AxesOptions) -> Result<Axes>
pub fn add_axes(&self, options: AxesOptions) -> Result<Axes>
Adds an axes helper object.
pub fn get_axes(&self, identifier: &str) -> Result<Axes>
pub fn get_axes(&self, identifier: &str) -> Result<Axes>
Gets the axes object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not an axes helper.
pub fn add_box(&self, options: BoxOptions) -> Result<Box>
pub fn add_box(&self, options: BoxOptions) -> Result<Box>
Adds a box object.
pub fn get_box(&self, identifier: &str) -> Result<Box>
pub fn get_box(&self, identifier: &str) -> Result<Box>
Gets the box object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a box.
pub fn add_camera(&self, options: CameraOptions) -> Result<Camera>
pub fn add_camera(&self, options: CameraOptions) -> Result<Camera>
Adds a camera object.
pub fn get_camera(&self, identifier: &str) -> Result<Camera>
pub fn get_camera(&self, identifier: &str) -> Result<Camera>
Gets the camera object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a camera.
pub fn add_cylinder(&self, options: CylinderOptions) -> Result<Cylinder>
pub fn add_cylinder(&self, options: CylinderOptions) -> Result<Cylinder>
Adds a cylinder object.
pub fn get_cylinder(&self, identifier: &str) -> Result<Cylinder>
pub fn get_cylinder(&self, identifier: &str) -> Result<Cylinder>
Gets the cylinder object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a cylinder.
pub fn add_line(&self, points: PointsType, options: LineOptions) -> Result<Line>
pub fn add_line(&self, points: PointsType, options: LineOptions) -> Result<Line>
Adds a line object.
If options.segments is enabled the number of points must be even.
pub fn get_line(&self, identifier: &str) -> Result<Line>
pub fn get_line(&self, identifier: &str) -> Result<Line>
Gets the line object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a line.
pub fn add_model(
&self,
source: ModelSource,
options: ModelOptions,
) -> Result<Model>
pub fn add_model( &self, source: ModelSource, options: ModelOptions, ) -> Result<Model>
Adds a model object loaded from a local path or remote URL.
Local files are cached by content hash and remote URLs by URL, so the model is only uploaded when it is not already present on the server.
Returns Error::Value if both rotation and quaternion are set.
pub fn get_model(&self, identifier: &str) -> Result<Model>
pub fn get_model(&self, identifier: &str) -> Result<Model>
Gets the model object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a model.
pub fn add_point_cloud(
&self,
data_format: PointCloudFormat,
options: PointCloudOptions,
) -> Result<PointCloud>
pub fn add_point_cloud( &self, data_format: PointCloudFormat, options: PointCloudOptions, ) -> Result<PointCloud>
Adds a point cloud object.
pub fn get_point_cloud(&self, identifier: &str) -> Result<PointCloud>
pub fn get_point_cloud(&self, identifier: &str) -> Result<PointCloud>
Gets the point cloud object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a point cloud.
pub fn add_sphere(&self, options: SphereOptions) -> Result<Sphere>
pub fn add_sphere(&self, options: SphereOptions) -> Result<Sphere>
Adds a sphere object.
pub fn get_sphere(&self, identifier: &str) -> Result<Sphere>
pub fn get_sphere(&self, identifier: &str) -> Result<Sphere>
Gets the sphere object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a sphere.
pub fn add_text_panel(
&self,
text: &str,
options: TextPanelOptions,
) -> Result<TextPanel>
pub fn add_text_panel( &self, text: &str, options: TextPanelOptions, ) -> Result<TextPanel>
Adds a text panel object.
pub fn get_text_panel(&self, identifier: &str) -> Result<TextPanel>
pub fn get_text_panel(&self, identifier: &str) -> Result<TextPanel>
Gets the text panel object for the provided identifier.
§Errors
Returns Error::ObjectTypeMismatch
if the server object is not a text panel.
pub fn get_objects(&self) -> Result<Vec<AnyObject>>
pub fn get_objects(&self) -> Result<Vec<AnyObject>>
Gets all objects in the scene as their typed write-access helpers.
pub fn get_object(&self, identifier: &str) -> Result<AnyObject>
pub fn get_object(&self, identifier: &str) -> Result<AnyObject>
Gets a single object by its identifier as its typed write-access helper.
pub fn add_hash_instruction(
&self,
anchor: &str,
instructions: Vec<Instruction>,
) -> Result<AnchorInstruction>
pub fn add_hash_instruction( &self, anchor: &str, instructions: Vec<Instruction>, ) -> Result<AnchorInstruction>
Adds a hash (anchor) instruction.
The instructions are flattened into a single ordered map and stored
under anchor.
pub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Closes the live websocket connection (no-op if not connected).
pub fn connection(&mut self) -> Result<ConnectionGuard<'_>>
pub fn connection(&mut self) -> Result<ConnectionGuard<'_>>
Opens the live connection and returns an RAII guard that closes it on drop.
The guard dereferences to Visu, so live operations such as
Visu::update can be called through it.
pub fn update(&mut self, instructions: Vec<Instruction>) -> Result<()>
pub fn update(&mut self, instructions: Vec<Instruction>) -> Result<()>
Sends live updates via the websocket connection.
Requires an open connection (see Visu::connection).