Skip to main content

rib/registry/
component_dependency_key.rs

1// Copyright 2024-2025 Golem Cloud
2//
3// Licensed under the Golem Source License v1.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://license.golem.cloud/LICENSE
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::fmt::{Display, Formatter};
16use uuid::Uuid;
17
18#[derive(Debug, Default, Hash, PartialEq, Eq, Clone, Ord, PartialOrd)]
19pub struct ComponentDependencyKey {
20    pub component_name: String,
21    pub component_id: Uuid,
22    pub component_revision: u64,
23    pub root_package_name: Option<String>,
24    pub root_package_version: Option<String>,
25}
26
27impl Display for ComponentDependencyKey {
28    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29        write!(
30            f,
31            "Component: {}, ID: {}, Revision: {}, Root Package: {}@{}",
32            self.component_name,
33            self.component_id,
34            self.component_revision,
35            self.root_package_name.as_deref().unwrap_or("unknown"),
36            self.root_package_version.as_deref().unwrap_or("unknown")
37        )
38    }
39}