use std::sync::Arc;
use pedant_types::SourceRecord;
use crate::ir::FileIr;
use crate::resolution::line_index::SnapshotSource;
use crate::resolution::rust::inventory::RustFileInventory;
use crate::resolution::snapshot_record::SnapshotRecordOf;
#[derive(Debug)]
pub struct RustSource {
record: SnapshotRecordOf<RustFileInventory>,
}
impl RustSource {
pub(super) fn of_record(path: &Arc<str>, record: &SourceRecord<RustFileInventory>) -> Self {
Self {
record: SnapshotRecordOf::of_record(path, record),
}
}
pub fn path(&self) -> &str {
self.record.path()
}
pub(in crate::resolution::rust) fn shared_path(&self) -> &Arc<str> {
self.record.shared_path()
}
pub fn text(&self) -> &str {
self.record.text()
}
pub fn digest(&self) -> &[u8; 32] {
self.record.digest()
}
pub fn ir(&self) -> &FileIr {
self.record.inventory().ir()
}
pub(super) fn legacy_callable_trait_error(&self) -> Option<&str> {
self.record.inventory().legacy_callable_trait_error()
}
}
impl SnapshotSource for RustSource {
fn path(&self) -> &str {
self.record.path()
}
fn text(&self) -> &str {
self.record.text()
}
}