# IngestClient

## pub struct IngestClient

Client for uploading files and managing ingest jobs.

## Implementations

### impl IngestClient

#### pub async fn upload_csv(&self, path: impl AsRef<Path>, target: impl Into<DatasetTarget>, ingest: CsvIngest) -> Result<(IngestJob, String)>

Upload a CSV file and ingest it into the given dataset.

The target accepts anything that converts to [`DatasetTarget`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/enum.DatasetTarget.md "nominal::core::DatasetTarget"):
`&str` / `String` for an existing dataset RID, or a [`DatasetCreate`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/struct.DatasetCreate.md "nominal::core::DatasetCreate")
for a new dataset (created atomically with the ingest).

Returns `(job, dataset_rid)`: the newly-created ingest job (use
[`Self::wait_for_ingest_job`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/struct.IngestClient.md#method.wait_for_ingest_job "nominal::core::IngestClient::wait_for_ingest_job") to block until it reaches a terminal
state) and the RID of the dataset the data is landing in (the existing
one, or the freshly-created one).

#### pub async fn upload_parquet(&self, path: impl AsRef<Path>, target: impl Into<DatasetTarget>, ingest: ParquetIngest) -> Result<(IngestJob, String)>

Upload a Parquet file and ingest it into the given dataset.

The target accepts anything that converts to [`DatasetTarget`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/enum.DatasetTarget.md "nominal::core::DatasetTarget"):
`&str` / `String` for an existing dataset RID, or a [`DatasetCreate`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/struct.DatasetCreate.md "nominal::core::DatasetCreate")
for a new dataset (created atomically with the ingest).

Returns `(job, dataset_rid)`.

#### pub async fn upload_mcap(&self, path: impl AsRef<Path>, target: impl Into<DatasetTarget>, ingest: McapIngest) -> Result<(IngestJob, String)>

Upload an MCAP file and ingest its protobuf timeseries data into the
given dataset.

Returns `(job, dataset_rid)`.

#### pub async fn upload_journal_json(&self, path: impl AsRef<Path>, target: impl Into<DatasetTarget>, ingest: JournalJsonIngest) -> Result<(IngestJob, String)>

Upload a journald JSON file (`.jsonl` or `.jsonl.gz`) and ingest it
into the given dataset.

Returns `(job, dataset_rid)`.

#### pub async fn upload_avro_stream(&self, path: impl AsRef<Path>, target: impl Into<DatasetTarget>, ingest: AvroStreamIngest) -> Result<(IngestJob, String)>

Upload a Nominal Avro-stream file and ingest it into the given dataset.

Returns `(job, dataset_rid)`.

#### pub async fn upload_ardupilot_dataflash(&self, path: impl AsRef<Path>, target: impl Into<DatasetTarget>, ingest: DataflashIngest) -> Result<(IngestJob, String)>

Upload an ArduPilot DataFlash (`.bin`) file and ingest it into the
given dataset.

Returns `(job, dataset_rid)`.

#### pub async fn upload_video(&self, path: impl AsRef<Path>, target: impl Into<VideoTarget>, ingest: VideoIngest) -> Result<(IngestJob, String)>

Upload a video file (`.mp4` / `.mkv` / `.avi` / `.ts`) or an MCAP file
containing a video stream and ingest it into the given video resource.

Build the `ingest` argument with [`VideoIngest::starting_at`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/struct.VideoIngest.md#method.starting_at "nominal::core::VideoIngest::starting_at") for a
plain video file, or [`VideoIngest::mcap_topic`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/struct.VideoIngest.md#method.mcap_topic "nominal::core::VideoIngest::mcap_topic") to extract a single
stream out of an MCAP.

Returns `(job, video_rid)`.

#### pub async fn get_ingest_job(&self, rid: &str) -> Result<IngestJob>

Fetch the current state of an ingest job.

#### pub async fn wait_for_ingest_job(&self, rid: &str) -> Result<IngestJob>

Poll an ingest job until it reaches a terminal state.

Returns `Ok` on `Completed`. Returns `Err(Error::Ingest { .. })` on
`Failed` or `Cancelled`. Polls every 2 seconds; use
[`Self::wait_for_ingest_job_with_interval`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/struct.IngestClient.md#method.wait_for_ingest_job_with_interval "nominal::core::IngestClient::wait_for_ingest_job_with_interval") to override.

#### pub async fn wait_for_ingest_job_with_interval(&self, rid: &str, interval: Duration) -> Result<IngestJob>

Like [`Self::wait_for_ingest_job`](https://dev.nominal.io/rust-client/ref/rust/nominal/core/struct.IngestClient.md#method.wait_for_ingest_job "nominal::core::IngestClient::wait_for_ingest_job") but polls on the given interval.

## Trait implementations

**Auto traits**: [`Send`](https://doc.rust-lang.org/1.98.1/core/marker/trait.Send.html), [`Sync`](https://doc.rust-lang.org/1.98.1/core/marker/trait.Sync.html), [`Unpin`](https://doc.rust-lang.org/1.98.1/core/marker/trait.Unpin.html), [`!UnwindSafe`](https://doc.rust-lang.org/1.98.1/core/panic/unwind_safe/trait.UnwindSafe.html), [`!RefUnwindSafe`](https://doc.rust-lang.org/1.98.1/core/panic/unwind_safe/trait.RefUnwindSafe.html)
