Skip to main content

IndexWriter

Struct IndexWriter 

Source
pub struct IndexWriter { /* private fields */ }
Expand description

In-memory builder for constructing and serializing .ridx files.

Implementations§

Source§

impl IndexWriter

Source

pub fn write_to<W: Write + Seek>(&mut self, writer: &mut W) -> Result<()>

Serializes the entire index to any writer implementing Write + Seek.

Source§

impl IndexWriter

Source

pub fn intern_ty_def(&mut self, def: RawTyDef<'_>) -> TyDefId

Interns a local or external definition handle inside this shard’s TyArena.

Source

pub fn intern_ty(&mut self, ty: RawTy<'_>) -> TyId

Interns a structured, Infer-free type inside this shard’s TyArena.

Source

pub fn ty_entry_count(&self) -> usize

Total count of deduplicated TyEntry nodes in TyArena.

Source

pub fn ty_interner(&self) -> &TyInterner

Read-only access to the TyInterner accumulated on this writer.

Source

pub fn add_fn_sig(&mut self, sig: RawFnSig<'_>)

Records a structured function/method/tuple-ctor signature for def_index.

Source

pub fn fn_sig_count(&self) -> usize

Total count of structured function signatures queued.

Source

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.

Source

pub fn impl_count(&self) -> usize

Total count of structured impl headers queued.

Source

pub fn assoc_ty_count(&self) -> usize

Total count of associated type bindings queued across all impl headers.

Source

pub fn add_field(&mut self, field: RawField<'_>)

Records a structured ADT or enum variant field (FieldEntry).

Source

pub fn field_count(&self) -> usize

Total count of structured fields queued.

Source

pub fn add_def_ty(&mut self, entry: RawDefTy)

Records a structured definition type/constructor entry (DefTyEntry).

Source

pub fn def_ty_count(&self) -> usize

Total count of structured definition type entries queued.

Source§

impl IndexWriter

Source

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.

Source

pub fn add_cfg_flag(&mut self, key: &str)

Adds a bare cfg flag atom (e.g. unix, test, debug_assertions).

Source

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

pub fn add_cfg(&mut self, key: &str, value: Option<&str>)

Adds an active cfg predicate (None for bare atom, Some(val) for key = "val").

Source

pub fn cfg_count(&self) -> usize

Total count of raw CfgEntry rows queued before deduplication.

Source§

impl IndexWriter

Source

pub fn add_def_generic_param( &mut self, def_index: u32, param: RawGenericParam<'_>, )

Records a generic parameter declared on DefEntry def_index.

Source

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).

Source

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.

Source

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).

Source

pub fn generic_param_count(&self) -> usize

Total count of generic parameter declarations queued across definitions and impls.

Source

pub fn where_pred_count(&self) -> usize

Total count of where / bound predicates queued across definitions and impls.

Source

pub fn add_lang_item(&mut self, item: RawLangItem)

Records a compiler #[lang = "..."] (or associated trait item) entry in this shard.

Source

pub fn lang_item_count(&self) -> usize

Total count of LangItemEntry rows queued in this shard.

Source

pub fn add_use(&mut self, item: RawUse<'_>)

Records a module use, glob, re-export, or extern crate binding in this shard.

Source

pub fn use_count(&self) -> usize

Total count of raw UseEntry rows queued before multi-namespace merge.

Source§

impl IndexWriter

Source

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.

Source

pub fn macro_def_count(&self) -> usize

Total count of raw MacroDefEntry rows queued before deduplication.

Source§

impl IndexWriter

Source

pub fn new( crate_name: impl Into<String>, crate_version: impl Into<String>, ) -> Self

Source§

impl IndexWriter

Source

pub fn set_unit_key(&mut self, unit_key: impl Into<String>)

Sets the compilation unit key for this index shard.

Source

pub fn unit_key(&self) -> Option<&str>

Returns the compilation unit key if set.

Source

pub fn set_generation(&mut self, generation: impl Into<String>)

Sets the source snapshot generation digest for this index shard.

Source

pub fn generation(&self) -> Option<&str>

Returns the source snapshot generation digest if set.

Source

pub fn set_file_hashes(&mut self, hashes: HashMap<String, u64>)

Sets the source file provenance hashes for files indexed in this shard.

Source

pub fn add_file_hash(&mut self, file: &str, hash: u64)

Records or updates the source text provenance hash for a single indexed file.

Source

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’).

Source

pub fn get_or_insert_file(&mut self, path: &str) -> u32

Get or assign a numeric ID for a file path.

Source

pub fn add_definition(&mut self, def: RawDefinition) -> u32

Source

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).

Source

pub fn add_definition_with_owners( &mut self, def: RawDefinition, owners: Vec<String>, ) -> u32

Source

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.

Source

pub fn add_def_owner(&mut self, def_id: u32, owner: String)

Source

pub fn add_def_owner_by_index(&mut self, idx: u32, owner: String)

Source

pub fn add_reference(&mut self, r: RawReference)

Source

pub fn add_type(&mut self, t: RawType)

Source

pub fn add_type_with_owner(&mut self, t: RawType, owner_path: Option<String>)

Source

pub fn add_deref( &mut self, source_type: impl Into<String>, target_type: impl Into<String>, )

Source

pub fn add_note(&mut self, note: RawNote)

Source

pub fn note_count(&self) -> usize

Total count of notes queued.

Source

pub fn definition_count(&self) -> usize

Total count of definitions queued.

Source

pub fn reference_count(&self) -> usize

Total count of references queued.

Source

pub fn type_count(&self) -> usize

Total count of types queued.

Source

pub fn deref_count(&self) -> usize

Total count of deref mappings queued.

Source

pub fn indexed_files(&self) -> Vec<String>

Returns all unique file paths known to this writer.

Trait Implementations§

Source§

impl Default for IndexWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.