Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(attachments): convert functions and structs to use `struct` keyword

Steven Enamakele5ba85abbc32
diff --git a/crates/openhuman-core/src/threads/attachments/staged.rs b/crates/openhuman-core/src/threads/attachments/staged.rs
index a21b0b456e..95eeb295a4 100644
--- a/crates/openhuman-core/src/threads/attachments/staged.rs
+++ b/crates/openhuman-core/src/threads/attachments/staged.rs
@@ -4,7 +4,7 @@ use tinystoragedrivers::CollectionSpec;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
-pub(super) \1 StagedAttachment {
+pub(super) struct StagedAttachment {
tenant: crate::core::runtime::Tenant,
thread_id: String,
attachment: StoredAttachment,
@@ -15,7 +15,7 @@ pub(super) \1 StagedAttachment {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
-pub(super) \1 StagedAttachmentClaim {
+pub(super) struct StagedAttachmentClaim {
tenant: crate::core::runtime::Tenant,
thread_id: String,
message_id: String,
@@ -24,25 +24,21 @@ pub(super) \1 StagedAttachmentClaim {
canceled: bool,
}
-pub(super) \1 STAGED_DOMAIN: &str = "threads::attachments";
-pub(super) \1 STAGED_COLLECTION: &str = "staged_thread_attachments";
-pub(super) \1 STAGED_TTL_SECS: i64 = 7 * 24 * 60 * 60;
+pub(super) const STAGED_DOMAIN: &str = "threads::attachments";
+pub(super) const STAGED_COLLECTION: &str = "staged_thread_attachments";
+pub(super) const STAGED_TTL_SECS: i64 = 7 * 24 * 60 * 60;
-pub(super) \1 STAGED_DOMAIN: &str = "threads::attachments";
-pub(super) \1 STAGED_COLLECTION: &str = "staged_thread_attachments";
-pub(super) \1 STAGED_TTL_SECS: i64 = 7 * 24 * 60 * 60;
-
-pub(super) \1 staged_doc_id(opaque_id: &str) -> Result<String, String> {
+pub(super) fn staged_doc_id(opaque_id: &str) -> Result<String, String> {
let uuid = uuid::Uuid::parse_str(opaque_id)
.map_err(|_| "staged attachment reference is invalid".to_string())?;
Ok(uuid.simple().to_string())
}
-pub(super) \1 staged_collections() -> Vec<CollectionSpec> {
+pub(super) fn staged_collections() -> Vec<CollectionSpec> {
vec![CollectionSpec::new(STAGED_COLLECTION)]
}
-pub(super) \1 staged_repo(
+pub(super) fn staged_repo(
ctx: &crate::core::runtime::DispatchCtx,
workspace: &std::path::Path,
) -> Result<Repo, String> {
@@ -59,7 +55,7 @@ pub(super) \1 staged_repo(
.map_err(|error| format!("open staged attachment collection: {error}"))
}
-pub(super) \1 get_staged_record(repo: &Repo, id: &str) -> Result<Option<StagedAttachment>, String> {
+pub(super) fn get_staged_record(repo: &Repo, id: &str) -> Result<Option<StagedAttachment>, String> {
let id = id.to_string();
repo.run(|docs| async move {
let Some(stored) = docs.get(STAGED_COLLECTION, &id).await? else {
@@ -72,7 +68,7 @@ pub(super) \1 get_staged_record(repo: &Repo, id: &str) -> Result<Option<StagedAt
.map_err(|error| error.to_string())
}
-pub(super) \1 read_staged_entries(
+pub(super) fn read_staged_entries(
ctx: &crate::core::runtime::DispatchCtx,
thread_id: &str,
requested: &[ContentPart],
@@ -130,7 +126,7 @@ pub(crate) async fn bind_staged_refs(
))
}
-pub(super) \1 claim_staged_refs(
+pub(super) fn claim_staged_refs(
ctx: &crate::core::runtime::DispatchCtx,
thread_id: &str,
config: &crate::config::Config,
@@ -159,7 +155,7 @@ pub(super) \1 claim_staged_refs(
Ok(())
}
-pub(super) \1 claim_staged_record(
+pub(super) fn claim_staged_record(
repo: &Repo,
tenant: &crate::core::runtime::Tenant,
thread_id: &str,
@@ -329,7 +325,7 @@ pub(crate) async fn resolve_staged_parts(
Ok(resolved)
}
-pub(super) \1 validate_staged_files(
+pub(super) fn validate_staged_files(
ctx: &crate::core::runtime::DispatchCtx,
thread_id: &str,
config: &crate::config::Config,
@@ -399,7 +395,7 @@ pub(crate) async fn discard_staged_parts(
discard_staged_entries(ctx, thread_id, &config, entries).await
}
-pub(super) \1 discard_staged_entries(
+pub(super) fn discard_staged_entries(
ctx: &crate::core::runtime::DispatchCtx,
thread_id: &str,
config: &crate::config::Config,
@@ -447,7 +443,7 @@ pub(super) \1 discard_staged_entries(
Ok(())
}
-pub(super) \1 cancel_staged_record(
+pub(super) fn cancel_staged_record(
repo: &Repo,
tenant: &crate::core::runtime::Tenant,
thread_id: &str,
@@ -550,7 +546,7 @@ pub(crate) async fn consume_staged_parts(
Ok(())
}
-pub(super) \1 opaque_media(part: &ContentPart) -> Option<&MediaReference> {
+pub(super) fn opaque_media(part: &ContentPart) -> Option<&MediaReference> {
match part {
ContentPart::Image { media, .. }
| ContentPart::Audio { media, .. }
@@ -588,4 +584,3 @@ pub(crate) fn validate_opaque_parts(parts: &[ContentPart]) -> Result<(), String>
}
Ok(())
}
-