Struct tlrepo::ThreadLocalRepo

source ·
pub struct ThreadLocalRepo { /* private fields */ }
Expand description

An object providing a thread-local copy of a git2::Repository for each thread.

Implementations§

source§

impl ThreadLocalRepo

source

pub fn new(path: PathBuf) -> Self

Create a ThreadLocalRepo that opens the repository at the specified path on each thread.

source

pub fn get(&self) -> Result<&Repository, Error>

Get the git2::Repository for this thread. Returns an error if the open fails.

Note that the cache of thread-local objects never gets pruned. If you’re running on a long-running thread or a thread pool, call this method. If you’re running on a short-lived thread, call get_uncached instead.

source

pub fn get_uncached(&self) -> Result<Repository, Error>

Get a new git2::Repository, and don’t save it in the thread-local cache. Returns an error if the open fails.

The cache of thread-local objects never gets pruned. If, over the lifetime of your process, you run an unbounded number of threads that call get and subsequently exit, the thread-local cache will grow without bound. In such threads, use get_uncached to open a repository that won’t get cached.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.