pub struct Parse {
pub server_url: String,
/* private fields */
}
Expand description
The main client for interacting with a Parse Server instance.
Parse
handles the configuration of server connection details (URL, Application ID, API keys)
and provides methods for making authenticated or unauthenticated requests to various Parse Server endpoints.
It manages session tokens for authenticated users and uses an underlying reqwest::Client
for HTTP communication.
Most operations are performed by calling methods directly on Parse
or by obtaining specialized
handles (like ParseUserHandle
, ParseSessionHandle
, ParseCloud
) through methods on this client.
§Initialization
A Parse
is typically created using the Parse::new()
method, providing the server URL,
Application ID, and any relevant API keys (JavaScript, REST, Master).
use parse_rs::Parse;
let server_url = "http://localhost:1338/parse";
let app_id = "myAppId";
let master_key = "myMasterKey";
// Create a client instance with Master Key
let mut client = Parse::new(
server_url,
app_id,
None, // javascript_key
None, // rest_api_key
Some(master_key), // master_key
)?;
// Client is now ready to be used
Fields§
§server_url: String
Implementations§
Source§impl Parse
impl Parse
Sourcepub async fn track_event(
&self,
event_name: &str,
dimensions: Option<Value>,
) -> Result<(), ParseError>
pub async fn track_event( &self, event_name: &str, dimensions: Option<Value>, ) -> Result<(), ParseError>
Tracks a custom event with optional dimensions.
§Arguments
event_name
: The name of the event to track (e.g., “ButtonClicked”, “ItemPurchased”).dimensions
: Optional key-value pairs to associate with the event.
§Returns
A Result
indicating success or a ParseError
.
This operation typically requires the Master Key, JavaScript Key, or REST API Key.
Source§impl Parse
impl Parse
Sourcepub fn new(
server_url: &str,
app_id: &str,
javascript_key: Option<&str>,
rest_api_key: Option<&str>,
master_key: Option<&str>,
) -> Result<Self, ParseError>
pub fn new( server_url: &str, app_id: &str, javascript_key: Option<&str>, rest_api_key: Option<&str>, master_key: Option<&str>, ) -> Result<Self, ParseError>
Creates a new Parse
instance.
This constructor initializes the client with the necessary credentials and configuration to communicate with your Parse Server.
§Arguments
server_url
: The base URL of your Parse Server (e.g.,"http://localhost:1338/parse"
). The client will attempt to normalize this URL (e.g., ensure scheme, remove trailing/parse
if present to derive the true server base for constructing endpoint paths).app_id
: Your Parse Application ID. This is a required header for all requests.javascript_key
: Optional. Your Parse JavaScript Key. If provided andmaster_key
is not, this key will be included in requests by default, unless overridden by a session token or explicit master key usage.rest_api_key
: Optional. Your Parse REST API Key. If provided and bothmaster_key
andjavascript_key
are not, this key will be included in requests by default. It’s generally preferred over the JavaScript Key for server-to-server communication.master_key
: Optional. Your Parse Master Key. If provided, this key will be included in requests by default, granting unrestricted access. Use with caution. It supersedes other keys for default authentication if present.
§Returns
A Result
containing the new Parse
instance if successful, or a ParseError
if
configuration is invalid (e.g., invalid URL, invalid header values).
§Key Precedence for Default Headers
When the client makes requests, the authentication key used in the default headers (when no session token is active
and use_master_key
is not explicitly set for an operation) follows this precedence:
- Master Key (if provided at initialization)
- JavaScript Key (if provided and Master Key is not)
- REST API Key (if provided and neither Master Key nor JavaScript Key are)
A session token, once set (e.g., after login), will typically take precedence over these default keys for most operations.
§Example
use parse_rs::Parse;
let server_url = "http://localhost:1338/parse";
let app_id = "myAppId";
let js_key = "myJavascriptKey";
// Initialize with JavaScript Key
let mut client_with_js_key = Parse::new(
server_url,
app_id,
Some(js_key),
None, // rest_api_key
None, // master_key
)?;
// Initialize with Master Key (will take precedence for default auth)
let master_key = "myMasterKey";
let mut client_with_master_key = Parse::new(
server_url,
app_id,
Some(js_key), // JS key is also provided
None, // REST API key
Some(master_key), // Master key will be used by default
)?;
Sourcepub fn session_token(&self) -> Option<&str>
pub fn session_token(&self) -> Option<&str>
Returns the current session token, if one is set on the client.
A session token is typically obtained after a user successfully logs in and is used to authenticate subsequent requests for that user.
§Examples
// After a user logs in, the client might have a session token.
if let Some(token) = client.session_token() {
println!("Current session token: {}", token);
} else {
println!("No active session token.");
}
Sourcepub fn query_installations(&self) -> ParseQuery
pub fn query_installations(&self) -> ParseQuery
Creates a query for Installation objects.
§Returns
A ParseQuery
instance, configured for the “_Installation” class.
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Checks if the client currently has an active session token.
This is a convenience method equivalent to client.session_token().is_some()
.
§Examples
if client.is_authenticated() {
println!("Client has an active session.");
} else {
println!("Client does not have an active session.");
}
Sourcepub async fn upload_file(
&self,
file_name: &str,
data: Vec<u8>,
mime_type: &str,
) -> Result<FileField, ParseError>
pub async fn upload_file( &self, file_name: &str, data: Vec<u8>, mime_type: &str, ) -> Result<FileField, ParseError>
Uploads a file to the Parse Server.
This method sends the raw byte data of a file to the Parse Server, which then stores it
and returns a FileField
containing the URL and name of the stored file. This FileField
can then be associated with a ParseObject
.
Note: File uploads require the Master Key to be configured on the Parse
or for the
use_master_key
parameter in the underlying _request_file_upload
to be true (which is the default for this public method).
§Arguments
file_name
: A string slice representing the desired name for the file on the server (e.g.,"photo.jpg"
).data
: AVec<u8>
containing the raw byte data of the file.mime_type
: A string slice representing the MIME type of the file (e.g.,"image/jpeg"
,"application/pdf"
).
§Returns
A Result
containing a FileField
on success, which includes the name
and url
of the uploaded file.
Returns a ParseError
if the upload fails due to network issues, server errors, incorrect permissions,
or misconfiguration.
§Examples
use parse_rs::{Parse, ParseError, FileField, ParseObject, object::CreateObjectResponse};
use serde_json::Value;
use std::collections::HashMap;
let file_name = "profile.png";
let file_data: Vec<u8> = vec![0, 1, 2, 3, 4, 5]; // Example byte data
let mime_type = "image/png";
// Upload the file
let file_field: FileField = client.upload_file(file_name, file_data, mime_type).await?;
println!("File uploaded successfully: Name - {}, URL - {}", file_field.name, file_field.url);
// Now, you can associate this FileField with a ParseObject
let mut player_profile_data = HashMap::new();
player_profile_data.insert("playerName".to_string(), Value::String("John Doe".to_string()));
player_profile_data.insert("profilePicture".to_string(), serde_json::to_value(file_field)?);
let mut player_profile = ParseObject::new("PlayerProfile");
let created_profile: CreateObjectResponse = client.create_object("PlayerProfile", &player_profile).await?;
println!("Created PlayerProfile with ID: {}", created_profile.object_id);
Sourcepub async fn execute_aggregate<T: DeserializeOwned + Send + 'static>(
&self,
class_name: &str,
pipeline: Value,
) -> Result<Vec<T>, ParseError>
pub async fn execute_aggregate<T: DeserializeOwned + Send + 'static>( &self, class_name: &str, pipeline: Value, ) -> Result<Vec<T>, ParseError>
Executes an aggregation pipeline against a specified class and returns the results.
Aggregation queries allow for complex data processing and computation directly on the server.
The pipeline is defined as a serde_json::Value
, typically an array of stages (e.g., $match
, $group
, $sort
).
This method requires the Master Key to be configured on the Parse
and is used for the request.
Refer to the Parse Server aggregation documentation and MongoDB aggregation pipeline documentation for details on constructing pipelines.
§Type Parameters
T
: The type that each element of the result set is expected to deserialize into. This type must implementDeserializeOwned
.
§Arguments
class_name
: The name of the class to perform the aggregation on (e.g.,"GameScore"
).pipeline
: Aserde_json::Value
representing the aggregation pipeline. This is usually a JSON array.
§Returns
A Result
containing a Vec<T>
where T
is the deserialized type of the aggregation results.
Returns a ParseError
if the aggregation fails, the pipeline is invalid, or the Master Key is not available.
§Examples
use parse_rs::{Parse, ParseError};
use serde::Deserialize;
use serde_json::json; // for constructing the pipeline value
#[derive(Deserialize, Debug)]
struct PlayerStats {
// Note: Parse Server might return grouped _id as "objectId"
#[serde(rename = "objectId")]
player_name: String,
total_score: i64,
average_score: f64,
}
let client = Parse::new(&server_url, &app_id, None, None, Some(&master_key))?;
let class_name = "GameScore";
let pipeline = json!([
{ "$match": { "playerName": { "$exists": true } } },
{ "$group": {
"_id": "$playerName",
"totalScore": { "$sum": "$score" },
"averageScore": { "$avg": "$score" }
}},
{ "$sort": { "totalScore": -1 } },
{ "$project": {
"_id": 0, // Exclude the default _id field from MongoDB if not needed
"playerName": "$_id", // Rename _id to playerName
"total_score": "$totalScore",
"average_score": "$averageScore"
}}
]);
let results: Vec<PlayerStats> = client.execute_aggregate(class_name, pipeline).await?;
for stats in results {
println!("Player: {}, Total Score: {}, Avg Score: {:.2}",
stats.player_name, stats.total_score, stats.average_score);
}
Sourcepub async fn delete_object_with_master_key(
&self,
endpoint: &str,
) -> Result<Value, ParseError>
pub async fn delete_object_with_master_key( &self, endpoint: &str, ) -> Result<Value, ParseError>
Deletes an object from a class using the Master Key.
This method provides a direct way to delete any object by its class name and object ID,
bypassing ACLs and Class-Level Permissions due to the use of the Master Key.
The Master Key must be configured on the Parse
for this operation to succeed.
For more general object deletion that respects ACLs and uses the current session’s
authentication, use the delete
method on a ParseObject
instance retrieved via the client,
or the delete
method available on the ParseUserHandle
for users.
§Arguments
endpoint
: A string slice representing the relative path to the object, typically in the format"classes/ClassName/objectId"
(e.g.,"classes/GameScore/xWMyZ4YEGZ"
).
§Returns
A Result
containing a serde_json::Value
(which is usually an empty JSON object {}
upon successful deletion by the Parse Server) or a ParseError
if the deletion fails
(e.g., object not found, Master Key not configured, network issue).
§Examples
use parse_rs::{Parse, ParseError};
use serde_json::Value;
let class_name = "OldGameData";
let object_id_to_delete = "someObjectId123";
let endpoint_to_delete = format!("classes/{}/{}", class_name, object_id_to_delete);
// Ensure client is configured with Master Key for this to work
match client.delete_object_with_master_key(&endpoint_to_delete).await {
Ok(_) => println!("Successfully deleted object {} from class {}.", object_id_to_delete, class_name),
Err(e) => eprintln!("Failed to delete object: {}", e),
}
Sourcepub async fn delete_user(&self, object_id: &str) -> Result<(), ParseError>
pub async fn delete_user(&self, object_id: &str) -> Result<(), ParseError>
Deletes a specific User by their objectId.
This operation requires the Master Key to be configured on the client and will use it.
§Arguments
object_id
: The objectId of the user to delete.
§Returns
A Result
indicating success (Ok(())
) or a ParseError
.
Note: The Parse Server typically returns an empty JSON object {}
on successful deletion.
This method maps a successful response (any Ok(Value)
) to Ok(())
.
Sourcepub async fn execute_query<T: DeserializeOwned + Send + Sync + 'static>(
&self,
query: &ParseQuery,
) -> Result<Vec<T>, ParseError>
pub async fn execute_query<T: DeserializeOwned + Send + Sync + 'static>( &self, query: &ParseQuery, ) -> Result<Vec<T>, ParseError>
Sourcepub async fn find_objects(
&self,
query: &ParseQuery,
) -> Result<Vec<ParseObject>, ParseError>
pub async fn find_objects( &self, query: &ParseQuery, ) -> Result<Vec<ParseObject>, ParseError>
Sourcepub async fn create_class_schema<T: Serialize + Send + Sync>(
&self,
class_name: &str,
schema_payload: &T,
) -> Result<ParseSchema, ParseError>
pub async fn create_class_schema<T: Serialize + Send + Sync>( &self, class_name: &str, schema_payload: &T, ) -> Result<ParseSchema, ParseError>
Creates a new class schema in your Parse application.
This operation requires the Master Key to be configured on the Parse
and will use it for authentication.
§Arguments
class_name
: The name of the class to create. This must match theclassName
field in theschema_payload
.schema_payload
: Aserde_json::Value
representing the schema to create. It must includeclassName
andfields
. Optionally,classLevelPermissions
andindexes
can be included. Example:{ "className": "MyNewClass", "fields": { "name": { "type": "String", "required": true }, "score": { "type": "Number", "defaultValue": 0 } }, "classLevelPermissions": { "find": { "*": true }, "get": { "*": true } } }
§Returns
A Result
containing the ParseSchema
of the newly created class,
or a ParseError
if the request fails (e.g., Master Key not provided, schema definition error, class already exists, network error).
§Examples
use parse_rs::Parse;
use serde_json::json;
let client = Parse::new(&server_url, &app_id, None, None, Some(&master_key))?;
let new_class_name = "MyTemporaryClass";
let schema_payload = json!({
"className": new_class_name,
"fields": {
"playerName": { "type": "String" },
"score": { "type": "Number", "required": true, "defaultValue": 0 }
},
"classLevelPermissions": {
"find": { "*": true },
"get": { "*": true },
"create": { "*": true }, // Allow creation for testing
"update": { "*": true }, // Allow update for testing
"delete": { "*": true } // Allow deletion for testing
}
});
match client.create_class_schema(new_class_name, &schema_payload).await {
Ok(schema) => {
println!("Successfully created schema for class '{}':", schema.class_name);
println!("Fields: {:?}", schema.fields.keys());
// You can now create objects of this class, e.g., using client.create_object(...)
}
Err(e) => eprintln!("Failed to create schema for class '{}': {}", new_class_name, e),
}
// Clean up: Delete the class schema (optional, for testing)
// Ensure the class is empty before deleting, or set drop_class_if_objects_exist to true.
client.delete_class_schema(new_class_name, true).await.ok();
Sourcepub async fn update_class_schema<T: Serialize + Send + Sync>(
&self,
class_name: &str,
schema_update_payload: &T,
) -> Result<ParseSchema, ParseError>
pub async fn update_class_schema<T: Serialize + Send + Sync>( &self, class_name: &str, schema_update_payload: &T, ) -> Result<ParseSchema, ParseError>
Updates the schema for an existing class in your Parse application.
This can be used to add or remove fields, change field types (with caution),
update Class-Level Permissions (CLP), or add/remove indexes.
To delete a field or index, use the {"__op": "Delete"}
operator in the payload.
This operation requires the Master Key to be configured on the Parse
and will use it for authentication.
§Arguments
class_name
: The name of the class whose schema is to be updated.schema_update_payload
: Aserde_json::Value
representing the changes to apply. Example to add a field and delete another:{ "className": "MyExistingClass", // Should match class_name argument "fields": { "newField": { "type": "Boolean" }, "oldField": { "__op": "Delete" } }, "classLevelPermissions": { "update": { "role:Admin": true } // Example CLP update } }
§Returns
A Result
containing the updated ParseSchema
of the class,
or a ParseError
if the request fails (e.g., Master Key not provided, class not found, invalid update operation, network error).
§Examples
use parse_rs::Parse;
use serde_json::json;
let client = Parse::new(&server_url, &app_id, None, None, Some(&master_key))?;
let class_to_update = "MyUpdatableClass";
// 1. Ensure the class exists (create it for the example)
let initial_payload = json!({
"className": class_to_update,
"fields": { "initialField": { "type": "String" } },
"classLevelPermissions": { "find": {"*": true}, "get": {"*": true}, "create": {"*": true}, "update": {"*": true}, "delete": {"*": true} }
});
client.create_class_schema(class_to_update, &initial_payload).await.ok(); // Ignore error if already exists
// 2. Prepare the update payload
let update_payload = json!({
"className": class_to_update, // Must match
"fields": {
"addedField": { "type": "Number" },
"initialField": { "__op": "Delete" } // Delete the initial field
},
"classLevelPermissions": {
"get": { "role:Moderator": true, "*": false } // Change CLP
}
});
match client.update_class_schema(class_to_update, &update_payload).await {
Ok(schema) => {
println!("Successfully updated schema for class '{}':", schema.class_name);
println!("Current Fields: {:?}", schema.fields.keys());
if let Some(clp) = schema.class_level_permissions {
println!("Current CLP (get): {:?}", clp.get);
}
}
Err(e) => eprintln!("Failed to update schema for class '{}': {}", class_to_update, e),
}
// Clean up: Delete the class schema (optional, for testing)
client.delete_class_schema(class_to_update, true).await.ok();
Sourcepub async fn get_class_schema(
&self,
class_name: &str,
) -> Result<ParseSchema, ParseError>
pub async fn get_class_schema( &self, class_name: &str, ) -> Result<ParseSchema, ParseError>
Fetches the schema for a specific class in your Parse application.
This operation requires the Master Key to be configured on the Parse
and will use it for authentication.
§Arguments
class_name
: The name of the class for which to fetch the schema.
§Returns
A Result
containing the ParseSchema
for the specified class,
or a ParseError
if the request fails (e.g., Master Key not provided, class not found, network error).
§Examples
use parse_rs::Parse;
let client = Parse::new(&server_url, &app_id, None, None, Some(&master_key))?;
let class_to_fetch = "MyTestClass"; // Assume this class exists
// First, ensure the class exists by creating it if it doesn't (for testability)
// For a real scenario, you'd likely expect the class to exist.
let initial_schema_payload = serde_json::json!({
"className": class_to_fetch,
"fields": {
"someField": { "type": "String" }
}
});
client.create_class_schema(class_to_fetch, &initial_schema_payload).await.ok(); // Ignore error if already exists
match client.get_class_schema(class_to_fetch).await {
Ok(schema) => {
println!("Successfully fetched schema for class '{}':", schema.class_name);
println!("Fields: {:?}", schema.fields.keys());
if let Some(clp) = &schema.class_level_permissions {
println!("CLP: {:?}", clp.get);
}
}
Err(e) => eprintln!("Failed to fetch schema for class '{}': {}", class_to_fetch, e),
}
// Clean up the test class (optional)
client.delete_class_schema(class_to_fetch, true).await.ok();
Sourcepub async fn delete_class_schema(
&self,
class_name: &str,
_fail_if_objects_exist: bool,
) -> Result<(), ParseError>
pub async fn delete_class_schema( &self, class_name: &str, _fail_if_objects_exist: bool, ) -> Result<(), ParseError>
Deletes an existing class schema from your Parse application.
Important: The class must be empty (contain no objects) for the deletion to succeed. If the class contains objects, the Parse Server will return an error.
This operation requires the Master Key to be configured on the Parse
and will use it for authentication.
§Arguments
class_name
: The name of the class whose schema is to be deleted.fail_if_objects_exist
: Iftrue
(the default), the operation will fail if the class contains objects. Currently, the Parse API does not support automatically deleting objects along with the schema in a single call. You must delete all objects from the class manually before calling this method if you want to delete a non-empty class. Setting this tofalse
is not currently supported by the underlying API and will behave liketrue
.
§Returns
A Result<(), ParseError>
which is Ok(())
on successful deletion,
or a ParseError
if the request fails (e.g., Master Key not provided, class not found, class not empty, network error).
§Examples
use parse_rs::Parse;
use serde_json::json;
let client = Parse::new(&server_url, &app_id, None, None, Some(&master_key))?;
let class_to_delete = "MyClassToDelete";
// 1. Create a class for the example (ensure it's empty for successful deletion)
let schema_payload = json!({
"className": class_to_delete,
"fields": { "tempField": { "type": "String" } },
"classLevelPermissions": { "find": {"*": true}, "get": {"*": true}, "create": {"*": true}, "update": {"*": true}, "delete": {"*": true} }
});
client.create_class_schema(class_to_delete, &schema_payload).await.ok(); // Create it, ignore if already exists for test idempotency
// 2. Attempt to delete the (empty) class schema
match client.delete_class_schema(class_to_delete, true).await {
Ok(()) => println!("Successfully deleted schema for class '{}'", class_to_delete),
Err(e) => eprintln!("Failed to delete schema for class '{}': {}. Ensure it's empty.", class_to_delete, e),
}
// Example of trying to delete a class that might not be empty (will likely fail if objects exist)
// let another_class = "PotentiallyNonEmptyClass";
// if let Err(e) = client.delete_class_schema(another_class, true).await {
// eprintln!("Could not delete schema for '{}': {}. It might not be empty or might not exist.", another_class, e);
// }
Sourcepub fn user(&mut self) -> ParseUserHandle<'_>
pub fn user(&mut self) -> ParseUserHandle<'_>
Methods to get handles for specific Parse features
Returns a ParseUserHandle
for managing user authentication and user-specific operations.
The ParseUserHandle
provides methods like signup
, login
, logout
, request_password_reset
,
get_current_user
, update_current_user
, and delete_current_user
.
It operates in the context of the current Parse
instance, using its configuration
and session state.
§Examples
use parse_rs::{Parse, ParseError};
use serde_json::Value;
use std::collections::HashMap;
let mut user_data = HashMap::new();
user_data.insert("email".to_string(), Value::String("test@example.com".to_string()));
// Add other fields as needed for signup
// Get the user handle and sign up a new user
// let new_user = client.user().signup("testuser", "password123", Some(user_data)).await?;
// println!("New user signed up with ID: {}", new_user.get_object_id().unwrap_or_default());
// Later, to log in:
// let logged_in_user = client.user().login("testuser", "password123").await?;
// println!("User logged in. Session token: {}", client.session_token().unwrap_or_default());
Sourcepub fn session(&self) -> ParseSessionHandle<'_>
pub fn session(&self) -> ParseSessionHandle<'_>
Returns a ParseSessionHandle
for managing session-specific operations.
The ParseSessionHandle
provides methods like get_current_session
(to validate the current client’s session token)
and delete_session
(to delete a specific session, requires Master Key).
§Examples
use parse_rs::{Parse, ParseError, ParseSession};
// After a user logs in, their session token is stored in the client.
// You can then get details about the current session:
// if client.is_authenticated() {
// match client.session().get_current_session().await {
// Ok(current_session_details) => {
// println!("Current session is valid for user: {}",
// current_session_details.get_user().map_or("N/A", |u| u.get_object_id().unwrap_or_default()));
// }
// Err(e) => eprintln!("Could not get current session details: {}", e),
// }
// }
Sourcepub fn cloud(&self) -> ParseCloud<'_>
pub fn cloud(&self) -> ParseCloud<'_>
Returns a ParseCloud
handle for calling Parse Cloud Code functions.
The ParseCloud
handle provides the call_function
method to execute server-side Cloud Code.
§Examples
use parse_rs::{Parse, ParseError};
use serde_json::json; // For creating parameters
let function_name = "helloWorld";
let params = json!({ "name": "Rustaceans" });
// match client.cloud().call_function(function_name, Some(params)).await {
// Ok(result) => println!("Cloud function '{}' returned: {}", function_name, result),
// Err(e) => eprintln!("Cloud function '{}' failed: {}", function_name, e),
// }
Sourcepub async fn get_all_schemas(&self) -> Result<GetAllSchemasResponse, ParseError>
pub async fn get_all_schemas(&self) -> Result<GetAllSchemasResponse, ParseError>
Fetches the schemas for all classes in your Parse application.
This operation requires the Master Key to be configured on the Parse
and will use it for authentication.
§Returns
A Result
containing a GetAllSchemasResponse
which includes a list of ParseSchema
objects,
or a ParseError
if the request fails (e.g., Master Key not provided, network error).
§Examples
use parse_rs::Parse;
let client = Parse::new(&server_url, &app_id, None, None, Some(&master_key))?;
match client.get_all_schemas().await {
Ok(response) => {
println!("Successfully fetched {} schemas:", response.results.len());
for schema in response.results {
println!("- Class: {}, Fields: {:?}", schema.class_name, schema.fields.keys());
}
}
Err(e) => eprintln!("Failed to fetch schemas: {}", e),
}
Source§impl Parse
impl Parse
Sourcepub async fn get_config(&self) -> Result<ParseConfig, ParseError>
pub async fn get_config(&self) -> Result<ParseConfig, ParseError>
Retrieves the Parse Server configuration.
This operation requires the Master Key.
§Returns
A Result
containing the ParseConfig
or a ParseError
.
Sourcepub async fn update_config(
&self,
params_to_update: &HashMap<String, Value>,
) -> Result<UpdateConfigResponse, ParseError>
pub async fn update_config( &self, params_to_update: &HashMap<String, Value>, ) -> Result<UpdateConfigResponse, ParseError>
Updates the Parse Server configuration parameters.
This operation requires the Master Key.
The params_to_update
should contain only the parameters you wish to change.
§Arguments
params_to_update
: AHashMap<String, Value>
of parameters to update.
§Returns
A Result
indicating success (typically an empty successful response or a confirmation)
or a ParseError
.
The Parse Server responds with {"result": true}
on successful update.
Source§impl Parse
impl Parse
Sourcepub async fn create_installation(
&self,
installation_data: &NewParseInstallation,
) -> Result<CreateObjectResponse, ParseError>
pub async fn create_installation( &self, installation_data: &NewParseInstallation, ) -> Result<CreateObjectResponse, ParseError>
Sourcepub async fn get_installation(
&self,
object_id: &str,
) -> Result<RetrievedParseInstallation, ParseError>
pub async fn get_installation( &self, object_id: &str, ) -> Result<RetrievedParseInstallation, ParseError>
Sourcepub async fn update_installation(
&self,
object_id: &str,
update_data: &UpdateParseInstallation,
) -> Result<UpdateObjectResponse, ParseError>
pub async fn update_installation( &self, object_id: &str, update_data: &UpdateParseInstallation, ) -> Result<UpdateObjectResponse, ParseError>
Updates an existing Installation object on the Parse Server.
§Arguments
object_id
: The objectId of the installation to update.update_data
: AnUpdateParseInstallation
struct containing the fields to update.
§Returns
A Result
containing an UpdateObjectResponse
(which includes updatedAt
) or a ParseError
.
Sourcepub async fn delete_installation(
&self,
object_id: &str,
) -> Result<EmptyResponse, ParseError>
pub async fn delete_installation( &self, object_id: &str, ) -> Result<EmptyResponse, ParseError>
Source§impl Parse
impl Parse
pub async fn create_object<T: Serialize + Send + Sync>( &self, class_name: &str, data: &T, ) -> Result<CreateObjectResponse, ParseError>
pub async fn retrieve_object( &self, class_name: &str, object_id: &str, ) -> Result<RetrievedParseObject, ParseError>
pub async fn update_object<T: Serialize + Send + Sync>( &self, class_name: &str, object_id: &str, data: &T, ) -> Result<UpdateObjectResponse, ParseError>
pub async fn delete_object( &self, class_name: &str, object_id: &str, ) -> Result<(), ParseError>
Source§impl Parse
impl Parse
Sourcepub async fn add_to_relation(
&self,
parent_class_name: &str,
parent_object_id: &str,
relation_key: &str,
targets: &[Pointer],
) -> Result<ParseDate, ParseError>
pub async fn add_to_relation( &self, parent_class_name: &str, parent_object_id: &str, relation_key: &str, targets: &[Pointer], ) -> Result<ParseDate, ParseError>
Adds target objects to a relation field of a parent object.
§Arguments
parent_class_name
: The class name of the parent object.parent_object_id
: The object ID of the parent object.relation_key
: The key (field name) of the relation on the parent object.targets
: A slice ofPointer
s representing the objects to add to the relation.
§Returns
A Result
containing the ParseDate
of the update or a ParseError
.
This operation typically requires the Master Key or appropriate ACLs.
Sourcepub async fn remove_from_relation(
&self,
parent_class_name: &str,
parent_object_id: &str,
relation_key: &str,
targets: &[Pointer],
) -> Result<ParseDate, ParseError>
pub async fn remove_from_relation( &self, parent_class_name: &str, parent_object_id: &str, relation_key: &str, targets: &[Pointer], ) -> Result<ParseDate, ParseError>
Removes target objects from a relation field of a parent object.
§Arguments
parent_class_name
: The class name of the parent object.parent_object_id
: The object ID of the parent object.relation_key
: The key (field name) of the relation on the parent object.targets
: A slice ofPointer
s representing the objects to remove from the relation.
§Returns
A Result
containing the ParseDate
of the update or a ParseError
.
This operation typically requires the Master Key or appropriate ACLs.
Source§impl Parse
impl Parse
pub async fn get<R: DeserializeOwned + Send + 'static>( &self, endpoint: &str, ) -> Result<R, ParseError>
pub async fn post<T: Serialize + Send + Sync, R: DeserializeOwned + Send + 'static>( &self, endpoint: &str, data: &T, ) -> Result<R, ParseError>
pub async fn put<T: Serialize + Send + Sync, R: DeserializeOwned + Send + 'static>( &self, endpoint: &str, data: &T, ) -> Result<R, ParseError>
pub async fn delete<R: DeserializeOwned + Send + 'static>( &self, endpoint: &str, ) -> Result<R, ParseError>
Source§impl Parse
impl Parse
Sourcepub async fn create_role(
&self,
new_role: &NewParseRole,
) -> Result<ParseRole, ParseError>
pub async fn create_role( &self, new_role: &NewParseRole, ) -> Result<ParseRole, ParseError>
Creates a new Role on the Parse Server.
§Arguments
new_role
: ANewParseRole
struct containing the name and ACL for the new role.
§Returns
A Result
containing the created ParseRole
or a ParseError
.
Note: The users
and roles
relations are not populated in the returned object.
They need to be managed via separate relation operations or queries.
Sourcepub async fn delete_role(&self, object_id: &str) -> Result<(), ParseError>
pub async fn delete_role(&self, object_id: &str) -> Result<(), ParseError>
Sourcepub async fn add_users_to_role(
&self,
role_id: &str,
user_ids: &[&str],
) -> Result<ParseDate, ParseError>
pub async fn add_users_to_role( &self, role_id: &str, user_ids: &[&str], ) -> Result<ParseDate, ParseError>
Sourcepub async fn remove_users_from_role(
&self,
role_id: &str,
user_ids: &[&str],
) -> Result<ParseDate, ParseError>
pub async fn remove_users_from_role( &self, role_id: &str, user_ids: &[&str], ) -> Result<ParseDate, ParseError>
Sourcepub async fn add_child_roles_to_role(
&self,
role_id: &str,
child_role_ids: &[&str],
) -> Result<ParseDate, ParseError>
pub async fn add_child_roles_to_role( &self, role_id: &str, child_role_ids: &[&str], ) -> Result<ParseDate, ParseError>
Adds child roles to a specific (parent) Role.
§Arguments
role_id
: The objectId of the parent Role to modify.child_role_ids
: A slice of objectIds of the child Roles to add to the parent role.
§Returns
A Result
containing the ParseDate
of the update or a ParseError
.
This operation typically requires the Master Key.
Sourcepub async fn remove_child_roles_from_role(
&self,
role_id: &str,
child_role_ids: &[&str],
) -> Result<ParseDate, ParseError>
pub async fn remove_child_roles_from_role( &self, role_id: &str, child_role_ids: &[&str], ) -> Result<ParseDate, ParseError>
Removes child roles from a specific (parent) Role.
§Arguments
role_id
: The objectId of the parent Role to modify.child_role_ids
: A slice of objectIds of the child Roles to remove from the parent role.
§Returns
A Result
containing the ParseDate
of the update or a ParseError
.
This operation typically requires the Master Key.