keramics_formats/file_resolver.rs
1/* Copyright 2024-2025 Joachim Metz <joachim.metz@gmail.com>
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may
5 * obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 * License for the specific language governing permissions and limitations
11 * under the License.
12 */
13
14use std::sync::Arc;
15
16use keramics_core::{DataStreamReference, ErrorTrace};
17
18use super::path_component::PathComponent;
19
20pub type FileResolverReference = Arc<Box<dyn FileResolver>>;
21
22/// File resolver trait.
23pub trait FileResolver: Send + Sync {
24 /// Retrieves a data stream with the specified path.
25 fn get_data_stream(
26 &self,
27 path_components: &[PathComponent],
28 ) -> Result<Option<DataStreamReference>, ErrorTrace>;
29}