Struct renga_api_rs::Project

source ·
pub struct Project { /* private fields */ }
Expand description

Represents active Renga project.

Provides methods to work with a Renga project. Can be obtained using crate::Application::project method.

By default, project is immutable. To achieve mutability, you must follow this steps:

For example:

use renga_api_rs as renga;
let mut app = renga::Application::new().unwrap();
let mut project = app.new_project().unwrap();
let mut transaction = project.start_transaction().unwrap();
 
// do something with the project
transaction.commit().unwrap();

You can safely clone this struct and use it in multiple threads.

See Official documentation

Implementations§

source§

impl Project

source

pub fn new(parent_handle: Dispatch, handle: Dispatch) -> Result<Self>

Creates new instance of Project from native handles.

To get an instance of this structure without using native handles, use the crate::Application::new_project or crate::Application::project methods.

source

pub fn path(&self) -> Result<Option<PathBuf>>

Returns path to project save file or None if project was never saved.

See Project::save

source

pub fn save(&self) -> Result<PathBuf>

Saves project and returns path to saved file.

source

pub fn has_unsaved_changes(&self) -> Result<bool>

Returns `true`` if project has unsaved changes.

source

pub fn close(&mut self, discard_changes: bool) -> Result<()>

Closes project.

If project has unsaved changes, you can discard them using discard_changes parameter.

source

pub fn start_transaction(&mut self) -> Result<ProjectTransaction>

Creates new transaction.

See ProjectTransaction for more information.

source

pub fn has_transaction(&self) -> Result<bool>

Returns true if project has an active transaction.

source

pub fn category(&self, category: Category) -> Result<EntityCollection>

Returns collection of entities of given category.

You can use this method to access entities inside categories. For example, to get style template with name matching string Pump:

use renga_api_rs as renga;
use anyhow::Result;
 
fn style_template() -> Result<renga::Entity> {
  let mut app = renga::Application::new()?;
  let mut project = app.new_project()?;
  let pump_style_template = project
    .category(renga::Category::Equipment)?
    .into_vec()?
    .into_iter()
    .find(|entity| entity.name == "Pump")
    .unwrap();
  Ok(pump_style_template)
}
 
let pump_style_template = style_template().unwrap();
assert_eq!(
  pump_style_template.name, 
  "Pump"
);
source

pub fn import_category( &mut self, category: Category, path: &Path, ) -> Result<Entity>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

source§

type Err = NoError

The error type produced by a failed conversion.
source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, Dst> ConvAsUtil<Dst> for T

source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
source§

impl<T> ConvUtil for T

source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<Src> TryFrom<Src> for Src

source§

type Err = NoError

The error type produced by a failed conversion.
source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<Src> ValueFrom<Src> for Src

source§

type Err = NoError

The error type produced by a failed conversion.
source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.