Crate parse_rs

Source
Expand description

§Parse SDK for Rust (parse-rs)

A modern, asynchronous, and unofficial Rust SDK for interacting with Parse Server backends. This crate provides a type-safe and ergonomic way to perform operations such as user authentication, object management (CRUD), querying, file handling, and executing Cloud Code functions.

§Overview

parse-rs is built with async/await for non-blocking operations and leverages popular Rust libraries like reqwest for HTTP communication and serde for JSON serialization/deserialization.

For detailed setup, prerequisites, and advanced usage, please refer to the README.md file in the repository.

§Quick Start Example

use parse_rs::{Parse, ParseError, ParseObject, object::CreateObjectResponse};
use serde_json::Value;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<(), ParseError> {
    // Initialize the Parse client.
    // Ensure PARSE_SERVER_URL, PARSE_APP_ID, and PARSE_MASTER_KEY (or other keys)
    // are set in your environment or provide them directly.
    let server_url = std::env::var("PARSE_SERVER_URL").unwrap_or_else(|_| "http://localhost:1338/parse".to_string());
    let app_id = std::env::var("PARSE_APP_ID").unwrap_or_else(|_| "myAppId".to_string());
    let master_key = std::env::var("PARSE_MASTER_KEY").unwrap_or_else(|_| "myMasterKey".to_string());

    let mut client = Parse::new(
        &server_url,
        &app_id,
        None, // javascript_key
        None, // rest_api_key
        Some(&master_key),
    )?;

    // Create a new ParseObject
    let mut game_score_data = HashMap::new();
    game_score_data.insert("score".to_string(), Value::Number(1337.into()));
    game_score_data.insert("playerName".to_string(), Value::String("Sean Plott".to_string()));

    let mut new_score = ParseObject::new("GameScore");
    let created_object: CreateObjectResponse = client.create_object("GameScore", &new_score).await?;

    println!("Successfully created GameScore with objectId: {}", created_object.object_id);
    Ok(())
}

For more examples and detailed API documentation, please explore the individual modules.

Re-exports§

pub use acl::ParseACL;
pub use client::Parse;
pub use cloud::ParseCloud;
pub use config::ParseConfig;
pub use error::ParseError;
pub use file::FileField;
pub use file::ParseFile;
pub use object::ParseObject;
pub use object::RetrievedParseObject;
pub use query::ParseQuery;
pub use role::NewParseRole;
pub use role::ParseRole;
pub use schema::ClassLevelPermissionsSchema;
pub use schema::FieldSchema;
pub use schema::FieldType;
pub use schema::GetAllSchemasResponse;
pub use schema::ParseSchema;
pub use session::ParseSession;
pub use types::Endpoint;
pub use types::ParseDate;
pub use types::ParseRelation;
pub use types::Pointer;
pub use types::QueryParams;
pub use types::RelationOp;
pub use types::Results;
pub use types::UpdateResponseData;
pub use user::LoginRequest;
pub use user::ParseUser;
pub use user::PasswordResetRequest;
pub use user::SignupRequest;
pub use user::SignupResponse;

Modules§

acl
analytics
client
cloud
config
error
file
geopoint
installation
object
query
relations
requests
role
schema
Module for defining Parse Server class schemas and their fields.
session
types
user