Skip to main content

ServeOptions

Struct ServeOptions 

Source
pub struct ServeOptions {
    pub protocol: ProtocolVersion,
    pub stateless_rpc: bool,
    pub advertise_refs: bool,
    pub agent: String,
    pub hidden_refs: Vec<String>,
    pub server_options: Vec<String>,
    pub bundle_list: Option<BundleList>,
    pub push_bundle: Option<String>,
    pub accepted_promisor_remotes: Vec<String>,
    pub lazy_fetch: Option<bool>,
}
Expand description

How a serving session is framed on the wire.

Fields§

§protocol: ProtocolVersion

Protocol version the client asked for.

§stateless_rpc: bool

Handle exactly one request from the input and stop, without printing the advertisement first. Smart HTTP uses this for its POST requests.

§advertise_refs: bool

Print the ref (or capability) advertisement and stop. Smart HTTP uses this to answer GET info/refs.

§agent: String

Value for the agent= capability, such as grit/0.5.0.

§hidden_refs: Vec<String>

Ref patterns hidden from the advertisement (transfer.hideRefs and the service-specific uploadpack.hideRefs / receive.hideRefs).

§server_options: Vec<String>

Values the client sent as v2 server-option=<value> capability lines on the current command request. Cleared at the start of each v2 command and filled before ls-refs / fetch / object-info handlers run.

§bundle_list: Option<BundleList>

Bundles to offer through the protocol v2 bundle-uri command. None leaves the command out of the advertisement.

§push_bundle: Option<String>

Where clients may upload a resumable push bundle, advertised by receive-pack as pushBundle=<value>; relative values are relative to the repository URL. None advertises nothing.

§accepted_promisor_remotes: Vec<String>

Filled while serving: the promisor remotes the client accepted, from the promisor-remote=<names> capability of its v2 command requests. Only names this server advertised (see PromisorAdvertisement) are kept. The list lasts for the whole session, so an acceptance sent with ls-refs still holds for the fetch that follows; a stateless (smart HTTP) request only sees what that one request carried. Callers leave it empty.

§lazy_fetch: Option<bool>

Fetch objects this repository is missing from its own promisor remotes before answering a client that accepted none of them, so the client still gets a complete pack. None uses uploadpack.lazyFetch (a grit setting, false by default).

Git’s upload-pack turns lazy fetch off unless GIT_NO_LAZY_FETCH=0 is in its environment; the library reads no environment, so callers map that variable here. Fetching needs a PromisorFetcher on the Repository, otherwise the request fails with MissingObjectReason::NoFetcher.

Implementations§

Source§

impl ServeOptions

Source

pub fn lazy_fetch_from_environment(env: &Environment) -> Option<bool>

The Self::lazy_fetch an upload-pack process should use under env, from GIT_NO_LAZY_FETCH (or grit’s GRIT_NO_LAZY_FETCH, which wins when both are set): a false value turns lazy fetch on, a true value turns it off, and unset (or not a boolean) leaves uploadpack.lazyFetch in charge.

Git’s upload-pack sets GIT_NO_LAZY_FETCH=1 unless the variable is already in its environment, so GIT_NO_LAZY_FETCH=0 is how a Git server is told to fetch promised objects for clients that did not accept its promisor remotes.

§Parameters
  • env: the server process environment.
Source

pub fn lazy_fetch_enabled(&self, config: &ConfigSet) -> bool

Whether upload-pack may fetch missing promised objects for this session: Self::lazy_fetch when set, otherwise uploadpack.lazyFetch from config.

A caller uses this to decide whether to open the served Repository with a PromisorFetcher. Without one, a served repository never fetches anything.

§Parameters
  • config: the served repository’s configuration.
Source

pub fn attach_promisor_fetcher( &self, repo: &Repository, config: &ConfigSet, fetcher: Option<Arc<dyn PromisorFetcher>>, ) -> bool

Give the repository an upload-pack session serves the promisor fetcher it may use: fetcher when Self::lazy_fetch_enabled, and none otherwise, so a server without lazy fetch never fetches anything, whichever fetcher the repository was opened with.

Every upload-pack entry point (the grit upload-pack command, smart HTTP, the in-process local transport) calls this right after opening the repository.

§Parameters
  • repo: the served repository.
  • config: its configuration.
  • fetcher: the fetcher to use when lazy fetch is on.
§Returns

Whether a fetcher is now installed.

Trait Implementations§

Source§

impl Clone for ServeOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServeOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ServeOptions

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.