Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
arch-rebuild-order
Commits
c8abaf59
Unverified
Commit
c8abaf59
authored
Jan 22, 2021
by
Orhun Parmaksız
Browse files
Use anyhow Result type for library methods
parent
740643be
Pipeline
#4734
passed with stages
in 2 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib.rs
View file @
c8abaf59
use
alpm
::{
Package
,
SigLevel
};
use
anyhow
::{
anyhow
,
Result
};
use
error
::
RebuildOrderError
;
use
petgraph
::
dot
::{
Config
,
Dot
};
use
petgraph
::
graph
::
DiGraph
;
...
...
@@ -14,17 +15,14 @@ const ROOT_DIR: &str = "/";
const
DB_PATH
:
&
str
=
"/var/lib/pacman/"
;
/// Attempt to find any match of a package in the syncdb.
fn
find_package_anywhere
<
'a
>
(
pkgname
:
&
str
,
pacman
:
&
'a
alpm
::
Alpm
,
)
->
Result
<
Package
<
'a
>
,
RebuildOrderError
>
{
fn
find_package_anywhere
<
'a
>
(
pkgname
:
&
str
,
pacman
:
&
'a
alpm
::
Alpm
)
->
Result
<
Package
<
'a
>>
{
let
dbs
=
pacman
.syncdbs
();
for
db
in
dbs
{
if
let
Ok
(
pkg
)
=
db
.pkg
(
pkgname
)
{
return
Ok
(
pkg
);
}
}
Err
(
RebuildOrderError
::
PackageNotFound
)
Err
(
anyhow!
(
RebuildOrderError
::
PackageNotFound
)
)
}
/// Retrieve a HashMap of all reverse dependencies.
...
...
@@ -66,7 +64,7 @@ fn get_reverse_deps_map(pacman: &alpm::Alpm) -> HashMap<String, HashSet<String>>
}
/// Write a given DiGraph to a given file using a buffered writer.
fn
write_dotfile
(
filename
:
String
,
graph
:
DiGraph
<&
str
,
u16
>
)
->
Result
<
()
,
RebuildOrderError
>
{
fn
write_dotfile
(
filename
:
String
,
graph
:
DiGraph
<&
str
,
u16
>
)
->
Result
<
()
>
{
let
dotgraph
=
Dot
::
with_config
(
&
graph
,
&
[
Config
::
EdgeNoLabel
]);
let
file
=
File
::
create
(
filename
)
?
;
let
mut
bufw
=
BufWriter
::
new
(
file
);
...
...
@@ -81,7 +79,7 @@ pub fn run(
dbpath
:
Option
<
String
>
,
repos
:
Vec
<
String
>
,
dotfile
:
Option
<
String
>
,
)
->
anyhow
::
Result
<
String
>
{
)
->
Result
<
String
>
{
let
pacman
=
match
dbpath
{
Some
(
path
)
=>
alpm
::
Alpm
::
new
(
ROOT_DIR
,
&
path
),
None
=>
alpm
::
Alpm
::
new
(
ROOT_DIR
,
DB_PATH
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment