pub struct CreateOptions { /* private fields */ }Expand description
The options of a new repository.
collection_id,
remotes_dir, and
set give the keys of the new config.
fallback gives a value in memory to the
handle that the create returns. A create writes no
[core] add-remotes-config-dir of its own, and the default of the key is
false.
§Examples
use ostrya::repo::{CreateOptions, RemotesDir};
use ostrya::RepoMode;
let repo = CreateOptions::new(RepoMode::Archive)
.collection_id("org.example.Os")
.remotes_dir(RemotesDir::path("/etc/myapp/remotes.d"))
.create("/srv/repo".as_ref())
.await?;
assert_eq!(repo.mode(), RepoMode::Archive);Implementations§
Source§impl CreateOptions
impl CreateOptions
Sourcepub fn new(mode: RepoMode) -> Self
pub fn new(mode: RepoMode) -> Self
Creates the options of a repository of mode, with no collection id
and no remotes directory.
The create writes mode to [core] mode.
Sourcepub fn collection_id(self, id: impl Into<String>) -> Self
pub fn collection_id(self, id: impl Into<String>) -> Self
Sets the collection id. The create writes it to
[core] collection-id.
The call and set::<repo::CollectionId> store
one value, and the last call wins. The create refuses an id that
fails the collection-id rule of CollectionIdValue.
Sourcepub fn set<K>(self, value: ValueOf<K>) -> Self
pub fn set<K>(self, value: ValueOf<K>) -> Self
Sets the value of the key K in the new config.
The create writes the text of Value::format as given. A later
call for the same key replaces the value. Repo::create states the
place of each key in the file. The value is in the file, so the handle
reads it as a value of the file.
The key implements Settable. [core] mode and [core] repo_version fail to compile, because new and
the create write them:
use ostrya::{CreateOptions, RepoMode};
use ostrya::config::repo;
let _ = CreateOptions::new(RepoMode::Archive).set::<repo::Locking>(false);use ostrya::{CreateOptions, RepoMode};
use ostrya::config::repo;
let _ = CreateOptions::new(RepoMode::Archive).set::<repo::Mode>(RepoMode::Bare);Two keys have more rules:
repo::CollectionId: the call andcollection_idstore one value, and the last call wins.ex_ostrya::RemotesConfigDir: the handle takes the remotes directory that the key names, as an open takes it. The create refuses the key together withremotes_dir.
Sourcepub fn fallback<K>(self, value: ValueOf<K>) -> Self
pub fn fallback<K>(self, value: ValueOf<K>) -> Self
Sets a fallback value of the key K on the handle that the create
returns, as OpenOptions::fallback does.
The value is in memory alone, and the create does not write it into
config. A later open of the repository does not take it.
Sourcepub fn remotes_dir(self, dir: RemotesDir) -> Self
pub fn remotes_dir(self, dir: RemotesDir) -> Self
Sets the remotes directory of the repository.
The create writes nothing into the directory. It writes the key
[ex-ostrya] remotes-config-dir into the new config:
- A
Pathvalue, which is absolute, writes its path as given. - An
InRepovalue writes its path as given. - A
Fdvalue writes no key.
The handle that a create returns holds dir in each case, and
Repo::remotes_dir gives it. The create reads the remotes of the
directory, as an open does. The create writes no
[core] add-remotes-config-dir. It refuses the call together with
set::<ex_ostrya::RemotesConfigDir>.
Sourcepub async fn create(&self, path: &Path) -> Result<Repo>
pub async fn create(&self, path: &Path) -> Result<Repo>
Creates and opens a repository at path, relative to the working
directory.
The call creates a new repository only. Repo::create describes
the layout that it writes.
§Errors
Error::RepoExistsifpathholds an entryconfigof any type. The call checks the entry without following a symlink, and it writes nothing. If another process writesconfigafter the check and before the call puts its ownconfigin place, the call gives the same error, and the layout directories that it wrote stay.Error::InvalidInputif the remotes directory value is an empty path, a path that holds a NUL byte, a relativePathpath, or anInRepopath that is absolute or has a..component, or if the value of the key is not valid UTF-8. The call checks the value before it writes.Error::InvalidInputif the collection id fails the collection-id rule ofCollectionIdValue, if the value of[ex-ostrya] remotes-config-dirfails the rules ofRemotesConfigPath, if the call has a remotes directory value and that key together, or if a key file cannot hold the text of a value ofset. The call checks the values before it writes.Error::Ioof kindNotFoundif a component ofpathabove the last does not exist, or if a symlink inpathhas no target. The message is<path> does not exist, withpathas given.Error::InvalidFormatifpathor a component of it is not a directory, or if a directory of the layout is a symlink or is not a directory. The call then writes noconfig.Error::Ioof kindNotFoundif the file system oftmp/hasO_TMPFILEand/proc/self/fdis not available. The message starts witha link through /proc/self/fd gives ENOENT. The layout directories then stay with noconfig, and a later create atpathwritesconfig.Error::Ioif a create, a write, a read, or the check of the entryconfigfails.- The errors of
OpenOptions::openfor the key[ex-ostrya] remotes-config-dir, the remotes directory, and its.conffiles. The call reads them after it writes the layout andconfig, so a refusal leaves the new repository on disk.
Sourcepub async fn create_at(&self, dir: BorrowedFd<'_>, path: &Path) -> Result<Repo>
pub async fn create_at(&self, dir: BorrowedFd<'_>, path: &Path) -> Result<Repo>
Creates and opens a repository at path, relative to the directory
dir.
The call creates a new repository only. Repo::create describes
the layout that it writes. The path of Error::RepoExists is
path, relative to dir.
§Errors
Trait Implementations§
Source§impl Clone for CreateOptions
impl Clone for CreateOptions
Source§impl Debug for CreateOptions
impl Debug for CreateOptions
Auto Trait Implementations§
impl Forget for CreateOptions
impl Freeze for CreateOptionswhere
*const u8 is !null: Freeze,
PhantomData<Entry>: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<OwnedFd> is !null: Freeze,
PhantomData<ArcInner<OwnedFd>>: Freeze,
impl Move for CreateOptions
impl RefUnwindSafe for CreateOptions
impl Send for CreateOptions
impl Sync for CreateOptions
impl Unpin for CreateOptions
impl UnsafeUnpin for CreateOptionswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Entry>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<OwnedFd> is !null: UnsafeUnpin,
PhantomData<ArcInner<OwnedFd>>: UnsafeUnpin,
impl UnwindSafe for CreateOptions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.