# Adapter

> Reading and writing the interchange formats.

Symbols in this group are spelled `otio_read_…` or `otio_write_…`. An SDK drops that prefix.

## `read_from_bytes`

`otio_read_from_bytes` · constructor

Reads a document from the bytes of a file in some format.

`options` may be null for the format's usual behaviour. The bundle formats are refused with `OTIO_STATUS_UNSUPPORTED`: read one from its path.

```c
OtioStatus otio_read_from_bytes(
    OtioFormat format,
    const uint8_t *data,
    size_t len,
    const OtioReadOptions *options,
    OtioDocument **out_document,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `format` | `OtioFormat` | input |
| `data` | `bytes` | bytes |
| `len` | `size` | length |
| `options` (optional) | `OtioReadOptions` | input |
| `out_document` | `document` | output |
| `out_error` | `text` | error |

## `read_from_file`

`otio_read_from_file` · constructor

Reads a document from a file on disk in some format.

An AAF is read where it lies, seeking around the file, rather than copied into memory first. An `.otiod` is a directory, and `path` names it.

A build without a file system, such as one for WebAssembly, reports `OTIO_STATUS_UNSUPPORTED`; use [`otio_read_from_bytes`] there.

```c
 *     if (otio_read_from_file(OTIO_FORMAT_CMX_3600, "cut.edl", NULL, &document,
 *                             &error)) {
 *         fprintf(stderr, "%s\n", error.data);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `format` | `OtioFormat` | input |
| `path` | `text` | input |
| `options` (optional) | `OtioReadOptions` | input |
| `out_document` | `document` | output |
| `out_error` | `text` | error |

## `read_options_default`

`otio_read_options_init` · free

Returns the defaults, for a caller that wants to change one field.

```c
 * then call `otio_read_options_init()` or `otio_write_options_init()`, which
 * fill every field that size covers with its default:
 *
 *     OtioReadOptions options;
```

| Parameter | Type | Role |
| --- | --- | --- |
| `out_options` | `OtioReadOptions` | output |

## `write_options_default`

`otio_write_options_init` · free

Returns the defaults, for a caller that wants to change one field.

```c
 * then call `otio_read_options_init()` or `otio_write_options_init()`, which
 * fill every field that size covers with its default:
 *
 *     OtioReadOptions options;
```

| Parameter | Type | Role |
| --- | --- | --- |
| `out_options` | `OtioWriteOptions` | output |

## `write_to_bytes`

`otio_write_to_bytes` · method

Writes a document as the bytes of a file in some format.

The buffer is NUL-terminated, so a text format's output can be used as a C string; `len` is what matters for a binary one. The bundle formats are refused with `OTIO_STATUS_UNSUPPORTED`: write one to a path.

```c
OtioStatus otio_write_to_bytes(
    OtioFormat format,
    const OtioDocument *source,
    const OtioWriteOptions *options,
    OtioBuffer *out_bytes,
    OtioBuffer *out_error);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `format` | `OtioFormat` | input |
| `source` (optional) | `document` | document in |
| `options` (optional) | `OtioWriteOptions` | input |
| `out_bytes` | `bytes` | output |
| `out_error` | `text` | error |

## `write_to_file`

`otio_write_to_file` · method

Writes a document to a file on disk in some format.

A bundle is written from the document's root, which has to be a timeline, along with a copy of every media file it references; an `.otiod` is a directory, and `path` names it. Neither overwrites: a bundle whose `path` already exists is refused.

A build without a file system, such as one for WebAssembly, reports `OTIO_STATUS_UNSUPPORTED`; use [`otio_write_to_bytes`] there.

```c
 *     otio_write_to_file(OTIO_FORMAT_OTIO_JSON, document, "cut.otio", NULL, NULL);
```

| Parameter | Type | Role |
| --- | --- | --- |
| `format` | `OtioFormat` | input |
| `source` (optional) | `document` | document in |
| `path` | `text` | input |
| `options` (optional) | `OtioWriteOptions` | input |
| `out_error` | `text` | error |

---

Page: https://otio-rust-docs.vercel.app/reference/adapter/
