leo_package/dependency.rs
1// Copyright (C) 2019-2025 Provable Inc.
2// This file is part of the Leo library.
3
4// The Leo library is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// The Leo library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
16
17use crate::Location;
18
19use serde::{Deserialize, Serialize};
20use std::path::PathBuf;
21
22/// Information about a dependency, as represented in the `program.json` manifest.
23#[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
24pub struct Dependency {
25 /// The name of the program. As this corresponds to what appears in `program.json`,
26 /// it should have the ".aleo" suffix.
27 pub name: String,
28 /// Network, local, or test dependency?
29 pub location: Location,
30 /// For a local dependency, where is its package? Or, for a test, where is its source file?
31 pub path: Option<PathBuf>,
32}
33
34impl Dependency {
35 pub fn new(name: String, location: Location, path: Option<PathBuf>) -> Self {
36 Self { name, location, path }
37 }
38}