feat(tvix/store/proto): implement get_name for all nodes
Also add a `NamedNode` trait. We'll later use this to access names from all three individually. Change-Id: Icb5afd6fa5a0d834e9908294382de9892a5a6440 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7953 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
9c18888715
commit
a2c33f517c
1 changed files with 24 additions and 0 deletions
|
@ -150,6 +150,30 @@ impl PathInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// NamedNode is implemented for [FileNode], [DirectoryNode] and [SymlinkNode],
|
||||||
|
/// so we can ask all three for their name easily.
|
||||||
|
trait NamedNode {
|
||||||
|
fn get_name(&self) -> &str;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NamedNode for &FileNode {
|
||||||
|
fn get_name(&self) -> &str {
|
||||||
|
self.name.as_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NamedNode for &DirectoryNode {
|
||||||
|
fn get_name(&self) -> &str {
|
||||||
|
self.name.as_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NamedNode for &SymlinkNode {
|
||||||
|
fn get_name(&self) -> &str {
|
||||||
|
self.name.as_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Accepts a name, and a mutable reference to the previous name.
|
/// Accepts a name, and a mutable reference to the previous name.
|
||||||
/// If the passed name is larger than the previous one, the reference is updated.
|
/// If the passed name is larger than the previous one, the reference is updated.
|
||||||
/// If it's not, an error is returned.
|
/// If it's not, an error is returned.
|
||||||
|
|
Loading…
Reference in a new issue