An API Wrapper for https://paste.myst.rs written in rust

Overview


PasteMyst.RS

pastemyst-rs is an api wrapper for pastemyst written in Rust.

This package is under development

Sample usage

To get a paste from pastemyst synchronously:

use pastemyst::paste;
use pastemyst::paste::PasteObject;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let paste: PasteObject = paste::get_paste("hipfqanx")?;
    println!("{}", paste.pasties[1].language);
    Ok(())
}

To create paste synchronously:

use pastemyst::paste;
use pastemyst::paste::PasteObject;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let pasties: Vec<PastyObject> = vec![
        PastyObject {
            _id: str!(""),
            language: str!(pastemyst::data::language::RUST),
            title: "A pasty title".to_string(),
            code: String::from("fn main() { println!(\"Hello World!\"); }"),
        },
        PastyObject {
            _id: str!(""),
            title: "Another pasty title".to_string(),
            language: str!(pastemyst::data::language::CLANG),
            code: String::from("#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}"),
        },
    ];
    let data: CreateObject = CreateObject {
        title: String::from("[crates.io/crates/pastemyst] This is a title"),
        expiresIn: String::from("1d"),
        isPrivate: false,
        isPublic: false,
        tags: String::from(""),
        pasties: pasties,
    };
    let paste: /*reqwest::Response*/ = paste::create_paste(data).unwrap(); // You don't need to add the commented part, that's jut for your information.
    println!("{}", paste._id);
    Ok(())
}

More from the examples and documentation.

Feature support

Feature Support Async
API v1
API v2
Get pastes
Get private pastes
Create pastes
Create Private pastes*
Edit pastes
Delete pastes
Get Users
Check if a user exists
Get a language by name
Get a language by extension
Time expires in to a unix timestamp

= Done/Implemented and fully functional

= Not done/implemented

= N/A

*This also includes a paste to be tied to your account, or create a private/public paste, or with tags.

Repository structure

This is the current structure of the code:

./
├───.github/
│   ├─.workflows/
│   │   └─ rust.yml
│   └─ISSUE_TEMPLATES/
│       ├─ bug_report.md
│       ├─ feature_request.md
│       ├─ documentation.md
│       └─ question.md
├───examples/
│   ├─ paste.rs
│   ├─ time.rs
│   ├─ data.rs
│   └─ user.rs
├───src/
│   └─ lib.rs
├─── .gitattributes 
├─── .gitignore
├─── Cargo.toml
├─── LICENSE
└─── README.MD

Building and Running

Being a Rust library, pastemyst-rs requires the Rust compiler installed. To check if it's installed, run: rustc --version and cargo --version to verify it. If it's not installed, install it from their site. Once that's cleared out; run cargo install to get the packages. To test it on-hand, either

  1. Create a main.rs with the main method and run those tests (cargo run).
  2. Run from the examples using cargo run --example example_name, for example cargo run --example get_paste.

Installation

If you want to use it in your rust application, it is recommended to get the crate from https://crates.io/crates/pastemyst. In your Cargo.toml file, under [dependencies] paste this:

pastemyst = "<Replace this text with the latest version>"
# OR
pastemyst = { version = "<Replace this text with the latest version>" }

Versioning

pastemyst-rs uses SemVer.

Given a version number MAJOR.MINOR.PATCH, increment the

MAJOR version when you make incompatible API changes,

MINOR version when you add functionality in a backwards compatible manner, and

PATCH version when you make backwards compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

Help/Assistance

You can create an issue or just join the support (discord) server.

Discuss in the server

Comments
  • [BUG] Project structure does not match README project tree

    [BUG] Project structure does not match README project tree

    Describe the bug

    The file tree in the README needs to be updated to match the project structure,

    To Reproduce

    1. Go to the readme file

    2. Scroll to file tree, which looks like this.

    3. Compare to project structure, not especially the missing files in the src node of the tree.

    Expected behavior

    The file tree in the README should match the project structure.

    Screenshots

    image

    bug documentation 
    opened by lucasstarsz 3
  • [FEATURE] Update User struct

    [FEATURE] Update User struct

    Is your feature request related to a problem? Please describe. With issue #306 closed, the api wrapper's code isn't updated.

    Describe the solution you'd like it's safe to add those two properties, so they should be added.

    enhancement 
    opened by ANF-Studios 1
  • [BUG] Prevent reqwest from panic-ing when user does not exist

    [BUG] Prevent reqwest from panic-ing when user does not exist

    Describe the bug reqwest panics in the user_get method if the user is not found and nothing is returned by the API (other than the status message)

    To Reproduce

    1. Get a user that you're sure does not exist
    2. Run the code
    3. Code panics

    Expected behavior N/A

    bug 
    opened by ANF-Studios 1
  • [BUG] Library panics when the user isn't found

    [BUG] Library panics when the user isn't found

    Describe the bug When getting a user that isn't found, it throws an exception due to missing properties.

    To Reproduce

    1. get a user that you are sure of doesn't exist.
    2. reqwest panics.

    Expected behavior It should not panic.

    Screenshots image

    Additional context A fix for this could be to not execute the GET method at all if the user does not exist or some sort of solution.

    bug good first issue 
    opened by ANF-Studios 1
  • [DOCUMENTATION] Replace Yes, No, N/A with ✔, ❌ and ⛔respectively.

    [DOCUMENTATION] Replace Yes, No, N/A with ✔, ❌ and ⛔respectively.

    What's wrong? Yes and no kind of get overwhelming.

    Proposed solution Replace those with an emoji which would improve the representation of the readme and readability as well.

    documentation enhancement 
    opened by ANF-Studios 1
  • [INVALID CODE] create_paste and create_paste_async do not have the PasteObject return type

    [INVALID CODE] create_paste and create_paste_async do not have the PasteObject return type

    pastemyst::paste::create_paste and pastemyst::paste::create_paste_async have their return type has reqwest::Response which is not what the under is looking for. They want a json response.

    Additional context To fix this, make this the return type:

    /*Code*/ -> Result<PasteObject, reqwest::Error> /*Code*/
    

    and change this:

    /*Code*/
        .body(serde_json::to_string(&contents).unwrap())
        .send().await?;
    Ok(result)
    

    to this

        .body(serde_json::to_string(&contents).unwrap())
        .send().await?;
    Ok(result.json)
    
    enhancement good first issue help wanted 
    opened by ANF-Studios 1
  • [DOCUMENTATION] Change occurrence of

    [DOCUMENTATION] Change occurrence of "This is a title"

    What's wrong? The paste title is great n' all but if/when people create pastes from examples, it'll be sent over to pastemyst and if that amount increases, there should be a way to let the authority know where these pastes are coming from.

    Proposed solution Change This is a title to [crates.io/crates/pastemyst] This is a title.

    documentation enhancement 
    opened by ANF-Studios 1
  • [DOCUMENTATION] Add a changelog to keep track of all changes.

    [DOCUMENTATION] Add a changelog to keep track of all changes.

    What's wrong? There is no changelog hence to history record.

    Proposed solution Having a changelog would solve this solution.

    Additional context Changelogs are useful which tells future maintainers and other people about changes and the difference in libraries which makes it easier to keep track of the past.

    documentation good first issue 
    opened by ANF-Studios 1
  • Rename package to `pastemyst` from `pastemyst-rs`

    Rename package to `pastemyst` from `pastemyst-rs`

    Having a shorter crate name is more beneficial and prevents importing hassles like the current one:

    use pastemyst_rs::paste::*;
    

    If it gets renamed, an equivalent would be:

    use pastemyst::paste::*;
    

    Which is a lot better.

    good first issue help wanted 
    opened by ANF-Studios 1
  • (#32) Update Project Tree Structure and fixed features failing issue

    (#32) Update Project Tree Structure and fixed features failing issue

    Changes

    • Added missing files to the main README's project file tree - fixes #32
    • Added feature specification into cargo.toml, fixing build issues where features such as paste were not found.
    opened by lucasstarsz 0
  • [DOCUMENTATION] Too many files in the example folder

    [DOCUMENTATION] Too many files in the example folder

    What's wrong? The example folder is just growing with every method added and can expand to be a pain.

    Proposed solution Store each function according to its task eg, getting pastes (sync), getting pastes (async), getting private pastes (sync) and getting private pastes (async) should be in one file.

    Alternative: Separate it per mod (namespace).

    documentation 
    opened by ANF-Studios 0
  • [FEATURE] Add testing

    [FEATURE] Add testing

    Is your feature request related to a problem? Please describe.

    With situations like pull request #33, it is imperative that tests are run to ensure that the project works as expected.

    Describe the solution you'd like

    Add tests covering at least the most used features.

    Describe alternatives you've considered

    There are not many alternatives to consider -- testing a library is objectively the most effective way to ensure any part of it works as intended.

    enhancement 
    opened by lucasstarsz 0
  • [FEATURE] We should return the object itself and not as a Result<...>

    [FEATURE] We should return the object itself and not as a Result<...>

    Is your feature request related to a problem? Please describe. As of now, returns are like so: Result<type, reqwest::Error> which just makes the user unwrap the method which can be a pain.

    Describe the solution you'd like Change the return type to type so it's easier.

    enhancement question 
    opened by ANF-Studios 1
Releases(1.0.0)
  • 1.0.0(Feb 18, 2021)

  • 0.8.0(Feb 9, 2021)

  • 0.7.75(Jan 24, 2021)

    v0.7.75

    • Ability to create private pastes.
    • Ability to create private pastes async.
    • Fixed create_paste and create_paste_async's return type.
    • Improved documentation.
    • Fixed some incorrect sentences and spellings in docs.
    • Added missing docs.
    • Fixed incorrect examples in docs.
    • Ability to edit pastes. (not fully done)
    • Renamed some modules.
    • Ability to delete pastes.
    • Added list of constants that have pastemyst's supported languages.
    • Ability to check if user exists
    • Ability to get users
    Source code(tar.gz)
    Source code(zip)
  • 0.2.25(Jan 14, 2021)

    Welcome to the second release of PasteMyst-RS.

    • Ability to create pastes.
    • Ability to create pastes async.
    • Minor bug fixes and value changes.
    • Improvements and major additions to the documentation.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Jan 12, 2021)

Owner
ANF Studios
An open source organization that focuses on creating new products.
ANF Studios
Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async

CDRS CDRS is looking for maintainers CDRS is Apache Cassandra driver written in pure Rust. ?? Looking for an async version? async-std https://github.c

Alex Pikalov 338 Jan 1, 2023
Postgres Foreign Data Wrapper for Clerk.com API

Pre-requisites Postgres-15 Rust pgrx Getting Started To run the program locally, clone the repository git clone https://github.com/tembo-io/clerk_fdw.

Tembo 3 Aug 22, 2023
https://crates.io/crates/transistor

Transistor A Rust Crux Client crate/lib. For now, this crate intends to support 2 ways to interact with Crux: Via Docker with a crux-standalone versio

Julia Naomi 28 May 28, 2022
rust wrapper for rocksdb

rust-rocksdb Requirements Clang and LLVM Contributing Feedback and pull requests welcome! If a particular feature of RocksDB is important to you, plea

null 1.3k Dec 30, 2022
UnQLite wrapper 1.0 is avaliable for Rust

unqlite A high-level UnQLite database engine wrapper. NOTE: Some of the documents is stolen from UnQLite Official Website. What is UnQLite? UnQLite is

Huo Linhe 101 Dec 12, 2022
duckdb-rs is an ergonomic wrapper for using duckdb from Rust.

duckdb-rs duckdb-rs is an ergonomic wrapper for using duckdb from Rust. It attempts to expose an interface similar to rusqlite. Acctually the initial

Wang Fenjin 126 Dec 30, 2022
ODBC wrapper for safe idiomatic Rust

ODBC wrapper for safe idiomatic Rust Library for writing ODBC applications in Rust. If you're looking for raw ODBC FFI bindings check odbc-safe and od

Konstantin V. Salikhov 91 Dec 10, 2022
Rusqlite is an ergonomic wrapper for using SQLite from Rust

Rusqlite Rusqlite is an ergonomic wrapper for using SQLite from Rust. It attempts to expose an interface similar to rust-postgres. use rusqlite::{para

Rusqlite 1.9k Jan 7, 2023
Thin wrapper around [`tokio::process`] to make it streamable

process-stream Wraps tokio::process::Command to future::stream. Install process-stream = "0.2.2" Example usage: From Vec<String> or Vec<&str> use proc

null 4 Jun 25, 2022
A Rust client for the ElasticSearch REST API

rs-es Introduction An ElasticSearch client for Rust via the REST API. Targetting ElasticSearch 2.0 and higher. Other clients For later versions of Ela

Ben Ashford 218 Dec 27, 2022
An Elasticsearch REST API client for Rust

elastic elastic is an efficient, modular API client for Elasticsearch written in Rust. The API is targeting the Elastic Stack 7.x. elastic provides st

null 249 Oct 18, 2022
Telegram bot API client for Rust

Frankenstein Telegram bot API client for Rust. It's a complete wrapper for Telegram bot API and it's up to date with version 5.2 of the API. Frankenst

Ayrat Badykov 136 Jan 1, 2023
A Rust SQL query builder with a pleasant fluent API closely imitating actual SQL

Scooby An SQL query builder with a pleasant fluent API closely imitating actual SQL. Meant to comfortably build dynamic queries with a little bit of s

Aleksei Voronov 100 Nov 11, 2022
Rust crate for linking against the RDKit C++ API

RDKit-Sys Rust code that binds to the C++ rdkit library! How does it work? RDKit is a C++ mega-library, full of cheminformatics wisdom. We don't want

null 14 Dec 29, 2022
Rust API to manage user accounts 🦦

Autha Autha, pronounced Otter ?? , is the service that manages user accounts and the associated delegation. ☄️ Autha is an OAuth2 server designed with

Gravitalia 14 Dec 22, 2022
A Rust-based comment server using SQLite and an intuitive REST API.

soudan A Rust-based comment server using SQLite and an intuitive REST API. Soudan is built with simplicity and static sites in mind. CLI usage See sou

Elnu 0 Dec 19, 2022
Rust - Build a CRUD API with SQLX and PostgreSQL

In this article, you'll learn how to build a CRUD API in Rust using SQLX, Actix-web, and PostgreSQL. Learning how to build a CRUD API as a developer will equip you with valuable skills for building robust, maintainable, and scalable applications.

CODEVO 5 Feb 20, 2023
High performance and distributed KV store w/ REST API. 🦀

About Lucid KV High performance and distributed KV store w/ REST API. ?? Introduction Lucid is an high performance, secure and distributed key-value s

Lucid ᵏᵛ 306 Dec 28, 2022
An async executor based on the Win32 thread pool API

wae An async executor based on the Win32 thread pool API use futures::channel::oneshot; #[wae::main] async fn main() { let (tx, rx) = oneshot::ch

Raphaël Thériault 10 Dec 10, 2021