pub enum Resource {
Bundled {
bundled: String,
},
FileSystem {
file: PathBuf,
},
}
Expand description
Represents a resource, which is either bundled in the CKB binary or resident in the local file system.
Variants§
Bundled
A resource that bundled in the CKB binary.
FileSystem
A resource that resides in the local file system.
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn file_system(file: PathBuf) -> Resource
pub fn file_system(file: PathBuf) -> Resource
Creates a reference to the resource resident in the file system.
Sourcepub fn ckb_config<P: AsRef<Path>>(root_dir: P) -> Resource
pub fn ckb_config<P: AsRef<Path>>(root_dir: P) -> Resource
Creates the CKB config file resource from the file system.
It searches the file name CKB_CONFIG_FILE_NAME
in the directory root_dir
.
Sourcepub fn miner_config<P: AsRef<Path>>(root_dir: P) -> Resource
pub fn miner_config<P: AsRef<Path>>(root_dir: P) -> Resource
Creates the CKB miner config file resource from the file system.
It searches the file name MINER_CONFIG_FILE_NAME
in the directory root_dir
.
Sourcepub fn db_options<P: AsRef<Path>>(root_dir: P) -> Resource
pub fn db_options<P: AsRef<Path>>(root_dir: P) -> Resource
Creates the RocksDB options file resource from the file system.
It searches the file name DB_OPTIONS_FILE_NAME
in the directory root_dir
.
Sourcepub fn bundled_ckb_config() -> Resource
pub fn bundled_ckb_config() -> Resource
Creates the bundled CKB config file resource.
Sourcepub fn bundled_miner_config() -> Resource
pub fn bundled_miner_config() -> Resource
Creates the bundled CKB miner config file resource.
Sourcepub fn bundled_db_options() -> Resource
pub fn bundled_db_options() -> Resource
Creates the bundled RocksDB options file resource.
Sourcepub fn exported_in<P: AsRef<Path>>(root_dir: P) -> bool
pub fn exported_in<P: AsRef<Path>>(root_dir: P) -> bool
Checks whether any of the bundled resource has been exported in the specified directory.
This can be used to avoid overwriting to export all the bundled resources to the specified directory.
Sourcepub fn is_bundled(&self) -> bool
pub fn is_bundled(&self) -> bool
Returns true
if this is a bundled resource.
Sourcepub fn exists(&self) -> bool
pub fn exists(&self) -> bool
Returns true
if the resource exists.
The bundled resource exists only when the identifier is included in the bundle.
The file system resource exists only when the file exists.
Sourcepub fn parent(&self) -> Option<&Path>
pub fn parent(&self) -> Option<&Path>
The parent directory of the resource.
It always returns None
on bundled resource.
Sourcepub fn absolutize<P: AsRef<Path>>(&mut self, base: P)
pub fn absolutize<P: AsRef<Path>>(&mut self, base: P)
Modifies the file system resource to ensure the path is absolute.
If the path is relative, expand the path relative to the directory base
.
Sourcepub fn export<P: AsRef<Path>>(
&self,
context: &TemplateContext<'_>,
root_dir: P,
) -> Result<()>
pub fn export<P: AsRef<Path>>( &self, context: &TemplateContext<'_>, root_dir: P, ) -> Result<()>
Exports a bundled resource.
This function returns Ok
immediately when invoked on a file system resource.
The file is exported to the path by combining root_dir
and the resource identifier.
These bundled files can be customized for different chains using spec branches. See Template.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Resource
impl StructuralPartialEq for Resource
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnwindSafe for Resource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)