Struct wasmer_pack::PackageName
source · pub struct PackageName { /* private fields */ }
Expand description
The name of a package from WAPM (e.g. wasmer/wasmer-pack
).
Syntax:
- A
PackageName
consists of a “name” and an optional “namespace or username” - The “namespace or username” may be an “identifier” or the “_” namespace (used for backwards compatibility)
- If a “namespace or username” isn’t provided, it is assumed to be a package alias and will be resolved to a package by the WAPM backend
- “Identifiers” can only contain alphanumeric ascii characters,
_
, and-
- “Identifiers” must also start with an ascii character and be at most 100 characters long
Implementations§
source§impl PackageName
impl PackageName
pub fn parse(raw: &str) -> Result<Self, Error>
pub fn name(&self) -> &str
pub fn set_name(&mut self, name: impl Into<String>)
pub fn namespace(&self) -> &Namespace
sourcepub fn javascript_package(&self) -> String
pub fn javascript_package(&self) -> String
Get the NPM equivalent of this PackageName
.
This should satisfy NPM’s naming rules:
- package name length should be greater than zero
- all the characters in the package name must be lowercase i.e., no uppercase or mixed case names are allowed
- package name can consist of hyphens
- package name must not contain any non-url-safe characters (since name ends up being part of a URL)
- package name should not start with . or _
- package name should not contain any spaces
- package name should not contain any of the following characters: ~)(’!*
- package name cannot be the same as a node.js/io.js core module nor a reserved/blacklisted name. For example, the following names are invalid:
- http
- stream
- node_modules
- favicon.ico
- package name length cannot exceed 214
sourcepub fn python_name(&self) -> String
pub fn python_name(&self) -> String
Get the PyPI equivalent of this PackageName
.
This should satisfy the naming scheme outlined in PEP 8:
Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.
Trait Implementations§
source§impl Clone for PackageName
impl Clone for PackageName
source§fn clone(&self) -> PackageName
fn clone(&self) -> PackageName
Returns a copy 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 PackageName
impl Debug for PackageName
source§impl Display for PackageName
impl Display for PackageName
source§impl FromStr for PackageName
impl FromStr for PackageName
source§impl PartialEq<PackageName> for PackageName
impl PartialEq<PackageName> for PackageName
source§fn eq(&self, other: &PackageName) -> bool
fn eq(&self, other: &PackageName) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for PackageName
impl StructuralEq for PackageName
impl StructuralPartialEq for PackageName
Auto Trait Implementations§
impl RefUnwindSafe for PackageName
impl Send for PackageName
impl Sync for PackageName
impl Unpin for PackageName
impl UnwindSafe for PackageName
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.