'\" t .TH "CARGO\-METADATA" "1" .nh .ad l .ss \n[.ss] 0 .SH "نام (NAME)" cargo\-metadata \- متاداده‌های ماشین‌خوان درباره بسته کنونی .SH "خلاصه دستور (SYNOPSIS)" \fBcargo metadata\fR [\fIگزینه‌ها\fR] .SH "توضیحات (DESCRIPTION)" اطلاعات مربوط به اعضای فضای کاری (workspace) و وابستگی‌های حل‌شدهٔ بستهٔ کنونی را در قالب JSON در خروجی استاندارد (stdout) نمایش می‌دهد. .sp قالب خروجی ممکن است در نسخه‌های آیندهٔ Cargo تغییر کند. توصیه می‌شود گزینهٔ \fB\-\-format\-version\fR را مشخص کنید تا کدهای شما در آینده نیز سازگار بمانند و اطمینان حاصل شود که خروجی در قالب مورد انتظار شماست. برای اطلاعات بیشتر در مورد انتظارات، بخش \[lq]سازگاری (Compatibility)\[rq]\& را ببینید. .sp برای دسترسی به یک API در Rust جهت خواندن متاداده‌ها، \fIکریت cargo_metadata\fR را ببینید. .SH "قالب خروجی (OUTPUT FORMAT)" .SS "سازگاری (Compatibility)" در یک نسخهٔ یکسان از قالب خروجی، سازگاری حفظ می‌شود؛ مگر در برخی سناریوها. موارد زیر فهرستی غیرجامع از تغییراتی است که ناسازگار تلقی نمی‌شوند: .sp .RS 4 \h'-04'\(bu\h'+03'\fBافزودن فیلدهای جدید\fR \[em] فیلدهای جدید در صورت نیاز اضافه خواهند شد. محفوظ داشتن این امکان به Cargo کمک می‌کند تا بدون نیاز به ارتقای مکرر نسخهٔ قالب، تکامل یابد. .RE .sp .RS 4 \h'-04'\(bu\h'+03'\fBافزودن مقادیر جدید برای فیلدهای مشابه enum\fR \[em] مشابه افزودن فیلدهای جدید است و باعث می‌شود متاداده‌ها بدون درجا زدن تکامل یابند. .RE .sp .RS 4 \h'-04'\(bu\h'+03'\fBتغییر نمایش‌های مات (opaque representations)\fR \[em] ساختار درونی برخی از فیلدها جزو جزئیات پیاده‌سازی هستند. برای نمونه، فیلدهای مربوط به \[lq]Source ID\[rq] به‌عنوان شناسه‌های مات برای تمایز بسته‌ها یا منابع در نظر گرفته می‌شوند. مصرف‌کنندگان نباید به این نمایش‌ها اتکا کنند، مگر اینکه صراحتاً مشخص شده باشد. .RE .SS "قالب JSON (JSON format)" خروجی JSON دارای قالب زیر است: .sp .RS 4 .nf { /* Array of all packages in the workspace. It also includes all feature\-enabled dependencies unless \-\-no\-deps is used. */ "packages": [ { /* The name of the package. */ "name": "my\-package", /* The version of the package. */ "version": "0.1.0", /* The Package ID for referring to the package within the document and as the `\-\-package` argument to many commands */ "id": "file:///path/to/my\-package#0.1.0", /* The license value from the manifest, or null. */ "license": "MIT/Apache\-2.0", /* The license\-file value from the manifest, or null. */ "license_file": "LICENSE", /* The description value from the manifest, or null. */ "description": "Package description.", /* The source ID of the package, an "opaque" identifier representing where a package is retrieved from. See "Compatibility" above for the stability guarantee. This is null for path dependencies and workspace members. For other dependencies, it is a string with the format: \- "registry+URL" for registry\-based dependencies. Example: "registry+https://github.com/rust\-lang/crates.io\-index" \- "git+URL" for git\-based dependencies. Example: "git+https://github.com/rust\-lang/cargo?rev=5e85ba14aaa20f8133863373404cb0af69eeef2c#5e85ba14aaa20f8133863373404cb0af69eeef2c" \- "sparse+URL" for dependencies from a sparse registry Example: "sparse+https://my\-sparse\-registry.org" The value after the `+` is not explicitly defined, and may change between versions of Cargo and may not directly correlate to other things, such as registry definitions in a config file. New source kinds may be added in the future which will have different `+` prefixed identifiers. */ "source": null, /* Array of dependencies declared in the package's manifest. */ "dependencies": [ { /* The name of the dependency. */ "name": "bitflags", /* The source ID of the dependency. May be null, see description for the package source. */ "source": "registry+https://github.com/rust\-lang/crates.io\-index", /* The version requirement for the dependency. Dependencies without a version requirement have a value of "*". */ "req": "^1.0", /* The dependency kind. "dev", "build", or null for a normal dependency. */ "kind": null, /* If the dependency is renamed, this is the new name for the dependency as a string. null if it is not renamed. */ "rename": null, /* Boolean of whether or not this is an optional dependency. */ "optional": false, /* Boolean of whether or not default features are enabled. */ "uses_default_features": true, /* Array of features enabled. */ "features": [], /* The target platform for the dependency. null if not a target dependency. */ "target": "cfg(windows)", /* The file system path for a local path dependency. not present if not a path dependency. */ "path": "/path/to/dep", /* A string of the URL of the registry this dependency is from. If not specified or null, the dependency is from the default registry (crates.io). */ "registry": null, /* (unstable) Boolean flag of whether or not this is a pulbic dependency. This field is only present when `\-Zpublic\-dependency` is enabled. */ "public": false } ], /* Array of Cargo targets. */ "targets": [ { /* Array of target kinds. \- lib targets list the `crate\-type` values from the manifest such as "lib", "rlib", "dylib", "proc\-macro", etc. (default ["lib"]) \- binary is ["bin"] \- example is ["example"] \- integration test is ["test"] \- benchmark is ["bench"] \- build script is ["custom\-build"] */ "kind": [ "bin" ], /* Array of crate types. \- lib and example libraries list the `crate\-type` values from the manifest such as "lib", "rlib", "dylib", "proc\-macro", etc. (default ["lib"]) \- all other target kinds are ["bin"] */ "crate_types": [ "bin" ], /* The name of the target. For lib targets, dashes will be replaced with underscores. */ "name": "my\-package", /* Absolute path to the root source file of the target. */ "src_path": "/path/to/my\-package/src/main.rs", /* The Rust edition of the target. Defaults to the package edition. */ "edition": "2018", /* Array of required features. This property is not included if no required features are set. */ "required\-features": ["feat1"], /* Whether the target should be documented by `cargo doc`. */ "doc": true, /* Whether or not this target has doc tests enabled, and the target is compatible with doc testing. */ "doctest": false, /* Whether or not this target should be built and run with `\-\-test` */ "test": true } ], /* Set of features defined for the package. Each feature maps to an array of features or dependencies it enables. */ "features": { "default": [ "feat1" ], "feat1": [], "feat2": [] }, /* Absolute path to this package's manifest. */ "manifest_path": "/path/to/my\-package/Cargo.toml", /* Package metadata. This is null if no metadata is specified. */ "metadata": { "docs": { "rs": { "all\-features": true } } }, /* List of registries to which this package may be published. Publishing is unrestricted if null, and forbidden if an empty array. */ "publish": [ "crates\-io" ], /* Array of authors from the manifest. Empty array if no authors specified. */ "authors": [ "Jane Doe " ], /* Array of categories from the manifest. */ "categories": [ "command\-line\-utilities" ], /* Optional string that is the default binary picked by cargo run. */ "default_run": null, /* Optional string that is the minimum supported rust version */ "rust_version": "1.56", /* Array of keywords from the manifest. */ "keywords": [ "cli" ], /* The readme value from the manifest or null if not specified. */ "readme": "README.md", /* The repository value from the manifest or null if not specified. */ "repository": "https://github.com/rust\-lang/cargo", /* The homepage value from the manifest or null if not specified. */ "homepage": "https://rust\-lang.org", /* The documentation value from the manifest or null if not specified. */ "documentation": "https://doc.rust\-lang.org/stable/std", /* The default edition of the package. Note that individual targets may have different editions. */ "edition": "2018", /* Optional string that is the name of a native library the package is linking to. */ "links": null, } ], /* Array of members of the workspace. Each entry is the Package ID for the package. */ "workspace_members": [ "file:///path/to/my\-package#0.1.0", ], /* Array of default members of the workspace. Each entry is the Package ID for the package. */ "workspace_default_members": [ "file:///path/to/my\-package#0.1.0", ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. // // This is null if \-\-no\-deps is specified. // // By default, this includes all dependencies for all target platforms. // The `\-\-filter\-platform` flag may be used to narrow to a specific // target triple. "resolve": { /* Array of nodes within the dependency graph. Each node is a package. */ "nodes": [ { /* The Package ID of this node. */ "id": "file:///path/to/my\-package#0.1.0", /* The dependencies of this package, an array of Package IDs. */ "dependencies": [ "https://github.com/rust\-lang/crates.io\-index#bitflags@1.0.4" ], /* The dependencies of this package. This is an alternative to "dependencies" which contains additional information. In particular, this handles renamed dependencies. */ "deps": [ { /* The name of the dependency's library target. If this is a renamed dependency, this is the new name. */ "name": "bitflags", /* The Package ID of the dependency. */ "pkg": "https://github.com/rust\-lang/crates.io\-index#bitflags@1.0.4" /* Array of dependency kinds. Added in Cargo 1.40. */ "dep_kinds": [ { /* The dependency kind. "dev", "build", or null for a normal dependency. */ "kind": null, /* The target platform for the dependency. null if not a target dependency. */ "target": "cfg(windows)" } ] } ], /* Array of features enabled on this package. */ "features": [ "default" ] } ], /* The package in the current working directory (if \-\-manifest\-path is not given). This is null if there is a virtual workspace. Otherwise it is the Package ID of the package. */ "root": "file:///path/to/my\-package#0.1.0", }, /* The absolute path to the target directory where Cargo places its output. */ "target_directory": "/path/to/my\-package/target", /* The absolute path to the build directory where Cargo places intermediate build artifacts. (unstable) */ "build_directory": "/path/to/my\-package/build\-dir", /* The version of the schema for this metadata structure. This will be changed if incompatible changes are ever made. */ "version": 1, /* The absolute path to the root of the workspace. */ "workspace_root": "/path/to/my\-package" /* Workspace metadata. This is null if no metadata is specified. */ "metadata": { "docs": { "rs": { "all\-features": true } } } } .fi .RE .sp نکات: .sp .RS 4 \h'-04'\(bu\h'+03'برای ساختار نحوی فیلد \fB"id"\fR، بخش \fIPackage ID Specifications\fR را در مرجع ببینید. .RE.SH "گزینه‌ها (OPTIONS)" .SS "گزینه‌های خروجی (Output Options)" .sp \fB\-\-no\-deps\fR .RS 4 اطلاعات را تنها دربارهٔ اعضای فضای کاری (workspace) خروجی می‌دهد و وابستگی‌ها را دریافت نمی‌کند. .RE .sp \fB\-\-format\-version\fR \fIversion\fR .RS 4 نسخهٔ قالب خروجی مورد استفاده را تعیین می‌کند. در حال حاضر تنها مقدار ممکن \fB1\fR است. .RE .sp \fB\-\-filter\-platform\fR \fItriple\fR .RS 4 این گزینه خروجی \fBresolve\fR را فیلتر می‌کند تا تنها شامل وابستگی‌های مربوط به \fItarget triple\fR \& مشخص‌شده باشد. می‌توان از مقدار عینی \fB"host\-tuple"\fR استفاده کرد که در داخل برنامه با هدف (target) میزبان جایگزین خواهد شد. بدون این پرچم، خروجی resolve شامل تمام هدف‌ها خواهد بود. .sp توجه داشته باشید که وابستگی‌های فهرست‌شده در آرایهٔ \[lq]packages\[rq] همچنان شامل تمام وابستگی‌ها است. تعریف هر بسته به این منظور است که بازتولید بدون تغییری از اطلاعات درون \fBCargo.toml\fR باشد. .RE .SS "انتخاب ویژگی‌ها (Feature Selection)" پرچم‌های ویژگی به شما امکان می‌دهند تا فعال بودن ویژگی‌ها را کنترل کنید. هنگامی که هیچ گزینهٔ ویژگی‌ای داده نشود، ویژگی \fBdefault\fR برای هر بستهٔ انتخاب‌شده فعال می‌شود. .sp برای جزئیات بیشتر، \fIمستندات ویژگی‌ها\fR را ببینید. .sp \fB\-F\fR \fIfeatures\fR, \fB\-\-features\fR \fIfeatures\fR .RS 4 فهرستی از ویژگی‌ها برای فعال‌سازی که با فاصله یا کاما از یکدیگر جدا شده‌اند. ویژگی‌های اعضای فضای کاری می‌توانند با نحوِ \fBpackage\-name/feature\-name\fR فعال شوند. این پرچم را می‌توان چندین بار مشخص کرد که در این صورت تمام ویژگی‌های مشخص‌شده فعال می‌شوند. .RE .sp \fB\-\-all\-features\fR .RS 4 تمامی ویژگی‌های دردسترسِ همهٔ بسته‌های انتخاب‌شده را فعال می‌کند. .RE .sp \fB\-\-no\-default\-features\fR .RS 4 ویژگی \fBdefault\fR بسته‌های انتخاب‌شده را فعال نمی‌کند. .RE .SS "گزینه‌های نمایش (Display Options)" .sp \fB\-v\fR, \fB\-\-verbose\fR .RS 4 استفاده از خروجی پرگو (verbose). می‌تواند دو بار برای خروجی \[lq]بسیار پرگو\[rq] مشخص شود که شامل خروجی‌های اضافی مانند هشدارهای وابستگی و خروجی اسکریپت ساخت است. همچنین می‌تواند با \fIمقدار پیکربندی\fR \fBterm.verbose\fR \& تعیین شود. .RE .sp \fB\-q\fR, \fB\-\-quiet\fR .RS 4 پیام‌های گزارش (log) ابزار cargo را چاپ نمی‌کند. همچنین می‌تواند با \fIمقدار پیکربندی\fR \fBterm.quiet\fR \& تعیین شود. .RE .sp \fB\-\-color\fR \fIwhen\fR .RS 4 زمان استفاده از خروجی رنگی را کنترل می‌کند. مقادیر معتبر: .sp .RS 4 \h'-04'\(bu\h'+03'\fBauto\fR (پیش‌فرض): تشخیص خودکار اینکه آیا پشتیبانی از رنگ در ترمینال موجود است یا خیر. .RE .sp .RS 4 \h'-04'\(bu\h'+03'\fBalways\fR: همیشه رنگ‌ها را نمایش می‌دهد. .RE .sp .RS 4 \h'-04'\(bu\h'+03'\fBnever\fR: هرگز رنگ‌ها را نمایش نمی‌دهد. .RE .sp همچنین می‌تواند با \fIمقدار پیکربندی\fR \fBterm.color\fR \& تعیین شود. .RE .SS "گزینه‌های مانیفست (Manifest Options)" .sp \fB\-\-manifest\-path\fR \fIpath\fR .RS 4 مسیر فایل \fBCargo.toml\fR. به‌طور پیش‌فرض، Cargo فایل \fBCargo.toml\fR را در دایرکتوری جاری یا هر دایرکتوری والد جستجو می‌کند. .RE .sp \fB\-\-locked\fR .RS 4 تضمین می‌کند که دقیقاً از همان وابستگی‌ها و نسخه‌هایی استفاده شود که هنگام ایجاد اولیهٔ فایل موجودِ \fBCargo.lock\fR ایجاد شده بودند. در صورت بروز هر یک از موارد زیر، Cargo با خطا خارج خواهد شد: .sp .RS 4 \h'-04'\(bu\h'+03'فایل lock موجود نباشد. .RE .sp .RS 4 \h'-04'\(bu\h'+03'ابزار Cargo به دلیل حلِ متفاوت وابستگی‌ها، برای تغییر فایل lock تلاش کند. .RE .sp این گزینه می‌تواند در محیط‌هایی که ساخت‌های قطعی (deterministic builds) مورد نظر است، مانند خطوط لولهٔ CI، استفاده شود. .RE .sp \fB\-\-offline\fR .RS 4 از دسترسی Cargo به شبکه به هر دلیلی جلوگیری می‌کند. بدون این پرچم، اگر Cargo نیاز به دسترسی به شبکه داشته باشد و شبکه در دسترس نباشد، با خطا متوقف خواهد شد. با این پرچم، Cargo در صورت امکان تلاش می‌کند بدون شبکه به کار خود ادامه دهد. .sp توجه داشته باشید که این ممکن است به حل وابستگی متفاوتی نسبت به حالت برخط منجر شود. Cargo خود را به crateهایی محدود می‌کند که به‌صورت محلی بارگیری شده‌اند، حتی اگر طبق نسخهٔ محلی نمایه (index)، نسخهٔ جدیدتری وجود داشته باشد. دستور \fBcargo\-fetch\fR(1) را برای بارگیری وابستگی‌ها پیش از رفتن به حالت آفلاین ببینید. .sp همچنین می‌تواند با \fIمقدار پیکربندی\fR \fBnet.offline\fR \& تعیین شود. .RE .sp \fB\-\-frozen\fR .RS 4 معادل تعیین هم‌زمان \fB\-\-locked\fR و \fB\-\-offline\fR\& است. .RE.SS "گزینه‌های مشترک (Common Options)" .sp \fB+\fR\fItoolchain\fR .RS 4 اگر Cargo به‌همراه rustup نصب شده باشد و نخستین آرگومان برای \fBcargo\fR با \fB+\fR آغاز شود، به‌عنوان نام زنجیره‌ابزار rustup (مانند \fB+stable\fR یا \fB+nightly\fR) تفسیر خواهد شد. برای اطلاعات بیشتر درباره چگونگی کارکرد بازنویسی‌های زنجیره‌ابزار، \fIمستندات rustup\fR را ببینید. .RE .sp \fB\-\-config\fR \fIKEY=VALUE\fR یا \fIPATH\fR .RS 4 یک مقدار پیکربندی Cargo را بازنویسی می‌کند. آرگومان باید در ساختار نحو TOML به‌صورت \fBKEY=VALUE\fR بوده یا به‌عنوان مسیری به یک فایل پیکربندی اضافی ارائه شود. این پرچم می‌تواند چندین بار مشخص شود. برای اطلاعات بیشتر، \fIبخش بازنویسی‌های خط فرمان\fR را ببینید. .RE .sp \fB\-C\fR \fIPATH\fR .RS 4 دایرکتوری کاری جاری را پیش از اجرای هرگونه عملیات مشخص‌شده تغییر می‌دهد. این مورد بر مواردی مانند مکانی که cargo به‌طور پیش‌فرض برای مانیفست پروژه (\fBCargo.toml\fR) جستجو می‌کند، و همچنین برای نمونه دایرکتوری‌های جستجوشده جهت کشف \fB\&.cargo/config.toml\fR اثر می‌گذارد. این گزینه باید پیش از نام دستور قرار گیرد، برای مثال \fBcargo \-C path/to/my\-project build\fR\&. .sp این گزینه فقط در \fIکانال nightly\fR در دسترس است و برای فعال‌سازی به پرچم \fB\-Z unstable\-options\fR نیاز دارد (ببینید: \fI#10098\fR ). .RE .sp \fB\-h\fR, \fB\-\-help\fR .RS 4 اطلاعات راهنما را چاپ می‌کند. .RE .sp \fB\-Z\fR \fIflag\fR .RS 4 پرچم‌های ناپایدار (فقط nightly) برای Cargo. برای جزئیات، \fBcargo \-Z help\fR را اجرا کنید. .RE .SH "محیط (ENVIRONMENT)" برای جزئیات درباره متغیرهای محیطی که Cargo می‌خواند، \fIمرجع\fR را ببینید. .SH "وضعیت خروج (EXIT STATUS)" .sp .RS 4 \h'-04'\(bu\h'+03'\fB0\fR: عملیات Cargo با موفقیت انجام شد. .RE .sp .RS 4 \h'-04'\(bu\h'+03'\fB101\fR: عملیات Cargo با شکست مواجه شد. .RE .SH "مثال‌ها (EXAMPLES)" .sp .RS 4 \h'-04' 1.\h'+01'نمایش خروجی JSON درباره بسته جاری: .sp .RS 4 .nf cargo metadata \-\-format\-version=1 .fi .RE .RE .SH "همچنین ببینید (SEE ALSO)" \fBcargo\fR(1), \fBcargo\-pkgid\fR(1), \fIمشخصات Package ID\fR , \fIپیام‌های JSON\fR