Update package declaration

This commit is contained in:
raychu86 2020-08-28 22:44:24 -07:00
parent 34fa444a06
commit ee308530f5
3 changed files with 30 additions and 15 deletions

View File

@ -23,5 +23,6 @@ pub use errors::*;
pub mod imports;
pub mod inputs;
pub mod outputs;
pub mod package;
pub mod root;
pub mod source;

27
package/src/package.rs Normal file
View File

@ -0,0 +1,27 @@
use crate::errors::PackageError;
use serde::Deserialize;
use std::path::PathBuf;
#[derive(Deserialize)]
pub struct Package {
pub name: String,
pub version: String,
pub description: Option<String>,
pub license: Option<String>,
}
impl Package {
pub fn new(package_name: &str) -> Self {
Self {
name: package_name.to_owned(),
version: "0.1.0".to_owned(),
description: None,
license: None,
}
}
pub fn remove_package(_package_name: &str) -> Result<(), PackageError> {
Ok(())
}
}

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::errors::ManifestError;
use crate::{errors::ManifestError, package::Package};
use serde::Deserialize;
use std::{
@ -31,14 +31,6 @@ pub struct Remote {
pub author: String,
}
#[derive(Deserialize)]
pub struct Package {
pub name: String,
pub version: String,
pub description: Option<String>,
pub license: Option<String>,
}
#[derive(Deserialize)]
pub struct Manifest {
pub package: Package,
@ -48,12 +40,7 @@ pub struct Manifest {
impl Manifest {
pub fn new(package_name: &str) -> Self {
Self {
package: Package {
name: package_name.to_owned(),
version: "0.1.0".to_owned(),
description: None,
license: None,
},
package: Package::new(package_name),
remote: None,
}
}