Skip to content

Commit 4defaa7

Browse files
committed
ref: Move EMPTY_SCOPES to common module
1 parent cad60a1 commit 4defaa7

File tree

2 files changed

+7
-7
lines changed
  • objectstore-server/src/extractors
  • objectstore-types/src

2 files changed

+7
-7
lines changed

objectstore-server/src/extractors/id.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ use axum::extract::rejection::PathRejection;
44
use axum::extract::{FromRequestParts, Path};
55
use axum::http::request::Parts;
66
use objectstore_service::id::{ObjectContext, ObjectId};
7-
use objectstore_types::scope::{Scope, Scopes};
7+
use objectstore_types::scope::{EMPTY_SCOPES, Scope, Scopes};
88
use serde::{Deserialize, de};
99

1010
use crate::extractors::Xt;
1111
use crate::state::ServiceState;
1212

13-
/// Used in place of scopes in the URL to represent an empty set of scopes.
14-
const EMPTY_SCOPES: &str = "_";
15-
1613
impl FromRequestParts<ServiceState> for Xt<ObjectId> {
1714
type Rejection = PathRejection;
1815

objectstore-types/src/scope.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! - [`Scope`] is a single key-value pair representing one level of hierarchy
66
//! - [`Scopes`] is an ordered collection of [`Scope`]s
77
8-
use std::fmt::{self, Write};
8+
use std::fmt;
99

1010
/// Characters allowed in a Scope's key and value.
1111
///
@@ -14,6 +14,9 @@ use std::fmt::{self, Write};
1414
const ALLOWED_CHARS: &str =
1515
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-()$!+'";
1616

17+
/// Used in place of scopes in the URL to represent an empty set of scopes.
18+
pub const EMPTY_SCOPES: &str = "_";
19+
1720
/// A single scope value of an object.
1821
///
1922
/// Scopes are used in a hierarchy in object IDs.
@@ -204,7 +207,7 @@ impl fmt::Display for AsApiPath<'_> {
204207
}
205208
Ok(())
206209
} else {
207-
f.write_char('_')
210+
f.write_str(EMPTY_SCOPES)
208211
}
209212
}
210213
}
@@ -271,6 +274,6 @@ mod tests {
271274

272275
let empty_scopes = Scopes::empty();
273276
let api_path = empty_scopes.as_api_path().to_string();
274-
assert_eq!(api_path, "_");
277+
assert_eq!(api_path, EMPTY_SCOPES);
275278
}
276279
}

0 commit comments

Comments
 (0)