Skip to content

Commit 9bfa9ea

Browse files
Koenraad VerheydenJoshua Nelson
Koenraad Verheyden
authored and
Joshua Nelson
committed
Add doc comments to db::blacklist
1 parent 72137a6 commit 9bfa9ea

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/db/blacklist.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ enum BlacklistError {
1010
CrateNotOnBlacklist(String),
1111
}
1212

13+
/// Returns whether the given name is blacklisted.
1314
pub fn is_blacklisted(conn: &Connection, name: &str) -> Result<bool, Error> {
1415
let rows = conn.query(
1516
"SELECT COUNT(*) FROM blacklisted_crates WHERE crate_name = $1;",
@@ -20,6 +21,7 @@ pub fn is_blacklisted(conn: &Connection, name: &str) -> Result<bool, Error> {
2021
Ok(count != 0)
2122
}
2223

24+
/// Returns the crate names on the blacklist, sorted ascending.
2325
pub fn list_crates(conn: &Connection) -> Result<Vec<String>, Error> {
2426
let rows = conn.query(
2527
"SELECT crate_name FROM blacklisted_crates ORDER BY crate_name asc;",
@@ -29,6 +31,7 @@ pub fn list_crates(conn: &Connection) -> Result<Vec<String>, Error> {
2931
Ok(rows.into_iter().map(|row| row.get(0)).collect())
3032
}
3133

34+
/// Adds a crate to the blacklist.
3235
pub fn add_crate(conn: &Connection, name: &str) -> Result<(), Error> {
3336
if is_blacklisted(conn, name)? {
3437
return Err(BlacklistError::CrateAlreadyOnBlacklist(name.into()).into());
@@ -42,6 +45,7 @@ pub fn add_crate(conn: &Connection, name: &str) -> Result<(), Error> {
4245
Ok(())
4346
}
4447

48+
/// Removes a crate from the blacklist.
4549
pub fn remove_crate(conn: &Connection, name: &str) -> Result<(), Error> {
4650
if !is_blacklisted(conn, name)? {
4751
return Err(BlacklistError::CrateNotOnBlacklist(name.into()).into());

0 commit comments

Comments
 (0)