Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to create File objects from existing files (#11) #12

Merged
merged 8 commits into from
Dec 31, 2021

Conversation

parafoxia
Copy link
Contributor

This PR:

  • Adds the load_from classmethod and the load_contents_from method to load contents from existing files (it also adds a private load_contents method which the two public methods share)
  • Corrects some issues in the docs
  • Adds relevant tests

Closes #11.

Copy link
Owner

@Jonxslays Jonxslays left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests would need to be adjusted a bit for this too.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@Jonxslays
Copy link
Owner

Leaving this here for reference:

type LoadResult<T> = Result<T, LoadError>;

#[derive(Debug, Clone)]
pub struct LoadError {
    message: String,
}

impl LoadError {
    fn new(message: &str) -> Self {
        Self {
            message: message.into(),
        }
    }
}

impl std::fmt::Display for LoadError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.message)
    }
}

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@parafoxia
Copy link
Contributor Author

Anything marked as resolved I've done locally, but may not have pushed yet.

@Jonxslays Jonxslays merged commit c12c73c into Jonxslays:master Dec 31, 2021
parafoxia added a commit to parafoxia/piston_rspy that referenced this pull request Apr 13, 2022
Jonxslays pushed a commit to parafoxia/piston_rspy that referenced this pull request Jun 30, 2022
Jonxslays added a commit to Jonxslays/piston_rspy that referenced this pull request Jun 30, 2022
* Add bindings for features added in Jonxslays/piston_rs#12

* Fix typo

* Add load_from and load_content_from method impls

Co-authored-by: Jonxslays <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a method to create a new File object from an actual file
2 participants