pub struct IndexWriter { /* private fields */ }Expand description
In-memory builder for constructing and serializing .ridx files.
Implementations§
Source§impl IndexWriter
impl IndexWriter
Source§impl IndexWriter
impl IndexWriter
Sourcepub fn intern_ty_def(&mut self, def: RawTyDef<'_>) -> TyDefId
pub fn intern_ty_def(&mut self, def: RawTyDef<'_>) -> TyDefId
Interns a local or external definition handle inside this shard’s TyArena.
Sourcepub fn intern_ty(&mut self, ty: RawTy<'_>) -> TyId
pub fn intern_ty(&mut self, ty: RawTy<'_>) -> TyId
Interns a structured, Infer-free type inside this shard’s TyArena.
Sourcepub fn ty_entry_count(&self) -> usize
pub fn ty_entry_count(&self) -> usize
Total count of deduplicated TyEntry nodes in TyArena.
Sourcepub fn ty_interner(&self) -> &TyInterner
pub fn ty_interner(&self) -> &TyInterner
Read-only access to the TyInterner accumulated on this writer.
Sourcepub fn add_fn_sig(&mut self, sig: RawFnSig<'_>)
pub fn add_fn_sig(&mut self, sig: RawFnSig<'_>)
Records a structured function/method/tuple-ctor signature for def_index.
Sourcepub fn fn_sig_count(&self) -> usize
pub fn fn_sig_count(&self) -> usize
Total count of structured function signatures queued.
Sourcepub fn add_impl(&mut self, imp: RawImpl<'_>) -> u32
pub fn add_impl(&mut self, imp: RawImpl<'_>) -> u32
Records a structured inherent or trait impl header and its associated type bindings,
returning the queued pending_impl_idx handle for attaching generic params and where predicates.
Sourcepub fn impl_count(&self) -> usize
pub fn impl_count(&self) -> usize
Total count of structured impl headers queued.
Sourcepub fn assoc_ty_count(&self) -> usize
pub fn assoc_ty_count(&self) -> usize
Total count of associated type bindings queued across all impl headers.
Sourcepub fn add_field(&mut self, field: RawField<'_>)
pub fn add_field(&mut self, field: RawField<'_>)
Records a structured ADT or enum variant field (FieldEntry).
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Total count of structured fields queued.
Sourcepub fn add_def_ty(&mut self, entry: RawDefTy)
pub fn add_def_ty(&mut self, entry: RawDefTy)
Records a structured definition type/constructor entry (DefTyEntry).
Sourcepub fn def_ty_count(&self) -> usize
pub fn def_ty_count(&self) -> usize
Total count of structured definition type entries queued.
Source§impl IndexWriter
impl IndexWriter
Sourcepub fn set_target_triple(&mut self, triple: impl Into<String>)
pub fn set_target_triple(&mut self, triple: impl Into<String>)
Sets the compilation target triple (e.g. x86_64-unknown-linux-gnu) for this shard.
Sourcepub fn add_cfg_flag(&mut self, key: &str)
pub fn add_cfg_flag(&mut self, key: &str)
Adds a bare cfg flag atom (e.g. unix, test, debug_assertions).
Sourcepub fn add_cfg_key_value(&mut self, key: &str, value: &str)
pub fn add_cfg_key_value(&mut self, key: &str, value: &str)
Adds a cfg(key = "value") predicate (e.g. ("feature", "serde"), ("target_os", "linux")).
Source§impl IndexWriter
impl IndexWriter
Sourcepub fn add_def_generic_param(
&mut self,
def_index: u32,
param: RawGenericParam<'_>,
)
pub fn add_def_generic_param( &mut self, def_index: u32, param: RawGenericParam<'_>, )
Records a generic parameter declared on DefEntry def_index.
Sourcepub fn add_impl_generic_param(
&mut self,
pending_impl_idx: u32,
param: RawGenericParam<'_>,
)
pub fn add_impl_generic_param( &mut self, pending_impl_idx: u32, param: RawGenericParam<'_>, )
Records a generic parameter declared on the queued Impl at pending_impl_idx (returned by add_impl).
Sourcepub fn add_def_where_pred(&mut self, def_index: u32, pred: RawWherePred<'_>)
pub fn add_def_where_pred(&mut self, def_index: u32, pred: RawWherePred<'_>)
Records a where / bound / supertrait / item-bound predicate on DefEntry def_index.
Sourcepub fn add_impl_where_pred(
&mut self,
pending_impl_idx: u32,
pred: RawWherePred<'_>,
)
pub fn add_impl_where_pred( &mut self, pending_impl_idx: u32, pred: RawWherePred<'_>, )
Records a where / bound predicate on the queued Impl at pending_impl_idx (returned by add_impl).
Sourcepub fn generic_param_count(&self) -> usize
pub fn generic_param_count(&self) -> usize
Total count of generic parameter declarations queued across definitions and impls.
Sourcepub fn where_pred_count(&self) -> usize
pub fn where_pred_count(&self) -> usize
Total count of where / bound predicates queued across definitions and impls.
Sourcepub fn add_lang_item(&mut self, item: RawLangItem)
pub fn add_lang_item(&mut self, item: RawLangItem)
Records a compiler #[lang = "..."] (or associated trait item) entry in this shard.
Sourcepub fn lang_item_count(&self) -> usize
pub fn lang_item_count(&self) -> usize
Total count of LangItemEntry rows queued in this shard.
Source§impl IndexWriter
impl IndexWriter
Sourcepub fn add_macro_def(&mut self, raw: RawMacroDef<'_>)
pub fn add_macro_def(&mut self, raw: RawMacroDef<'_>)
Records a declarative macro (macro_rules! or Rust 2.0 macro) body for raw.def_index.
Sourcepub fn macro_def_count(&self) -> usize
pub fn macro_def_count(&self) -> usize
Total count of raw MacroDefEntry rows queued before deduplication.
Source§impl IndexWriter
impl IndexWriter
Source§impl IndexWriter
impl IndexWriter
Sourcepub fn set_unit_key(&mut self, unit_key: impl Into<String>)
pub fn set_unit_key(&mut self, unit_key: impl Into<String>)
Sets the compilation unit key for this index shard.
Sourcepub fn set_generation(&mut self, generation: impl Into<String>)
pub fn set_generation(&mut self, generation: impl Into<String>)
Sets the source snapshot generation digest for this index shard.
Sourcepub fn generation(&self) -> Option<&str>
pub fn generation(&self) -> Option<&str>
Returns the source snapshot generation digest if set.
Sourcepub fn set_file_hashes(&mut self, hashes: HashMap<String, u64>)
pub fn set_file_hashes(&mut self, hashes: HashMap<String, u64>)
Sets the source file provenance hashes for files indexed in this shard.
Sourcepub fn add_file_hash(&mut self, file: &str, hash: u64)
pub fn add_file_hash(&mut self, file: &str, hash: u64)
Records or updates the source text provenance hash for a single indexed file.
Sourcepub fn intern_string(&mut self, s: &str) -> u32
pub fn intern_string(&mut self, s: &str) -> u32
Intern a string into the pool, returning its byte offset. Offset 0 is always reserved for the empty string (and used as a sentinel for ‘no owner’).
Sourcepub fn get_or_insert_file(&mut self, path: &str) -> u32
pub fn get_or_insert_file(&mut self, path: &str) -> u32
Get or assign a numeric ID for a file path.
pub fn add_definition(&mut self, def: RawDefinition) -> u32
Sourcepub fn add_definition_unowned(&mut self, def: RawDefinition) -> u32
pub fn add_definition_unowned(&mut self, def: RawDefinition) -> u32
Adds a definition without registering its lexical parent in the legacy defs_by_owner
table (used for nightly-#[unstable] sysroot lang items materialized strictly for v5
lang_items / fn_sigs / where_preds).
pub fn add_definition_with_owners( &mut self, def: RawDefinition, owners: Vec<String>, ) -> u32
Sourcepub fn add_reexport_with_owners(
&mut self,
def: RawDefinition,
owners: Vec<String>,
) -> u32
pub fn add_reexport_with_owners( &mut self, def: RawDefinition, owners: Vec<String>, ) -> u32
Adds a definition marked with FLAG_REEXPORT and associates it with owners.
pub fn add_def_owner(&mut self, def_id: u32, owner: String)
pub fn add_def_owner_by_index(&mut self, idx: u32, owner: String)
pub fn add_reference(&mut self, r: RawReference)
pub fn add_type(&mut self, t: RawType)
pub fn add_type_with_owner(&mut self, t: RawType, owner_path: Option<String>)
pub fn add_deref( &mut self, source_type: impl Into<String>, target_type: impl Into<String>, )
pub fn add_note(&mut self, note: RawNote)
Sourcepub fn note_count(&self) -> usize
pub fn note_count(&self) -> usize
Total count of notes queued.
Sourcepub fn definition_count(&self) -> usize
pub fn definition_count(&self) -> usize
Total count of definitions queued.
Sourcepub fn reference_count(&self) -> usize
pub fn reference_count(&self) -> usize
Total count of references queued.
Sourcepub fn type_count(&self) -> usize
pub fn type_count(&self) -> usize
Total count of types queued.
Sourcepub fn deref_count(&self) -> usize
pub fn deref_count(&self) -> usize
Total count of deref mappings queued.
Sourcepub fn indexed_files(&self) -> Vec<String>
pub fn indexed_files(&self) -> Vec<String>
Returns all unique file paths known to this writer.