Struct Package

Source
pub struct Package {
Show 27 fields pub name: String, pub version: String, pub description: Option<String>, pub keywords: Vec<String>, pub homepage: Option<String>, pub bugs: Option<Bug>, pub license: Option<String>, pub author: Option<PersonReference>, pub contributors: Vec<PersonReference>, pub files: Vec<String>, pub main: Option<String>, pub browser: Option<String>, pub bin: BinSet, pub man: Option<ManReference>, pub repository: Option<RepositoryReference>, pub scripts: ScriptsSet, pub dependencies: DepsSet, pub dev_dependencies: DepsSet, pub peer_dependencies: DepsSet, pub bundled_dependencies: DepsSet, pub optional_dependencies: DepsSet, pub engines: EnginesSet, pub private: bool, pub os: Vec<String>, pub cpu: Vec<String>, pub config: Option<Value>, pub others: BTreeMap<String, Value>,
}
Expand description

The top-level package.json structure.

Fields§

§name: String

The package name.

§version: String

The package version.

§description: Option<String>

The optional package description.

§keywords: Vec<String>

The optional list of keywords.

§homepage: Option<String>

The optional package homepage.

§bugs: Option<Bug>

The optional bug contact form.

§license: Option<String>

The optional package license.

§author: Option<PersonReference>

The optional author.

§contributors: Vec<PersonReference>

The optional list of contributors.

§files: Vec<String>

The optional list of files to include. Each entry defines a regex pattern.

§main: Option<String>

The optional package main entry file.

§browser: Option<String>

The optional package browser entry file.

This is usually defined in libraries that are meant to be consumed by browsers. These Thoes can refer to objects that are not available inside a nodejs environment (like window).

§bin: BinSet

The optional set of binary definitions.

§man: Option<ManReference>

The optional list of man page references.

§repository: Option<RepositoryReference>

The optional repository reference.

§scripts: ScriptsSet

The optional list of script entries.

§dependencies: DepsSet

The optional list of dependencies.

§dev_dependencies: DepsSet

The optional list of development dependencies.

§peer_dependencies: DepsSet

The optional list of peer dependencies.

§bundled_dependencies: DepsSet

The optional list of bundled dependencies.

§optional_dependencies: DepsSet

The optional list of optional dependencies.

§engines: EnginesSet

The optional list of engine entries.

§private: bool

The package privacy.

§os: Vec<String>

The OS’ that the package can run on.

§cpu: Vec<String>

The CPU architectures that the package can run on.

§config: Option<Value>

The optional config object.

§others: BTreeMap<String, Value>

Other custom fields that have been defined inside the package.json file.

Implementations§

Source§

impl Package

Source

pub fn new() -> Self

Creates a new default package.

Source

pub fn from_path(path: impl AsRef<Path>) -> Result<Self>

Deserializes a Package from a file path.

Source

pub fn from_reader<R: Read>(r: R) -> Result<Self>

Deserializes a Package from an IO stream.

Source

pub fn from_slice(v: &[u8]) -> Result<Self>

Deserializes a Package from bytes.

Trait Implementations§

Source§

impl Clone for Package

Source§

fn clone(&self) -> Package

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 Debug for Package

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Package

Source§

fn default() -> Package

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Package

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromStr for Package

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Deserializes a Package from a string.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl PartialEq for Package

Source§

fn eq(&self, other: &Package) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Package

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Package

Source§

impl StructuralPartialEq for Package

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

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<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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,