..  Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

..    http://www.apache.org/licenses/LICENSE-2.0

..  Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.

Rust API
========

The `tvm-tirx <https://crates.io/crates/tvm-tirx>`__ crate binds the TIRx compiler
objects over TVM FFI. Its modules follow the Python package: ``tvm_tirx::ir`` is
:doc:`tvm_tirx.ir <../python/ir>`, ``tvm_tirx::tirx`` is :doc:`tvm_tirx.tirx
<../python/tirx>`, and so on. Operators and types can also be defined from Rust in
``tvm_ffi::static_init_block!`` blocks, which run when their library loads; the
:doc:`Rust extension tutorial <../../advanced/extending_ir_in_rust>` builds such a
library.

The crate is built on the ``tvm-ffi`` crate, which provides the objects, functions,
containers and macros its API is written in. This site therefore also hosts the
``tvm-ffi`` reference, so links between the two crates resolve here, against the version
TIRx is built with.

The reference is generated by ``cargo doc`` when the documentation is built with
``BUILD_RUST_DOCS=1`` (see :doc:`../../dev/doc_build`).

Crates
------

.. list-table::
   :header-rows: 1
   :widths: 30 70

   * - Crate
     - Description
   * - 📦 `tvm-tirx <generated/tvm_tirx/index.html>`_
     - The IR, TIRx, symbolic analysis, target, backend, runtime, codegen and script
       bindings, and the Rust IR constructors and operators.
   * - 📦 `tvm-ffi <generated/tvm_ffi/index.html>`_
     - The TVM FFI objects, functions, containers and ``static_init_block!`` the
       bindings are built on, re-exported as ``tvm_tirx::tvm_ffi``.
