remove as_str() legacy wrappers, callers use .into() directly
This commit is contained in:
parent
299add158f
commit
46456f75ce
25 changed files with 46 additions and 128 deletions
|
|
@ -55,14 +55,6 @@ impl Kind {
|
|||
/// than restate it — a second list is a list that drifts.
|
||||
pub const ALL: [Kind; 4] = [Kind::Agent, Kind::Hive, Kind::Service, Kind::Controller];
|
||||
|
||||
/// The path segment, which is also what the store's grant is written
|
||||
/// against. Thin wrapper over the derived `Into<&'static str>` so call
|
||||
/// sites keep the same method-call shape as before.
|
||||
#[must_use]
|
||||
pub fn as_str(self) -> &'static str {
|
||||
self.into()
|
||||
}
|
||||
|
||||
/// What to call the name in an error — singular, because the message reads
|
||||
/// "hive name ... is not a single path segment".
|
||||
#[must_use]
|
||||
|
|
@ -85,7 +77,7 @@ impl Kind {
|
|||
/// another's secrets.
|
||||
pub fn principal_prefix(kind: Kind, name: &str) -> Result<String, Error> {
|
||||
checked_segment(kind.label(), name)?;
|
||||
Ok(format!("{ROOT}/{}/{name}", kind.as_str()))
|
||||
Ok(format!("{ROOT}/{}/{name}", <&str>::from(kind)))
|
||||
}
|
||||
|
||||
/// A path segment that cannot change the path's shape.
|
||||
|
|
@ -183,7 +175,7 @@ mod tests {
|
|||
// without a segment here would be granted by accident rather than by
|
||||
// decision. Spelling each one out is what makes adding a kind a
|
||||
// deliberate edit.
|
||||
let segments: Vec<&str> = Kind::ALL.iter().map(|k| k.as_str()).collect();
|
||||
let segments: Vec<&str> = Kind::ALL.iter().map(|k| (*k).into()).collect();
|
||||
assert_eq!(segments, ["agents", "hives", "services", "controller"]);
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +186,11 @@ mod tests {
|
|||
// make the error name the wrong one.
|
||||
for (i, a) in Kind::ALL.iter().enumerate() {
|
||||
for b in &Kind::ALL[i + 1..] {
|
||||
assert_ne!(a.as_str(), b.as_str(), "{a:?} and {b:?} share a segment");
|
||||
assert_ne!(
|
||||
<&str>::from(*a),
|
||||
<&str>::from(*b),
|
||||
"{a:?} and {b:?} share a segment"
|
||||
);
|
||||
assert_ne!(a.label(), b.label(), "{a:?} and {b:?} share a label");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ pub fn hive_object_name(hive: &str) -> Result<String, Error> {
|
|||
pub fn render() -> String {
|
||||
format!(
|
||||
"path \"{MOUNT}/data/{ROOT}/{}/*\" {{\n capabilities = [\"read\"]\n}}\n",
|
||||
Kind::Agent.as_str()
|
||||
<&str>::from(Kind::Agent)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue