# `cat-dev` #
A library used for interacting with [CAT-DEV](https://wiki.raregamingdump.ca/index.php?title=CAT-DEV)
also sometimes referred to as the "cat-dev bridge". A CAT-DEV is actually two
pieces under the hood, a "Host Bridge" which is what we actually interact with,
and the actual "Cafe Main Board" (if you have a legal copy of the Cafe SDK
v2.12.13 -- you can look at the doc page at
`/system/docs/man/en_us/dev/catdev/prerequisite/DevelopmentEnvironment.html`
to find an image explaining this flow).
## Stability ##
This crate is currently pre-1.0. We will do our best to minimize breaking
changes to the library, but there is still many parts of the cat-dev we have
not fully figured out. As such we're very hesitant to make any promises about
the stability of these APIs, or that we'll follow SEM-VER until we've at the
very least figured all of that out. If you are ever affected by this, or
concerned about this please reach out on our github repository. We do want to
try, and make it as smooth as possible.
## "Probably Don't Want Functions" ##
***Please double check the documentation before using functions***
Because this library is developed in close relation to re-implementations of
very old, very buggy CLI tools there are some functions that exist for the sole
purpose of recreating these buggy, or poorly displaying CLIs. These functions
will be marked in their documentation.
One key thing to watch out for: `_with_logging_hooks` these functions don't
magically enable logging, they simply allow hooks for running `println!`, and
`print!`'s completely outside of the logging infrastructure. For tool
reimplementations that need to match their output EXACTLY and thus can't use
the normal logging infrastructure.
## Usage ##
Here are some basic use cases, this not all encompassing but may be helpful for
you.
### `findbridge`-esque style discovery ###
You can discover all the bridges on your host in the following fashion:
```rust,no_run
use cat_dev::mion::discovery::discover_bridges;
/// Fetching detailed fields grabs a few extra bits of information, these are
/// all prefixed with `detailed_` in the returned info structures, but for
/// completeness sake the fields are:
///
/// - `detailed_sdk_version`
/// - `detailed_boot_type`
/// - `detailed_is_cafe_on`
///
/// These all return options that will only be populated if
/// `fetch_detailed_fields` is marked as true.
async fn stream_bridges(fetch_detailed_fields: bool) {
let mut channel_to_stream_bridges = discover_bridges(
fetch_detailed_fields,
None,
).await.expect("Failed to discover bridges!");
// This will block for a potentially "long-ish" (like 10 seconds) time.
//
// Our CLI tool avoids this by timing out if we don't receive a bridge in enough time.
// You can use `discover_and_collect_bridges` with an "early timeout" to get a much
// faster loop here. Though you do have to wait for all of the results to come in.
//
// FWIW our timeout in the CLI Re-implementations is 3 seconds.
while let Some(bridge) = channel_to_stream_bridges.recv().await {
println!("Found bridge: {bridge}");
}
}
```
### `getbridge`-esque style finding a specific bridge ###
You can get information about a specific bridge like so:
```rust,no_run
use cat_dev::mion::discovery::{find_mion, MIONFindBy};
use std::time::Duration;
async fn find_a_mion_by_name(
name: String,
fetch_detailed_fields: bool,
early_search_timeout: Option