pub enum AddSource {
File(PathBuf),
Bytes(Bytes),
Stream(StreamSource),
}Expand description
Source of content for a CommitOperation::Add operation.
Use File for content already on disk, especially large files:
the path is stored, but file contents are read when the commit runs and are
streamed where possible. Use Bytes for small in-memory content;
the buffer is owned by the operation and may be cloned for LFS/xet uploads.
AddSource::File is not a snapshot: the file must still exist, unchanged,
when HFRepository::create_commit runs.
Variants§
File(PathBuf)
target_family=wasm only.Read file contents from this local path at commit time.
Bytes(Bytes)
In-memory contents used as the file body. Stored as bytes::Bytes so the
internal .clone() calls along the upload path are cheap refcount bumps
rather than full memory copies.
Stream(StreamSource)
Lazily-read byte stream of known total length. Lets the upload pipeline
process a source whose total size exceeds available memory: only one
chunk is held in flight at any time. See StreamSource for the
factory contract (must be re-readable to satisfy the sample, hash, and
upload passes).
Implementations§
Source§impl AddSource
impl AddSource
Sourcepub fn file(path: impl Into<PathBuf>) -> Self
Available on non-target_family=wasm only.
pub fn file(path: impl Into<PathBuf>) -> Self
target_family=wasm only.Construct an AddSource::File from a local file path.
Sourcepub fn bytes(bytes: impl Into<Bytes>) -> Self
pub fn bytes(bytes: impl Into<Bytes>) -> Self
Construct an AddSource::Bytes from in-memory contents.
bytes accepts any type that converts to bytes::Bytes: Vec<u8> is
taken by value with no copy (via Bytes::from), &'static [u8] /
&'static str are wrapped without copying, and an existing Bytes
passes through unchanged.
Sourcepub fn stream(source: StreamSource) -> Self
pub fn stream(source: StreamSource) -> Self
Construct an AddSource::Stream from a StreamSource.
The total length must be known up-front and the factory must produce
identical bytes on every open() — see StreamSource::new.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AddSource
impl !RefUnwindSafe for AddSource
impl !UnwindSafe for AddSource
impl Send for AddSource
impl Sync for AddSource
impl Unpin for AddSource
impl UnsafeUnpin for AddSource
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§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more