Struct Classpath

Source
pub struct Classpath { /* private fields */ }
Expand description

A classpath in java

Implementations§

Source§

impl Classpath

Source

pub fn new() -> Self

Creates an empty classpath

Source

pub fn is_empty(&self) -> bool

Checks if the given classpath is empty

Source

pub fn len(&self) -> usize

Gets the number of entries in the classpath

Source

pub fn as_os_string(&self) -> OsString

Converts this classpath into a usable classpath for java

§Example
let cp = Classpath::from_iter(["file1", "file2", "file3"]);
assert_eq!(cp.as_os_string(), OsString::from(format!("file1{0}file2{0}file3", CLASSPATH_SEPARATOR)));
Source

pub fn get<P: AsRef<str>>(&self, path: P) -> Option<Result<Resource>>

Attempts to get a resource on the classpath.

Paths will be interpreted with only / as a separator. A leading / is ignored.

§Return

Will return None is path is not on classpath. Otherwise, Some(Result) is returned where the resource exists. The result is Ok if the inner is actually readable.

§Example
let cp = Classpath::from_str("run.jar");
let resource = cp.get("META-INF/MANIFEST").expect("manifest not found");
Source§

impl Classpath

Classpath manipulation methods

Source

pub fn push_front<P: AsRef<Path>>(&mut self, path: P)

Pushes a new entry to this classpath, at the front.

Source

pub fn push_back<P: AsRef<Path>>(&mut self, path: P)

Pushes a new entry to this classpath, at the back.

Source

pub fn join(self, other: Self) -> Self

Joins two classpaths together, with the self classpath being at the front and the other classpath at the back.

Trait Implementations§

Source§

impl Add for Classpath

Source§

type Output = Classpath

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for Classpath

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Classpath

Source§

fn clone(&self) -> Classpath

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 Classpath

Source§

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

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

impl Default for Classpath

Source§

fn default() -> Classpath

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

impl Display for Classpath

Source§

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

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

impl<P: AsRef<Path>> Extend<P> for Classpath

Source§

fn extend<T: IntoIterator<Item = P>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&OsStr> for Classpath

Source§

fn from(path: &OsStr) -> Self

Tries to create a classpath where the given path is a single entry.

Source§

impl From<&Path> for Classpath

Source§

fn from(path: &Path) -> Self

Tries to create a classpath where the given path is a single entry.

Source§

impl From<&str> for Classpath

Source§

fn from(path: &str) -> Self

Tries to create a classpath where the given path is a single entry.

Source§

impl From<PathBuf> for Classpath

Source§

fn from(path: PathBuf) -> Self

Tries to create a classpath where the given path is a single entry.

Source§

impl From<Vec<PathBuf>> for Classpath

Source§

fn from(vec: Vec<PathBuf>) -> Self

Converts to this type from the input type.
Source§

impl<P> FromIterator<P> for Classpath
where P: AsRef<Path>,

Source§

fn from_iter<T: IntoIterator<Item = P>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromStr for Classpath

Source§

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

Attempts to parse a classpath, with entries seperated by the Os’s classpath separator

Source§

type Err = Infallible

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

impl Hash for Classpath

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a Classpath

Source§

type Item = &'a Path

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<&'a Path>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for Classpath

Source§

type Item = PathBuf

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<PathBuf>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Classpath

Source§

fn eq(&self, other: &Classpath) -> 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 Eq for Classpath

Source§

impl StructuralPartialEq for Classpath

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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T