Struct tvix_glue::tvix_store_io::TvixStoreIO

source ·
pub struct TvixStoreIO {
    pub(crate) blob_service: Arc<dyn BlobService>,
    pub(crate) directory_service: Arc<dyn DirectoryService>,
    pub(crate) path_info_service: Arc<dyn PathInfoService>,
    pub(crate) nar_calculation_service: Arc<dyn NarCalculationService>,
    std_io: StdIO,
    build_service: Arc<dyn BuildService>,
    pub(crate) tokio_handle: Handle,
    pub(crate) fetcher: Fetcher<Arc<dyn BlobService>, Arc<dyn DirectoryService>, Arc<dyn PathInfoService>, Arc<dyn NarCalculationService>>,
    pub known_paths: RefCell<KnownPaths>,
}
Expand description

Implements EvalIO, asking given PathInfoService, DirectoryService and BlobService.

In case the given path does not exist in these stores, we ask StdIO. This is to both cover cases of syntactically valid store paths, that exist on the filesystem (still managed by Nix), as well as being able to read files outside store paths.

This structure is also directly used by the derivation builtins and tightly coupled to it.

In the future, we may revisit that coupling and figure out how to generalize this interface and hide this implementation detail of the glue itself so that glue can be used with more than one implementation of “Tvix Store IO” which does not necessarily bring the concept of blob service, directory service or path info service.

Fields§

§blob_service: Arc<dyn BlobService>§directory_service: Arc<dyn DirectoryService>§path_info_service: Arc<dyn PathInfoService>§nar_calculation_service: Arc<dyn NarCalculationService>§std_io: StdIO§build_service: Arc<dyn BuildService>§tokio_handle: Handle§fetcher: Fetcher<Arc<dyn BlobService>, Arc<dyn DirectoryService>, Arc<dyn PathInfoService>, Arc<dyn NarCalculationService>>§known_paths: RefCell<KnownPaths>

Implementations§

source§

impl TvixStoreIO

source

pub fn new( blob_service: Arc<dyn BlobService>, directory_service: Arc<dyn DirectoryService>, path_info_service: Arc<dyn PathInfoService>, nar_calculation_service: Arc<dyn NarCalculationService>, build_service: Arc<dyn BuildService>, tokio_handle: Handle ) -> Self

source

async fn store_path_to_node( &self, store_path: &StorePath<String>, sub_path: &Path ) -> Result<Option<Node>>

for a given StorePath and additional Path inside the store path, look up the PathInfo, and if it exists, and then use directoryservice::descend_to to return the Node specified by sub_path.

In case there is no PathInfo yet, this means we need to build it (which currently is stubbed out still).

source

pub(crate) async fn node_to_path_info<'a>( &self, name: &'a str, path: &Path, ca: &CAHash, root_node: Node ) -> Result<(PathInfo, NixHash, StorePathRef<'a>)>

source

pub(crate) async fn register_node_in_path_info_service<'a>( &self, name: &'a str, path: &Path, ca: &CAHash, root_node: Node ) -> Result<StorePathRef<'a>>

source

pub async fn store_path_exists<'a>( &'a self, store_path: StorePathRef<'a> ) -> Result<bool>

Trait Implementations§

source§

impl EvalIO for TvixStoreIO

source§

fn path_exists(&self, path: &Path) -> Result<bool>

Verify whether the file at the specified path exists. Read more
source§

fn open(&self, path: &Path) -> Result<Box<dyn Read>>

Open the file at the specified path to a io::Read.
source§

fn file_type(&self, path: &Path) -> Result<FileType>

Return the FileType of the given path, or an error if it doesn’t exist.
source§

fn read_dir(&self, path: &Path) -> Result<Vec<(Bytes, FileType)>>

Read the directory at the specified path and return the names of its entries associated with their FileType. Read more
source§

fn import_path(&self, path: &Path) -> Result<PathBuf>

Import the given path. What this means depends on the implementation, for example for a std::io-based implementation this might be a no-op, while for a Tvix store this might be a copy of the given files to the store. Read more
source§

fn store_dir(&self) -> Option<String>

Returns the root of the store directory, if such a thing exists in the evaluation context. 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> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more