[−][src]Struct cargo_toml_builder::CargoToml
Main builder struct
This is the builder that all other methods are called on. You can use ::builder()
,
::new()
, or ::default()
to get an initialized instance
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::builder() .name("my-project") .author("Me <me@me.com>") .build()?; assert_eq!(cargo_toml.to_string(), r#" [package] name = "my-project" version = "0.1.0" authors = ["Me <me@me.com>"] [dependencies] "#);
Fields
name: Option<String>
The name that will be used for this Cargo.toml
The list of authors that will be used for this Cargo.toml
Methods
impl CargoToml
[src]
pub fn new() -> CargoToml
[src]
Construct a new instance
Example
extern crate cargo_toml_builder; use cargo_toml_builder::CargoToml; let cargo_toml = CargoToml::new();
pub fn builder() -> CargoToml
[src]
Construct a new instance
Example
extern crate cargo_toml_builder; use cargo_toml_builder::CargoToml; let cargo_toml = CargoToml::builder();
pub fn name(&mut self, name: &str) -> &mut Self
[src]
Sets the package.name
of the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::CargoToml; let cargo_toml = CargoToml::new() .name("my-rust-project") .build()?; /* [package] name = "my-rust-project" */
pub fn author(&mut self, author: &str) -> &mut Self
[src]
Add an author to the package.authors
property
Note: This will append an entry to the underlying Vec, it will not affect any other
author
s that have been set
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .author("Me <me@me.com>") .build()?; /* [package] authors = ["Me <me@me.com>"] */
pub fn authors(&mut self, authors: &[String]) -> &mut Self
[src]
Set the list of authors for the package.authors
property
Note: This will replace any existing list of authors
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .authors(&[ "Me <me@me.com>".into(), "You <you@you.com>".into() ]) .build()?; /* [package] authors = ["Me <me@me.com>", "You <you@you.com>"] */
pub fn version(&mut self, version: &str) -> &mut Self
[src]
Sets the package.version
of the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .version("1.1.0") .build()?; /* [package] version = "1.1.0" */
pub fn build_script(&mut self, build: &str) -> &mut Self
[src]
Sets the package.build
property of the project
TODO: currently impossible to generate build = false
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .build_script("./my-build-script.rs") .build()?; /* [package] build = "./my-build-script" */
pub fn documentation(&mut self, documentation: &str) -> &mut Self
[src]
Sets the package.documentation
property of the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .documentation("https://docs.rs/my-project") .build()?; /* [package] documentation = "https://docs.rs/my-project" */
pub fn exclude(&mut self, exclude: &str) -> &mut Self
[src]
Adds an exclusion pattern to the package.exclude
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .exclude("build/**/*.o") .build()?; /* [package] exclude = ["build/**/*.o"] */
pub fn excludes(&mut self, excludes: &[String]) -> &mut Self
[src]
Sets the list of exclusion patterns for the package.exclude
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .excludes(&[ "build/**/*.o".into(), "doc/**/*.html".into(), ]) .build()?; /* [package] exclude = ["build/**/*.o", "doc/**/*.html"] */
pub fn include(&mut self, include: &str) -> &mut Self
[src]
Adds an inclusion pattern to the package.include
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .include("src/**/*") .build()?; /* [package] include = ["src/**/*"] */
pub fn includes(&mut self, includes: &[String]) -> &mut Self
[src]
Sets the inclusion patterns for the package.include
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .includes(&[ "src/**/*".into(), "Cargo.toml".into(), ]) .build()?; /* [package] include = ["src/**/*.html, "Cargo.toml"] */
pub fn publish(&mut self, publish: bool) -> &mut Self
[src]
Sets the package.publish
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .publish(false) .build()?; /* [package] publish = false */
pub fn workspace_root(&mut self, workspace_root: &str) -> &mut Self
[src]
Sets the package.workspace
property
(this is the workspace = "/path/to/workspace"
property, not be be confused with the
[workspace]
table that can also be added to the document)
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .workspace_root("/path/to/workspace/root") .build()?; /* [package] workspace = "/path/to/workspace/root" */
pub fn description(&mut self, description: &str) -> &mut Self
[src]
Sets the package.description
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .description("This is my new Rust project") .build()?; /* [package] description = "This is my new Rust project" */
pub fn homepage(&mut self, homepage: &str) -> &mut Self
[src]
Sets the package.homepage
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .homepage("https://my.domain/") .build()?; /* [package] homepage = "https://my.domain/" */
pub fn repository(&mut self, repository: &str) -> &mut Self
[src]
Sets the package.repository
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .repository("https://gitlab.com/me/my-project") .build()?; /* [package] repository = "https://gitlab.com/me/my-project" */
pub fn readme(&mut self, readme: &str) -> &mut Self
[src]
Sets the package.readme
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .readme("README.adoc") .build()?; /* [package] readme = "README.adoc" */
pub fn keyword(&mut self, keyword: &str) -> &mut Self
[src]
Adds a keyword to the package.keywords
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .keyword("async") .build()?; /* [package] keywords = ["async"] */
pub fn keywords(&mut self, keywords: &[String]) -> &mut Self
[src]
Sets the list of keywords for the package.keywords
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .keywords(&[ "async".into(), "networking".into(), ]) .build()?; /* [package] keywords = ["async", "networking"] */
pub fn category(&mut self, category: &str) -> &mut Self
[src]
Adds a category to the package.categories
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .category("filesystem") .build()?; /* [package] categories = ["filesystem"] */
pub fn categories(&mut self, categories: &[String]) -> &mut Self
[src]
Sets the list of categories for the package.categories
property
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .categories(&[ "filesystem".into(), "testing".into(), ]) .build()?; /* [package] categories = ["filesystem", "testing"] */
pub fn license<L: Into<License>>(&mut self, license: L) -> &mut Self
[src]
Adds a license to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .license(License::Mit) .build()?; /* [package] license = "MIT" */
pub fn licenses<L: Into<License> + Clone>(
&mut self,
licenses: &[L]
) -> &mut Self
[src]
&mut self,
licenses: &[L]
) -> &mut Self
Sets a list of licenses for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .licenses(&[ License::Mit, License::Apache2, ]) .build()?; /* [package] license = "MIT/Apache-2.0" */
pub fn license_file(&mut self, license_file: &str) -> &mut Self
[src]
Sets the location for the license file of the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .license_file("LICENSE") .build()?; /* [package] license-file = "LICENSE" */
pub fn appveyor<A: Into<Appveyor>>(&mut self, appveyor: A) -> &mut Self
[src]
Sets the badges.appveyor
table for the project
You can import the "Appveyor" struct from cargo_toml_builder::types
, but this method will
take anything that implements Into<Appveyor>
, which String
and &str
do. So if all you
want is to add the repo, you can just pass some kind of string to this method and it should
Just Work.
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::Appveyor; let appveyor_badge = Appveyor::new("https://gitlab.com/me/my-project"); let cargo_toml = CargoToml::new() .appveyor(appveyor_badge) // or this will also work, and result in the same output: // .appveyor("https://gitlab.com/me/my-project") .build()?; /* [badges] appveyor = { repository = "https://gitlab.com/me/my-project" } */
pub fn circle_ci<C: Into<CircleCi>>(&mut self, circle_ci: C) -> &mut Self
[src]
Sets the badges.circle-ci
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::CircleCi; let circe_ci_badge = CircleCi::new("https://gitlab.com/me/my-project"); let cargo_toml = CargoToml::new() .circle_ci(circe_ci_badge) .build()?; /* [badges] circle-ci = { repository = "https://gitlab.com/me/my-project" } */
pub fn gitlab<G: Into<Gitlab>>(&mut self, gitlab: G) -> &mut Self
[src]
Sets the badges.gitlab
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::Gitlab; let gitlab_badge = Gitlab::new("https://gitlab.com/me/my-project"); let cargo_toml = CargoToml::new() .gitlab(gitlab_badge) .build()?; /* [badges] gitlab = { repository = "https://gitlab.com/me/my-project" } */
pub fn travis_ci<T: Into<TravisCi>>(&mut self, travis_ci: T) -> &mut Self
[src]
Sets the badges.travis-ci
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::TravisCi; let travis_ci_badge = TravisCi::new("https://gitlab.com/me/my-project"); let cargo_toml = CargoToml::new() .travis_ci(travis_ci_badge) .build()?; /* [badges] travis-ci = { repository = "https://gitlab.com/me/my-project" } */
pub fn codecov<C: Into<Codecov>>(&mut self, codecov: C) -> &mut Self
[src]
Sets the badges.codecov
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::Codecov; let codecov_badge = Codecov::new("https://gitlab.com/me/my-project"); let cargo_toml = CargoToml::new() .codecov(codecov_badge) .build()?; /* [badges] codecov = { repository = "https://gitlab.com/me/my-project" } */
pub fn coveralls<C: Into<Coveralls>>(&mut self, coveralls: C) -> &mut Self
[src]
Sets the badges.coveralls
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::Coveralls; let coveralls_badge = Coveralls::new("https://gitlab.com/me/my-project"); let cargo_toml = CargoToml::new() .coveralls(coveralls_badge) .build()?; /* [badges] coveralls = { repository = "https://gitlab.com/me/my-project" } */
pub fn is_it_maintained_time(&mut self, time: &str) -> &mut Self
[src]
Sets the badges.is-it-maintained-issue-resolution
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::Coveralls; let cargo_toml = CargoToml::new() .is_it_maintained_time("https://gitlab.com/me/my-project") .build()?; /* [badges] is-it-maintained-issue-resolution = { repository = "https://gitlab.com/me/my-project" } */
pub fn is_it_maintained_issues(&mut self, issues: &str) -> &mut Self
[src]
Sets the badges.is-it-maintained-open-issues
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::Coveralls; let cargo_toml = CargoToml::new() .is_it_maintained_issues("https://gitlab.com/me/my-project") .build()?; /* [badges] is-it-maintained-open-issues = { repository = "https://gitlab.com/me/my-project" } */
pub fn maintenance<M: Into<MaintenanceStatus>>(
&mut self,
maintenance: M
) -> &mut Self
[src]
&mut self,
maintenance: M
) -> &mut Self
Sets the badges.maintenance
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::MaintenanceStatus; let cargo_toml = CargoToml::new() .maintenance(MaintenanceStatus::AsIs) .build()?; /* [badges] maintenance = { status = "as-is" } */
pub fn dependency<D: Into<Dependency>>(&mut self, dependency: D) -> &mut Self
[src]
Adds a dependency to the dependencies
table
The Dependency
struct is imported through the prelude, but you can also pass anything to
this that implements Into<Dependency>
which String
and &str
do. If you pass a string
to this method, it will add a regular crate dependency, with version "*"
. You can use the
extension methods from DependencyExt
to use a string to
construct a Dependency
object.
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .dependency("env_logger".version("0.5.6")) .build()?; /* [dependencies] env_logger = "0.5.6" */
pub fn dependencies<D: Into<Dependency> + Clone>(
&mut self,
dependencies: &[D]
) -> &mut Self
[src]
&mut self,
dependencies: &[D]
) -> &mut Self
Set the dependencies
table for the project
Note: This will replace any dependencies current attached to the object
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .dependencies(&[ "env_logger".version("0.5.6"), "tokio".version("0.2"), ]) .build()?; /* [dependencies] env_logger = "0.5.6" tokio = "0.2" */
pub fn dev_dependency<D: Into<Dependency>>(
&mut self,
dependency: D
) -> &mut Self
[src]
&mut self,
dependency: D
) -> &mut Self
Add a dev-dependencies
entry to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .dev_dependency("hamcrest".version("0.1.5")) .build()?; /* [dev-dependencies] hamcrest = "0.1.5" */
pub fn dev_dependencies<D: Into<Dependency> + Clone>(
&mut self,
dependencies: &[D]
) -> &mut Self
[src]
&mut self,
dependencies: &[D]
) -> &mut Self
Set the list of dev-dependencies
for the project
Note: This will replace any dev-dependencies currently attached to the object
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .dev_dependencies(&[ "hamcrest".version("0.1.5"), "my-test-lib".path("../my-test-lib") ]) .build()?; /* [dev-dependencies] hamcrest = "0.1.5" my-test-lib = { path = "../my-test-lib" } */
pub fn build_dependency<D: Into<Dependency>>(
&mut self,
dependency: D
) -> &mut Self
[src]
&mut self,
dependency: D
) -> &mut Self
Add an entry to the build-dependencies
table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .build_dependency("gcc".version("0.3.54")) .build()?; /* [build-dependencies] gcc = "0.3.54" */
pub fn build_dependencies<D: Into<Dependency> + Clone>(
&mut self,
dependencies: &[D]
) -> &mut Self
[src]
&mut self,
dependencies: &[D]
) -> &mut Self
Set the list of build-dependencies
for the project
Note: this will replace any build dependencies currently attached to the object
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .build_dependencies(&[ "gcc".version("0.3.54"), "cmake".version("0.1.29"), ]) .build()?; /* [build-dependencies] gcc = "0.3.54" cmake = "0.1.29" */
pub fn target_dependency<D: Into<Dependency>>(
&mut self,
name: &str,
dependency: D
) -> &mut Self
[src]
&mut self,
name: &str,
dependency: D
) -> &mut Self
Add a dependency to a target
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .target_dependency("cfg(unix)", "openssl".version("1.0.1")) .build()?; /* [target."cfg(unix)".dependencies] openssl = "1.0.1" */
pub fn target_dependencies<D: Into<Dependency> + Clone>(
&mut self,
name: &str,
dependencies: &[D]
) -> &mut Self
[src]
&mut self,
name: &str,
dependencies: &[D]
) -> &mut Self
Set the dependency list for a target
Note: This will replace any dependencies current attached to the target
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .target_dependencies("cfg(unix)", &[ "openssl".version("1.0.1"), "libc".version("0.2.40"), ]) .build()?; /* [target."cfg(unix)".dependencies] openssl = "1.0.1" libc = "0.2.40" */
pub fn profile_dev(&mut self, profile_dev: Profile) -> &mut Self
[src]
Set the properties of the dev profile
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::{Profile, PanicStrategy}; let profile = Profile::new().panic(PanicStrategy::Abort).build(); let cargo_toml = CargoToml::new() .profile_dev(profile) .build()?; /* [profile.dev] panic = "abort" */
pub fn profile_release(&mut self, profile_dev: Profile) -> &mut Self
[src]
Set the properties of the release profile
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::{Profile, PanicStrategy}; let profile = Profile::new().panic(PanicStrategy::Abort).build(); let cargo_toml = CargoToml::new() .profile_release(profile) .build()?; /* [profile.release] panic = "abort" */
pub fn profile_test(&mut self, profile_dev: Profile) -> &mut Self
[src]
Set the properties of the test profile
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::{Profile, PanicStrategy}; let profile = Profile::new().panic(PanicStrategy::Abort).build(); let cargo_toml = CargoToml::new() .profile_test(profile) .build()?; /* [profile.test] panic = "abort" */
pub fn profile_bench(&mut self, profile_dev: Profile) -> &mut Self
[src]
Set the properties of the bench profile
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::{Profile, PanicStrategy}; let profile = Profile::new().panic(PanicStrategy::Abort).build(); let cargo_toml = CargoToml::new() .profile_bench(profile) .build()?; /* [profile.bench] panic = "abort" */
pub fn profile_doc(&mut self, profile_dev: Profile) -> &mut Self
[src]
Set the properties of the doc profile
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::{Profile, PanicStrategy}; let profile = Profile::new().panic(PanicStrategy::Abort).build(); let cargo_toml = CargoToml::new() .profile_doc(profile) .build()?; /* [profile.doc] panic = "abort" */
pub fn feature<F: Into<Feature>>(&mut self, feature: F) -> &mut Self
[src]
Add a feature to the project
The user can attach dependencies, and the labels for other features, to a Feature
object.
If a Dependency is added, it will automatically be added to the [dependencies]
section of
the document with the optional = true
option added. If you need different behavior, add
the name of the dependency using the .feature
builder method and add the dependency to
the correct section manually.
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let nightly = Feature::new("nightly").dependency("clippy".version("0.0.191")).build(); let cargo_toml = CargoToml::new() .feature(nightly) .build()?; /* [features] nightly = ['clippy'] [dependencies] clippy = { version = "0.0.191", optional = true } */
Or, to add a feature dependency to, say, [dev-dependencies]
:
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let nightly = Feature::new("nightly").feature("clippy").build(); let cargo_toml = CargoToml::new() .feature(nightly) .dev_dependency("clippy".version("0.0.191").optional(true)) .build()?; /* [features] nightly = ['clippy'] [dev-dependencies] clippy = { version = "0.0.191", optional = true } */
pub fn workspace(&mut self, workspace: Workspace) -> &mut Self
[src]
Set the workspace config table for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::Workspace; let workspace = Workspace::new().member("/path/to/member1").build(); let cargo_toml = CargoToml::new() .workspace(workspace) .build()?; /* [workspace] members = ["/path/to/member1"] */
pub fn lib<T: Into<LibTarget>>(&mut self, target: T) -> &mut Self
[src]
Set a [lib]
target for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let target = LibTarget::new().name("my-lib").path("src/my-lib.rs").build(); let cargo_toml = CargoToml::new() .lib(target) .build()?; /* [lib] name = "my-lib" path = "src/my-lib.rs" */
pub fn bin<T: Into<BinTarget>>(&mut self, target: T) -> &mut Self
[src]
Add a [[bin]]
target for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let target = BinTarget::new().name("my-bin").path("src/bin/my-bin.rs").build(); let cargo_toml = CargoToml::new() .bin(target) .build()?; /* [dependencies] <name> = <value> */
pub fn bins(&mut self, target: &[BinTarget]) -> &mut Self
[src]
Set the [[bin]]
targets for the project
Note: This will replace any bin targets currently attached to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .bins(&[ BinTarget::new().name("my-bin-1").path("src/bin/my-bin-1.rs").build(), BinTarget::new().name("my-bin-2").path("src/bin/my-bin-2.rs").build(), ]) .build()?; /* [dependencies] <name> = <value> */
pub fn bench<T: Into<BenchTarget>>(&mut self, target: T) -> &mut Self
[src]
Add a [bench]
target for the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let target = BenchTarget::new().name("my-benchmark").path("bench/my-benchmark.rs").build(); let cargo_toml = CargoToml::new() .bench(target) .build()?; /* [dependencies] <name> = <value> */
pub fn benches(&mut self, target: &[BenchTarget]) -> &mut Self
[src]
Set the list of [[bench]]
targets for the project
Note: This will replace any bench targets currently attached to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .benches(&[ BenchTarget::new().name("my-benchmark-1").path("bench/my-benchmark-1.rs").build(), BenchTarget::new().name("my-benchmark-2").path("bench/my-benchmark-2.rs").build(), ]) .build()?; /* [[bench]] name = "my-benchmark-1" path = "bench/my-benchmark-1.rs" [[bench]] name = "my-benchmark-2" path = "bench/my-benchmark-2.rs" */
pub fn test<T: Into<TestTarget>>(&mut self, target: T) -> &mut Self
[src]
Add a [[test]]
target to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let target = TestTarget::new().name("my-test").path("tests/my-test.rs").build(); let cargo_toml = CargoToml::new() .test(target) .build()?; /* [[test]] name = "my-test" path = "tests/my-test.rs" */
pub fn tests(&mut self, target: &[TestTarget]) -> &mut Self
[src]
Set the [[test]]
targets for the project
Note: This will replace any test targets currently attached to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .tests(&[ TestTarget::new().name("my-test-1").path("tests/my-test-1.rs").build(), TestTarget::new().name("my-test-2").path("tests/my-test-2.rs").build(), ]) .build()?; /* [[test]] name = "my-test-1" path = "tests/my-test-1.rs" [[test]] name = "my-test-2" path = "tests/my-test-2.rs" */
pub fn example<T: Into<ExampleTarget>>(&mut self, target: T) -> &mut Self
[src]
Add an [[example]]
target to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let target = ExampleTarget::new().name("my-example").path("examples/my-example.rs").build(); let cargo_toml = CargoToml::new() .example(target) .build()?; /* [[example]] name = "my-example" path = "examples/my-example.rs" */
pub fn examples(&mut self, target: &[ExampleTarget]) -> &mut Self
[src]
Set the list of [[example]]
targets for the project
Note: This will replace any [[example]]
targets currently attached to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .examples(&[ ExampleTarget::new().name("my-example-1").path("examples/my-example-1.rs").build(), ExampleTarget::new().name("my-example-2").path("examples/my-example-2.rs").build(), ]) .build()?; /* [[example]] name = "my-example-1" path = "examples/my-example-1.rs" [[example]] name = "my-example-2" path = "examples/my-example-2.rs" */
pub fn patch(&mut self, patch: PatchSet) -> &mut Self
[src]
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::PatchSet; let patchset = PatchSet::new("crates-io") .patch("env_logger".repo("https://gitlab.com/me/env_logger.git")) .build(); let cargo_toml = CargoToml::new() .patch(patchset) .build()?; /* [patch.crates-io] env_logger = { git = "https://gitlab.com/me/env_logger.git" } */
pub fn patches(&mut self, patches: &[PatchSet]) -> &mut Self
[src]
Set the list of patch sets for the project
Note: This will replace any patch sets currently attached to the object
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; use cargo_toml_builder::types::PatchSet; let cargo_toml = CargoToml::new() .patches(&[ PatchSet::new("crates-io") .patch("env_logger".repo("https://gitlab.com/me/env_logger.git")) .build(), PatchSet::new("https://github.com/example/baz") .patch("baz".repo("https://github.com/example/patched-baz")) .build(), ]) .build()?; /* [patch.crates-io] env_logger = { git = "https://gitlab.com/me/env_logger.git" } [patch."https://github.com/example/baz"] baz = { git = "https://github.com/example/patched-baz" } */
pub fn replace<D: Into<Dependency>>(&mut self, dependency: D) -> &mut Self
[src]
Add a [replace]
entry to the project
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .replace("foo:0.1.0".repo("https://github.com/example/foo")) .build()?; /* [replace] "foo:0.1.0" = { git = "https://github.com/example/foo" } */
pub fn build(&self) -> Result<Document, Error>
[src]
Build a toml_edit::Document
object from this builder
Example
extern crate cargo_toml_builder; use cargo_toml_builder::prelude::*; let cargo_toml = CargoToml::new() .name("my-project") .author("Me <me@me.com>") .build()?; /* [package] name = "my-project" version = "0.1.0" authors = ["Me <me@me.com>"] [dependencies] */
Trait Implementations
impl Default for CargoToml
[src]
impl Clone for CargoToml
[src]
fn clone(&self) -> CargoToml
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<CargoToml> for CargoToml
[src]
impl Debug for CargoToml
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,