pub struct LinearContext { /* private fields */ }Expand description
Context for tracking linear resources.
Implementations§
Source§impl LinearContext
impl LinearContext
Sourcepub fn enter_scope(&mut self)
pub fn enter_scope(&mut self)
Enter a new scope.
Sourcepub fn exit_scope(&mut self) -> Result<(), Vec<LinearError>>
pub fn exit_scope(&mut self) -> Result<(), Vec<LinearError>>
Exit the current scope, validating all resources.
Sourcepub fn add_resource(&mut self, resource: Resource) -> Result<(), LinearError>
pub fn add_resource(&mut self, resource: Resource) -> Result<(), LinearError>
Add a new resource to the current scope.
Sourcepub fn create_resource(
&mut self,
name: impl Into<String>,
ty: LinearType,
location: impl Into<String>,
) -> Result<(), LinearError>
pub fn create_resource( &mut self, name: impl Into<String>, ty: LinearType, location: impl Into<String>, ) -> Result<(), LinearError>
Create and add a new resource.
Sourcepub fn get_resource(&self, name: &str) -> Option<&Resource>
pub fn get_resource(&self, name: &str) -> Option<&Resource>
Get a resource by name.
Sourcepub fn get_resource_mut(&mut self, name: &str) -> Option<&mut Resource>
pub fn get_resource_mut(&mut self, name: &str) -> Option<&mut Resource>
Get a mutable reference to a resource.
Sourcepub fn use_resource(
&mut self,
name: &str,
location: impl Into<String>,
) -> Result<(), LinearError>
pub fn use_resource( &mut self, name: &str, location: impl Into<String>, ) -> Result<(), LinearError>
Use a resource.
Sourcepub fn move_resource(
&mut self,
from: &str,
to: impl Into<String>,
location: impl Into<String>,
) -> Result<(), LinearError>
pub fn move_resource( &mut self, from: &str, to: impl Into<String>, location: impl Into<String>, ) -> Result<(), LinearError>
Move a resource to a new name.
Sourcepub fn drop_resource(&mut self, name: &str) -> Result<(), LinearError>
pub fn drop_resource(&mut self, name: &str) -> Result<(), LinearError>
Drop a resource.
Sourcepub fn validate_all(&self) -> Result<(), Vec<LinearError>>
pub fn validate_all(&self) -> Result<(), Vec<LinearError>>
Validate all resources at the end.
Sourcepub fn resource_names(&self) -> Vec<&str>
pub fn resource_names(&self) -> Vec<&str>
Get all resource names.
Sourcepub fn statistics(&self) -> LinearStatistics
pub fn statistics(&self) -> LinearStatistics
Get usage statistics.
Trait Implementations§
Source§impl Clone for LinearContext
impl Clone for LinearContext
Source§fn clone(&self) -> LinearContext
fn clone(&self) -> LinearContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinearContext
impl Debug for LinearContext
Source§impl Default for LinearContext
impl Default for LinearContext
Source§fn default() -> LinearContext
fn default() -> LinearContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LinearContext
impl RefUnwindSafe for LinearContext
impl Send for LinearContext
impl Sync for LinearContext
impl Unpin for LinearContext
impl UnwindSafe for LinearContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more