#[repr(C)]
pub struct Project { /* private fields */ }

Implementations§

source§

impl Project

source

pub fn all_open() -> Array<Project>

source

pub fn create<P: BnStrCompatible, S: BnStrCompatible>(path: P, name: S) -> Self

Create a new project

  • path - Path to the project directory (.bnpr)
  • name - Name of the new project
source

pub fn open_project<P: BnStrCompatible>(path: P) -> Self

Open an existing project

  • path - Path to the project directory (.bnpr) or project metadata file (.bnpm)
source

pub fn is_open(&self) -> bool

Check if the project is currently open

source

pub fn open(&self) -> Result<(), ()>

Open a closed project

source

pub fn close(&self) -> Result<(), ()>

Close a open project

source

pub fn id(&self) -> BnString

Get the unique id of this project

source

pub fn path(&self) -> BnString

Get the path of the project

source

pub fn name(&self) -> BnString

Get the name of the project

source

pub fn set_name<S: BnStrCompatible>(&self, value: S)

Set the name of the project

source

pub fn description(&self) -> BnString

Get the description of the project

source

pub fn set_description<S: BnStrCompatible>(&self, value: S)

Set the description of the project

source

pub fn query_metadata<S: BnStrCompatible>(&self, key: S) -> Ref<Metadata>

Retrieves metadata stored under a key from the project

source

pub fn store_metadata<S: BnStrCompatible>( &self, key: S, value: &Metadata ) -> bool

Stores metadata within the project,

  • key - Key under which to store the Metadata object
  • value - Object to store
source

pub fn remove_metadata<S: BnStrCompatible>(&self, key: S)

Removes the metadata associated with this key from the project

source

pub fn push_folder(&self, file: &ProjectFolder)

source

pub fn create_folder_from_path<P, D>( &self, path: P, parent: Option<&ProjectFolder>, description: D ) -> Result<ProjectFolder, ()>

Recursively create files and folders in the project from a path on disk

  • path - Path to folder on disk
  • parent - Parent folder in the project that will contain the new contents
  • description - Description for created root folder
source

pub fn create_folder_from_path_with_progress<P, D, F>( &self, path: P, parent: Option<&ProjectFolder>, description: D, progress_func: F ) -> Result<ProjectFolder, ()>

Recursively create files and folders in the project from a path on disk

  • path - Path to folder on disk
  • parent - Parent folder in the project that will contain the new contents
  • description - Description for created root folder
  • progress_func - Progress function that will be called
source

pub fn create_folder<N, D>( &self, parent: Option<&ProjectFolder>, name: N, description: D ) -> Result<ProjectFolder, ()>

Recursively create files and folders in the project from a path on disk

  • parent - Parent folder in the project that will contain the new folder
  • name - Name for the created folder
  • description - Description for created folder
source

pub unsafe fn create_folder_unsafe<N, D, I>( &self, parent: Option<&ProjectFolder>, name: N, description: D, id: I ) -> Result<ProjectFolder, ()>

Recursively create files and folders in the project from a path on disk

  • parent - Parent folder in the project that will contain the new folder
  • name - Name for the created folder
  • description - Description for created folder
  • id - id unique ID
source

pub fn folders(&self) -> Result<Array<ProjectFolder>, ()>

Get a list of folders in the project

source

pub fn folder_by_id<S: BnStrCompatible>(&self, id: S) -> Option<ProjectFolder>

Retrieve a folder in the project by unique folder id

source

pub fn delete_folder(&self, folder: &ProjectFolder) -> Result<(), ()>

Recursively delete a folder from the project

  • folder - Folder to delete recursively
source

pub fn delete_folder_with_progress<F>( &self, folder: &ProjectFolder, progress_func: F ) -> Result<(), ()>
where F: FnMut(usize, usize) -> bool,

Recursively delete a folder from the project

  • folder - Folder to delete recursively
  • progress_func - Progress function that will be called as objects get deleted
source

pub fn push_file(&self, file: &ProjectFile)

source

pub fn create_file_from_path<P, N, D>( &self, path: P, folder: Option<&ProjectFolder>, name: N, description: D ) -> Result<ProjectFile, ()>

Create a file in the project from a path on disk

  • path - Path on disk
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
source

pub fn create_file_from_path_with_progress<P, N, D, F>( &self, path: P, folder: Option<&ProjectFolder>, name: N, description: D, progress_func: F ) -> Result<ProjectFile, ()>

Create a file in the project from a path on disk

  • path - Path on disk
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
  • progress_func - Progress function that will be called as the file is being added
source

pub unsafe fn create_file_from_path_unsafe<P, N, D, I>( &self, path: P, folder: Option<&ProjectFolder>, name: N, description: D, id: I, creation_time: SystemTime ) -> Result<ProjectFile, ()>

Create a file in the project from a path on disk

  • path - Path on disk
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
  • id - id unique ID
  • creation_time - Creation time of the file
source

pub unsafe fn create_file_from_path_with_progress_unsafe<P, N, D, I, F>( &self, path: P, folder: Option<&ProjectFolder>, name: N, description: D, id: I, creation_time: SystemTime, progress_func: F ) -> Result<ProjectFile, ()>

Create a file in the project from a path on disk

  • path - Path on disk
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
  • id - id unique ID
  • creation_time - Creation time of the file
  • progress_func - Progress function that will be called as the file is being added
source

pub fn create_file<N, D>( &self, contents: &[u8], folder: Option<&ProjectFolder>, name: N, description: D ) -> Result<ProjectFile, ()>

Create a file in the project

  • contents - Bytes of the file that will be created
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
source

pub fn create_file_with_progress<N, D, F>( &self, contents: &[u8], folder: Option<&ProjectFolder>, name: N, description: D, progress_func: F ) -> Result<ProjectFile, ()>

Create a file in the project

  • contents - Bytes of the file that will be created
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
  • progress_func - Progress function that will be called as the file is being added
source

pub unsafe fn create_file_unsafe<N, D, I>( &self, contents: &[u8], folder: Option<&ProjectFolder>, name: N, description: D, id: I, creation_time: SystemTime ) -> Result<ProjectFile, ()>

Create a file in the project

  • contents - Bytes of the file that will be created
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
  • id - id unique ID
  • creation_time - Creation time of the file
source

pub unsafe fn create_file_with_progress_unsafe<N, D, I, F>( &self, contents: &[u8], folder: Option<&ProjectFolder>, name: N, description: D, id: I, creation_time: SystemTime, progress_func: F ) -> Result<ProjectFile, ()>

Create a file in the project

  • contents - Bytes of the file that will be created
  • folder - Folder to place the created file in
  • name - Name to assign to the created file
  • description - Description to assign to the created file
  • id - id unique ID
  • creation_time - Creation time of the file
  • progress_func - Progress function that will be called as the file is being added
source

pub fn files(&self) -> Result<Array<ProjectFile>, ()>

Get a list of files in the project

source

pub fn file_by_id<S: BnStrCompatible>(&self, id: S) -> Option<ProjectFile>

Retrieve a file in the project by unique id

source

pub fn file_by_path<S: BnStrCompatible>(&self, path: S) -> Option<ProjectFile>

Retrieve a file in the project by the path on disk

source

pub fn delete_file(&self, file: &ProjectFile) -> bool

Delete a file from the project

source

pub fn bulk_operation(&mut self) -> Result<ProjectBulkOperationLock<'_>, ()>

A context manager to speed up bulk project operations. Project modifications are synced to disk in chunks, and the project on disk vs in memory may not agree on state if an exception occurs while a bulk operation is happening.

if let Ok(bulk) = project.bulk_operation() {
    for file in std::fs::read_dir("/bin/").unwrap().into_iter() {
        let file = file.unwrap();
        let file_type = file.file_type().unwrap();
        if file_type.is_file() && !file_type.is_symlink() {
            bulk.create_file_from_path(
                "/bin/",
                None,
                &file.file_name().to_string_lossy(),
                "",
            ).unwrap();
        }
    }
}

Trait Implementations§

source§

impl Clone for Project

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CoreArrayProvider for Project

§

type Raw = *mut BNProject

§

type Context = ()

§

type Wrapped<'a> = &'a Project

source§

impl Drop for Project

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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<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> 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<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.