is_publishable_to_crates_io

Function is_publishable_to_crates_io 

Source
pub fn is_publishable_to_crates_io(manifest_path: &Path) -> Result<bool>
Expand description

Determines if a crate is publishable to crates.io based on its Cargo.toml manifest.

Checks the publish field in the [package] section according to Cargo’s rules:

  • No publish field: publishable (default)
  • publish = false: not publishable
  • publish = ["registry1", "registry2"]: publishable only if “crates-io” is in the array

§Arguments

  • manifest_path - Path to the Cargo.toml file to check

§Examples

use std::path::Path;
use sampo_core::is_publishable_to_crates_io;

// Check if a crate is publishable
let publishable = is_publishable_to_crates_io(Path::new("./Cargo.toml")).unwrap();
if publishable {
    println!("This crate can be published to crates.io");
}

§Errors

Returns an error if:

  • The manifest file cannot be read
  • The TOML is malformed
  • The manifest has no [package] section (returns Ok(false))