Skip to content

Commit

Permalink
Merge pull request #23 from Sleitnick/bugfix/datastores
Browse files Browse the repository at this point in the history
Fix datastores
  • Loading branch information
Sleitnick authored Feb 9, 2023
2 parents 5744e0f + 83fa9b9 commit 9f2c511
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Release

on:
push:
tags: "v*"
tags:
- v*

jobs:
create-release:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
},
"[rust]": {
"editor.formatOnSave": true
}
},
"files.eol": "\n"
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rbxcloud"
version = "0.2.1"
version = "0.2.2"
description = "CLI and SDK for the Roblox Open Cloud APIs"
authors = ["Stephen Leitnick"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions examples/datastore-get-entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ async fn main() {
// Print entry result or error:
match entry_result {
Ok(result) => {
println!("{}", result);
println!("{result}");
}
Err(e) => {
eprintln!("{:?}", e);
eprintln!("{e:?}");
}
}
}
2 changes: 1 addition & 1 deletion examples/publish-message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() {
println!("Message successfully published");
}
Err(e) => {
eprintln!("{:?}", e);
eprintln!("{e:?}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/publish-place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() {
println!("Published place! New version: {}", result.version_number);
}
Err(e) => {
eprintln!("{:?}", e);
eprintln!("{e:?}");
}
}
}
12 changes: 6 additions & 6 deletions src/cli/datastore_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl DataStore {
})
.await;
match res {
Ok(data) => Ok(Some(format!("{:#?}", data))),
Ok(data) => Ok(Some(format!("{data:#?}"))),
Err(err) => Err(err.into()),
}
}
Expand Down Expand Up @@ -330,7 +330,7 @@ impl DataStore {
})
.await;
match res {
Ok(data) => Ok(Some(format!("{:#?}", data))),
Ok(data) => Ok(Some(format!("{data:#?}"))),
Err(err) => Err(err.into()),
}
}
Expand Down Expand Up @@ -385,7 +385,7 @@ impl DataStore {
})
.await;
match res {
Ok(data) => Ok(Some(format!("{:#?}", data))),
Ok(data) => Ok(Some(format!("{data:#?}"))),
Err(err) => Err(err.into()),
}
}
Expand Down Expand Up @@ -414,7 +414,7 @@ impl DataStore {
})
.await;
match res {
Ok(data) => Ok(Some(format!("{}", data))),
Ok(data) => Ok(Some(format!("{data}"))),
Err(err) => Err(err.into()),
}
}
Expand Down Expand Up @@ -462,13 +462,13 @@ impl DataStore {
key,
start_time,
end_time,
sort_order: format!("{:?}", sort_order),
sort_order: format!("{sort_order:?}"),
limit: ReturnLimit(limit),
cursor,
})
.await;
match res {
Ok(data) => Ok(Some(format!("{:#?}", data))),
Ok(data) => Ok(Some(format!("{data:#?}"))),
Err(err) => Err(err.into()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/messaging_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Messaging {
let messaging = rbx_cloud.messaging(&topic);
let res = messaging.publish(&message).await;
match res {
Ok(()) => Ok(Some(format!("published message to topic {}", topic))),
Ok(()) => Ok(Some(format!("published message to topic {topic}"))),
Err(err) => Err(anyhow::anyhow!(err)),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ async fn main() {
match cli_args.run().await {
Ok(str) => {
if let Some(s) = str {
println!("{}", s);
println!("{s}");
}
}
Err(err) => {
eprintln!("{:?}", err);
eprintln!("{err:?}");
process::exit(1);
}
}
Expand Down
15 changes: 5 additions & 10 deletions src/rbx/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,18 @@ async fn handle_res_ok(res: Response) -> Result<(), Error> {

fn build_url(endpoint: &str, universe_id: UniverseId) -> String {
if endpoint.is_empty() {
format!(
"https://apis.roblox.com/datastores/v1/universes/{universeId}/standard-datastores",
universeId = universe_id,
)
format!("https://apis.roblox.com/datastores/v1/universes/{universe_id}/standard-datastores",)
} else {
format!(
"https://apis.roblox.com/datastores/v1/universes/{universeId}/standard-datastores/{endpoint}",
universeId=universe_id,
endpoint=endpoint,
"https://apis.roblox.com/datastores/v1/universes/{universe_id}/standard-datastores{endpoint}",
)
}
}

#[inline]
fn get_checksum_base64(data: &String) -> String {
let mut md5_hash = Md5::new();
md5_hash.update(&data.as_bytes());
md5_hash.update(data.as_bytes());
base64::encode(md5_hash.finalize())
}

Expand Down Expand Up @@ -350,7 +345,7 @@ fn build_ids_csv(ids: &Option<Vec<RobloxUserId>>) -> String {
ids.as_ref()
.unwrap_or(&vec![])
.iter()
.map(|id| format!("{}", id))
.map(|id| format!("{id}"))
.collect::<Vec<String>>()
.join(",")
}
Expand Down Expand Up @@ -413,7 +408,7 @@ pub async fn increment_entry(params: &IncrementEntryParams) -> Result<f64, Error
let res = client
.post(url)
.header("x-api-key", &params.api_key)
.header("roblox-entry-userids", format!("[{}]", ids))
.header("roblox-entry-userids", format!("[{ids}]"))
.header(
"roblox-entry-attributes",
params
Expand Down
14 changes: 7 additions & 7 deletions src/rbx/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ impl From<std::num::ParseFloatError> for Error {
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
match self {
Self::FileLoadError(s) => write!(f, "failed to read file: {}", s),
Self::HttpStatusError { code, msg } => write!(f, "http {}: {}", code, msg),
Self::ReqwestError(e) => write!(f, "{:?}", e),
Self::IOError(e) => write!(f, "{:?}", e),
Self::SerdeJsonError(e) => write!(f, "{:?}", e),
Self::DataStoreError(e) => write!(f, "{:?}", e),
Self::ParseFloatError(e) => write!(f, "{:?}", e),
Self::FileLoadError(s) => write!(f, "failed to read file: {s}"),
Self::HttpStatusError { code, msg } => write!(f, "http {code}: {msg}"),
Self::ReqwestError(e) => write!(f, "{e:?}"),
Self::IOError(e) => write!(f, "{e:?}"),
Self::SerdeJsonError(e) => write!(f, "{e:?}"),
Self::DataStoreError(e) => write!(f, "{e:?}"),
Self::ParseFloatError(e) => write!(f, "{e:?}"),
}
}
}
2 changes: 1 addition & 1 deletion src/rbx/experience.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum PublishVersionType {

impl fmt::Display for PublishVersionType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}

Expand Down

0 comments on commit 9f2c511

Please sign in to comment.