Crate workspacer

Source

Modules§

crate_handle_serde

Macros§

gen_bump_all_for_workspace
Macro that generates an impl BumpAll for SomeWorkspace<P,T> block. Use it once for your real Workspace<P,T> and once for your MockWorkspace<P,T>.

Structs§

AiReadmeWriter
AiReadmeWriterBuilder
Builder for AiReadmeWriter.
AiReadmeWriterDesiredOutput
This structure is a directive indicating which fields we need you to provide for us in your response to our query.
AiReadmeWriterDesiredOutputBuilder
Builder for AiReadmeWriterDesiredOutput.
AiReadmeWriterRequest
AiReadmeWriterRequestBuilder
Builder for AiReadmeWriterRequest.
CargoToml
Handle to manipulate and verify the Cargo.toml file
CargoTomlBuilder
Builder for CargoToml.
ConsolidatedCrateInterface
ConsolidationOptions
A collection of user-defined toggles controlling how items are gathered and displayed.
CrateAnalysis
CrateConfig
Configuration for creating a mock crate in the workspace.
CrateHandle
CrateHandleBuilder
Builder for CrateHandle.
CrateInterfaceItem
A single top-level item (fn, struct, etc.), with docs, attributes, and an optional body.
CrateInterfaceItemBuilder
Builder for CrateInterfaceItem.
DefaultCommandRunner
EnumSignatureGenerator
ExistingXMacro
ExistingXMacroBuilder
Builder for ExistingXMacro.
FnSignatureGenerator
GatherCommentsState
Tracks what we’ve collected and where we are in the scanning process.
ImplBlockInterface
LintReport
MacroRulesSignatureGenerator
ModuleInterface
ReadmeWriterConfig
ReadmeWriterConfigBuilder
Builder for ReadmeWriterConfig.
SignatureOptions
Control how we generate a signature string.
SignatureOptionsBuilder
Builder for SignatureOptions.
StructSignatureGenerator
TestCoverageCommand
TestCoverageReport
TopBlockMacro
TopBlockMacroBuilder
Builder for TopBlockMacro.
TraitSignatureGenerator
TypeAliasSignatureGenerator
UseItemInfo
Private struct => changed to public to avoid E0616
UseItemInfoBuilder
Builder for UseItemInfo.
Workspace
WorkspaceAnalysisBuilder
WorkspaceBuilder
Builder for Workspace.
WorkspaceDependencyTree
WorkspaceSizeAnalysis
WorkspaceTreeNode

Enums§

AiReadmeWriterBuilderError
Error type for AiReadmeWriterBuilder
AiReadmeWriterDesiredOutputBuilderError
Error type for AiReadmeWriterDesiredOutputBuilder
AiReadmeWriterError
AiReadmeWriterRequestBuilderError
Error type for AiReadmeWriterRequestBuilder
BuildError
BumpVersionsError
CargoDocError
CargoMetadataError
CargoTomlBuilderError
Error type for CargoTomlBuilder
CargoTomlError
CargoTomlWriteError
ConsolidatedItem
An enum representing any consolidated item that can live in a module. You could also store them separately if you like, but an enum is convenient.
CrateError
CrateHandleBuilderError
Error type for CrateHandleBuilder
CrateInterfaceItemBuilderError
Error type for CrateInterfaceItemBuilder
CrateWriteError
DirectoryError
ExistingXMacroBuilderError
Error type for ExistingXMacroBuilder
GitError
LintingError
ReadmeWriteError
ReadmeWriterConfigBuilderError
Error type for ReadmeWriterConfigBuilder
ReleaseType
Specifies how we want to bump a version:
SignatureOptionsBuilderError
Error type for SignatureOptionsBuilder
SortAndFormatImportsError
SourceFileRegistrationError
TestCoverageError
TestFailure
TokioError
TopBlockMacroBuilderError
Error type for TopBlockMacroBuilder
UseItemInfoBuilderError
Error type for UseItemInfoBuilder
WatchError
WorkspaceBuilderError
Error type for WorkspaceBuilder
WorkspaceError

Traits§

AddInternalDependency
A trait for adding an internal dep from one crate to another.
AddNewCrateToWorkspace
The main trait: Add a brand-new crate to the workspace with minimal scaffolding.
AddToWorkspaceMembers
Analyze
ApplyAiReadmeOutput
One pragmatic way to address “losing access to the crate or workspace handle” is to store enough information inside each request so that, after the AI expansions finish, you can locate and update the relevant Cargo.toml and README. That can be done in at least two ways:
Bump
This will be implemented by CrateHandle
BumpAll
A trait describing how to bump versions in a workspace.
BumpCrateAndDownstreams
CargoTomlInterface
CheckExistence
CheckIfReadmeExists
CheckIfSrcDirectoryContainsValidFiles
CheckRequiredFieldsForIntegrity
CheckRequiredFieldsForPublishing
CheckVersionValidityForIntegrity
CheckVersionValidityForPublishing
CleanupCrate
CleanupWorkspace
CommandRunner
ConsolidateCrateInterface
CrateHandleInterface
CreateCrateSkeleton
Extension trait to create the new crate skeleton: directory, Cargo.toml, src/lib.rs, …
DetectCircularDependencies
DocumentClone
EnsureAllSourceFilesAreRegistered
EnsureGitClean
ExitStatusExt
Unix-specific extensions to process::ExitStatus and ExitStatusError.
ExtendedCrateInterface
ExtendedWorkspaceInterface
FindCrateByName
GatherBinTargetNames
GenerateDependencyTree
GenerateDocs
GenerateSignature
A trait to generate a textual “signature” (or declaration line(s)) for different AST nodes (Fn, Struct, Enum, etc.), possibly with doc lines, etc.
GetAllCrateNames
GetCargoMetadata
Extend GetCargoMetadata to also handle a single crate (e.g., CrateHandle).
GetContent
GetCrateRepositoryLocation
GetCrateRepositoryLocationOrFallback
GetCrates
GetCratesMut
GetFilesInDirectory
GetFilesInDirectoryWithExclusions
GetInternalDependencies
A private trait for gathering local (path-based) dependencies from a crate’s Cargo.toml. We do NOT expose it publicly — it remains internal.
GetLicenseType
GetLicenseTypeOrFallback
GetPackageAuthors
GetPackageAuthorsOrFallback
GetPackageSection
GetPackageSectionMut
GetReadmePath
GetRustEdition
GetRustEditionOrFallback
GetSourceFilesWithExclusions
GetTestFiles
GetVersionOfLocalDep
HasCargoToml
HasCargoTomlPathBuf
HasCargoTomlPathBufSync
HasTestsDirectory
IsPrivate
IsValidVersion
NameAllFiles
NumCrates
PinAllWildcardDependencies
PinWildcardDependencies
ReadFileString
We add a new method to CrateHandleInterface so we can read file text from an in-memory mock or from the real filesystem. For your real code, you might implement it differently.
ReadmeWritingCrateHandle
ReadyForCargoPublish
Trait for checking if a component is ready for Cargo publishing
RebuildOrTest
RegisterInPrefixGroup
This trait says: “Given a prefix group’s facade crate, register a new internal crate in it.” Typically means:
RehydrateFromSignature
RootDirPathBuf
RunLinting
The RunLinting trait remains the same.
RunTestsWithCoverage
SaveToDisk
SortAndFormatImports
Our trait for sorting and formatting imports in a crate or workspace. The goal:
Test
removeme
TryPublish
UpdateDependencyVersionRaw
UpdateReadmeFiles
Versioned
WatchAndReload
WorkspaceDownstreamExt
WorkspaceInterface
WorkspaceTreeBuilder
WriteDocumentBack

Functions§

assemble_final_top_block_snippet
Builds the final top-block snippet by combining:
build_lock_versions
A shared helper that reads Cargo.lock from root and builds a map of crate->versions.
build_new_use_lines
Updated build_new_use_lines to accept the trailing_comments map as a third parameter. If your existing tests only pass two arguments, just add &BTreeMap::new() as the third.
build_top_block_for_imports_line
Builds the final snippet for the “has_imports_line=true” scenario: (a) old_top_macros first (with their leading comments), (b) then non-macro lines, (c) then new_top_macros.
build_top_block_for_no_imports_line
Builds the final snippet for the “has_imports_line=false” scenario: (a) snippet lines first, (b) then old_top_macros, (c) then new_top_macros.
collect_comment_token
collect_existing_mod_macro_stems
collect_existing_x_macros
combine_new_uses_with_remainder
The key fix: remove the trim_start() on the remainder.
We want to preserve leading blank lines in the remainder so that if there was a blank line after some block comment, it stays in the final output.
create_top_block_text
Builds a string with one line per TopBlockMacro, preserving each macro’s leading comments and ensuring each macro ends up on its own line (with no trailing newline).
dash_to_snake_case
Helper to transform dashes => underscores for snake-case usage
detect_trailing_comment_same_line
Detects a same-line trailing // comment starting just after offset pos (e.g. after the semicolon). If found, returns (comment_text, total_length) so we can store that comment text and expand the removal range. If none found, returns None.
determine_top_block_insertion_offset
dispatch_token_by_kind
dissect_use_statement
execute_ai_readme_writer_requests
existing_macros_to_top_block_macros
extract_docs
Extract doc lines from /// or /** ... */. We do NOT gather #[doc="..."] attributes here. Those can be handled separately if you want to unify them.
extract_non_macro_lines
extract_stem
fallback_scan_node_text
file_has_imports_line
filter_new_macros_for_duplicates
Removes from new_macros any macro whose stem is already in old_macros.
find_earliest_non_macro_item_offset
find_last_import_end_before_offset
find_single_prefix_match
A small helper that checks if crate_name starts with exactly one prefix + "-" from the scanned groups. If we find exactly one match, returns that prefix. If zero or multiple, None.
find_top_block_insertion_offset
fix_nested_tables
gather_all_attrs
Gather all the raw attributes from a node (e.g. #[derive(Debug)], #[cfg(feature="xyz")], possibly multiline like #[my_attr(\n Something\n)]), returning them as separate lines— one per distinct Attr node. If you want to force each #[...] node into a single line (removing internal newlines), you can strip out \n and \r. That way “multiline” attributes become one joined line. This matches some test scenarios that expect one line per attribute.
gather_assoc_type_aliases
Gathers all associated type aliases in an impl block, respecting skip logic and collecting docs/attrs.
gather_crate_items
gather_deduplicated_macro_stems
gather_fn_item
gather_impl_methods
Gathers all fn items from within an impl block, excluding any that should_skip_item_fn determines should be skipped (e.g., private methods, test methods if not .include_test_items(), or with #[some_other_attr], etc.).
gather_items_in_node
Gathers Rust items (fn, struct, enum, mod, trait, etc.) from parent_node. In older RA versions, top-level items appear in a SourceFile or ItemList. We’ll check those first; if that fails, we fallback to iterating .children().
gather_leading_comment_lines
gather_leading_comments
A helper that walks backward from item.syntax() to pick up line-comments, similarly to what we do for old macros. If no separate tokens are found, but the item’s own text starts with //, we parse those lines directly from full_text as a fallback.
gather_leading_token_comments
gather_module
gather_old_top_block_macros
gather_rs_files_recursively
Recursively scans the directory root_dir for .rs files. Returns an empty vector if root_dir doesn’t exist or isn’t a directory. Skips any directories it can’t read.
gather_sibling_comments_above
gather_token_comments_above
gather_use_items
generate_impl_signature
group_and_sort_uses
Now we always return three items: (grouped_map, comment_map, trailing_comments). If you have code/tests that only care about grouped_map & comment_map, just destructure as: let (grouped_map, comment_map, _trailing) = group_and_sort_uses(…); ignoring the trailing_comments value.
handle_path_change
has_cfg_test_attr
insert_local_version_if_absent
If a local path is provided but no version is present, attempts to fetch the version from the local Cargo.toml and inserts it.
is_dependencies_key
Checks if a table key ends with “dependencies”
is_imports_line
is_in_test_module
Returns true if any ancestor is a mod that has #[cfg(test)].
is_in_trait_impl_block
Returns true if node is anywhere inside impl SomeTrait for SomeType { ... }.
is_node_public
Check if a node is “public,” e.g. pub fn, pub struct, or #[macro_export].
is_x_macro
leading_spaces
Returns how many leading space characters are at the start of line.
make_exit_status
make_top_block_macro_lines
maybe_ensure_newline
If there is content in buffer and it does not end with a newline, push exactly one \n.
maybe_push_newline
A small helper that ensures if the buffer is non-empty and doesn’t end with \n, we push exactly one newline.
merge_doc_attrs
notify_rebuild_result
parse_and_validate_syntax
parse_new_macros_with_comments
A version of parse_new_macros_with_comments that does NOT do fallback merging snippet lines into the macro.
parse_new_top_block_snippet
peek_next_non_whitespace
pick_highest_version
pin_from_lock_or_warn
pin_wildcard_dependencies_in_table
Iterates over a TOML TeTable (i.e., [dependencies] or similar), and pins any wildcard dependencies found. This ensures that workspace dependencies do not remain * when building or releasing.
pin_wildcard_inline_table_dependency
pin_wildcard_string_dependency
Pins a wildcard string dependency (e.g. serde = "*") from the lockfile if its version is *. If no entry is found in the lockfile, logs a warning and leaves it as *.
pin_wildcard_table_dependency
Pins a wildcard sub-table dependency (e.g. [dependencies.somecrate] version="*", path="..."). If the dependency has a local path, uses GetVersionOfLocalDep to retrieve the version. Otherwise, falls back to the lockfile.
pin_wildcards_in_doc
post_process_spacing
Minimal post-processing to ensure correct spacing around arrows, where clauses, etc.
process_notify_event
process_other_token
process_upward_node
process_whitespace_token
push_macro_with_comments
A small helper for pushing a TopBlockMacro (leading comments + x!{stem}), ensuring each part ends in exactly one \n if needed.
rebuild_librs_with_new_top_block
remove_old_use_statements
remove_trailing_newlines
Removes trailing newlines from the provided buffer string (in-place).
replace_wildcard_version_with_local
If a local path is provided and the version is "*", fetches the local version and replaces the wildcard.
scan_preceding_tokens_for_comments
setup_file_watching
should_skip_impl
should_skip_item
skip_node_plus_trailing_whitespace
Skip exactly one node plus any preceding whitespace tokens, returning the next NodeOrToken above. This is used when:
skip_upward_node_with_whitespace
snap_offset_to_newline
Rounds an offset up to the next newline if it’s in the middle of a line, without exceeding earliest_offset.
snippet_for_logging
Simple helper to return a short snippet from a node’s text for logging
sort_and_format_imports_in_text
splice_top_block_into_source
Rebuilds the final text by copying old_text except for old macros, and inserting the final_top_block at insertion_offset. This version ensures:
split_path_into_prefix_and_final
trim_to_60
try_extract_embedded_comment_in_whitespace
validate_toml
Validates the provided TOML data, ensuring that a [package] section is present and its fields meet certain criteria (e.g. valid SemVer version, mandatory fields like authors, license, etc.).
watch_loop

Type Aliases§

Alias
removeme
LockVersionMap
WorkspaceDependencyGraph