# Bindings: Rust

557 public names in `bindings/rust/sona/src/lib.rs`, `bindings/rust/sona-editor/src/lib.rs`.

## Functions and constants

| Declaration | What it does |
|---|---|
| `const MANIFEST_BYTES: usize = sys::SONA_MANIFEST_BYTES` | The value of SONA_MANIFEST_BYTES: an AvatarDescription |
| `const JOINTS: usize = sys::SONA_JOINTS` | The value of SONA_JOINTS: palette slots; the avatar rig animates 71 |
| `const PALETTE_FLOATS: usize = sys::SONA_PALETTE_FLOATS` | The value of SONA_PALETTE_FLOATS: 72 joints x 3 float4 |
| `const VERTEX_STRIDE: usize = sys::SONA_VERTEX_STRIDE` | The value of SONA_VERTEX_STRIDE: the runtime vertex, see sona_mesh |
| `fn version() -> &'static str` | The library's version, "1.1.0".<br>Calls [`sona_version`](../c/the-context.md#sona_version). |
| `fn platform() -> &'static str` | The binary platform id compiled into the library: "linux-x64", "windows-x64",...<br>Calls [`sona_platform`](../c/the-context.md#sona_platform). |
| `fn check_layout() -> Result<usize>` | Compares every struct size and field offset sona360-sys mirrors with the library's own tables. |
| `fn interaction_defaults(kind: u32) -> sys::sona_interaction_desc` | A desc for one kind (sona_sys::SONA_INTERACT_*) with its timings and a default seat.<br>Calls [`sona_interaction_defaults`](../c/two-avatar-interactions-and-seats.md#sona_interaction_defaults). |
| `fn seat_defaults(kind: u32) -> sys::sona_seat` | size set and a seat of that kind: height 0.45 (0 for GROUND), depth 0.45 (unlimited for GROUND), width 0.5 for a chair, 1.4 for a bench and unlimited on the ground.<br>Calls [`sona_seat_defaults`](../c/two-avatar-interactions-and-seats.md#sona_seat_defaults). |
| `fn interaction_layout(desc: &sys::sona_interaction_desc) -> Result<sys::sona_interaction_plan>` | Where the interaction would stand its avatars and where the contacts meet.<br>Calls [`sona_interaction_layout`](../c/two-avatar-interactions-and-seats.md#sona_interaction_layout). |
| `fn skeleton_bone(skeleton: Skeleton, joint: u32) -> Option<&'static str>` | The bone a joint is in that skeleton; None for a joint it has none for.<br>Calls [`sona_skeleton_bone`](../c/skeleton-maps-and-vrm-export.md#sona_skeleton_bone). |
| `fn skeleton_joint(skeleton: Skeleton, bone: &str) -> Option<u32>` | The joint a bone of that skeleton is.<br>Calls [`sona_skeleton_joint`](../c/skeleton-maps-and-vrm-export.md#sona_skeleton_joint). |
| `fn joint_find(name: &str) -> Option<u32>` | A joint by name: "Hips", "Head", "PropRight", "shape_04", "joint_33".<br>Calls [`sona_joint_find`](../c/game-features.md#sona_joint_find). |
| `fn joint_name(joint: u32) -> Option<&'static str>` | None past the last joint.<br>Calls [`sona_joint_name`](../c/game-features.md#sona_joint_name). |
| `fn ik_target_defaults() -> sys::sona_ik_target` | The defaults Context::set_lod uses for None.<br>Calls [`sona_ik_target_defaults`](../c/inverse-kinematics.md#sona_ik_target_defaults). |
| `fn ik_feet_defaults() -> sys::sona_ik_feet` | SONA_IK_GROUND_PLANE with the plane y = 0, weight 1, hips offset at most 0.45 m, tilt at most 35 degrees, and the smoothing a default of 0.1 s.<br>Calls [`sona_ik_feet_defaults`](../c/inverse-kinematics.md#sona_ik_feet_defaults). |
| `fn ik_look_defaults() -> sys::sona_ik_look` | Its defaults are head and eyes, weight 1, yaw 70, up 35, down 45 degrees, smoothing by default 0.15 s, a turn rate of 360 degrees a second, eyes past 10.<br>Calls [`sona_ik_look_defaults`](../c/inverse-kinematics.md#sona_ik_look_defaults). |
| `fn ik_limits_defaults() -> sys::sona_ik_limits` | Elbows 145, knees 150, wrists 75 swing and 80 twist, ankles 45 and 30 degrees, hips 120 forward, 25 behind, 45 out and 25 in, shoulders 45 behind (held level) and 50 across, reach easing from 0.97, a 0.02 m body margin,<br>Calls [`sona_ik_limits_defaults`](../c/inverse-kinematics.md#sona_ik_limits_defaults). |
| `fn ragdoll_defaults() -> sys::sona_ragdoll_options` | size set; coverage 0.9.<br>Calls [`sona_ragdoll_defaults`](../c/ragdolls.md#sona_ragdoll_defaults). |
| `fn sway_defaults() -> sys::sona_sway` | Parts SONA_SWAY_DEFAULT, medium quality, stiffness and damping 0.5, wind scale 1, 48 minimum pixels.<br>Calls [`sona_sway_defaults`](../c/hair-and-cloth-sway.md#sona_sway_defaults). |
| `fn sway_world_defaults() -> sys::sona_sway_world` | Gravity 0 -9.81 0, no wind, gust 0.35 with a period of 1.5 s.<br>Calls [`sona_sway_world_defaults`](../c/hair-and-cloth-sway.md#sona_sway_world_defaults). |
| `fn lod_defaults() -> LodOptions` | The level-of-detail defaults, with sprites on at 48 px.<br>Calls [`sona_lod_defaults`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_defaults). |
| `fn placeholder_defaults() -> sys::sona_placeholder_options` | The loading placeholders' defaults (sona.h 3.8d).<br>Calls [`sona_placeholder_defaults`](../c/loading-placeholders.md#sona_placeholder_defaults). |
| `fn preview_defaults() -> PreviewOptions` | Fills the defaults above.<br>Calls [`sona_preview_defaults`](../c/item-previews.md#sona_preview_defaults). |
| `fn stock_clip_count() -> u32` | The clips in the library: 100 (SONA_STOCK_CLIP_COUNT).<br>Calls [`sona_stock_clip_count`](../c/stock-clips.md#sona_stock_clip_count). |
| `fn stock_clip(id: u32) -> Option<StockClip>` | The clip with this id (SONA_STOCK_*: bytes 4 to 7 of its asset id).<br>Calls [`sona_stock_clip_get`](../c/stock-clips.md#sona_stock_clip_get). |
| `fn stock_clip_at(index: u32) -> Option<StockClip>` | The clip at index, in id order.<br>Calls [`sona_stock_clip_at`](../c/stock-clips.md#sona_stock_clip_at). |
| `fn stock_clip_find(name: &str) -> Option<u32>` | By name ("wave"), asset id or a key of Context::clips ("GenericWave").<br>Calls [`sona_stock_clip_find`](../c/stock-clips.md#sona_stock_clip_find). |
| `fn stock_clip_for_body(id: u32, body: u32) -> u32` | The clip of id's family made for body (1 male, 2 female).<br>Calls [`sona_stock_clip_for_body`](../c/stock-clips.md#sona_stock_clip_for_body). |
| `fn stock_clips_tagged(all: u32, none: u32, body: u32) -> Vec<StockClip>` | Clips with every tag of all and none of none that suit body (0 any, 1 male, 2 female), by id.<br>Calls [`sona_stock_clips_tagged`](../c/stock-clips.md#sona_stock_clips_tagged). |
| `fn clip_tag_name(tag: u32) -> Option<&'static str>` | The name of one tag bit ("idle", "travel",...); NULL for 0, several bits or an unknown bit.<br>Calls [`sona_clip_tag_name`](../c/stock-clips.md#sona_clip_tag_name). |
| `fn clip_tag_find(name: &str) -> u32` | The bit for a tag name; 0 when none.<br>Calls [`sona_clip_tag_find`](../c/stock-clips.md#sona_clip_tag_find). |
| `fn idle_defaults() -> IdleOptions` | size set, parts SONA_IDLE_ALL, seed 0, amount 1, face_px 240.<br>Calls [`sona_idle_defaults`](../c/stock-clips.md#sona_idle_defaults). |
| `fn idle_sample(o: &IdleOptions, seconds: f64) -> Result<IdleState>` | The idle's channels at seconds for o.seed and o.parts, before amount.<br>Calls [`sona_idle_sample`](../c/stock-clips.md#sona_idle_sample). |
| `fn pixel_defaults() -> PixelOptions` | size set, height 32, colours 16, flags SONA_PIXEL_OUTLINE, outline 0 (from the palette), alpha_cut 0.5, no palette.<br>Calls [`sona_pixel_defaults`](../c/2d-outputs.md#sona_pixel_defaults). |
| `fn sticker_defaults() -> StickerOptions` | size set, pixels 512, time -1, framing SONA_PRESET_FULL, outline_px 10, outline 0xffffffff, shadow 0x59000000 (off while shadow_px is 0), padding 8.<br>Calls [`sona_sticker_defaults`](../c/2d-outputs.md#sona_sticker_defaults). |
| `fn sheet_defaults() -> SheetOptions` | size set, 8 frames, 8 directions, px_per_metre 64, padding 2, max_page 4096, draw_flags SONA_DRAW_NO_BLOOM; every other field 0 (the whole clip, facing the camera first, side on, orthographic, packed and trim<br>Calls [`sona_sheet_defaults`](../c/2d-outputs.md#sona_sheet_defaults). |
| `fn style_defaults() -> Style` | Style with its size set: the original look, no outline.<br>Calls [`sona_style_defaults`](../c/art-styles.md#sona_style_defaults). |
| `fn quality_defaults() -> Quality` | The web SDK's: automatic MSAA, MIPS \| CUTOUT_MIPS.<br>Calls [`sona_quality_defaults`](../c/rendering-quality.md#sona_quality_defaults). |
| `fn lighting_defaults() -> Lighting` | A key and fill switched off, the built-in environment, a fitted shadow map.<br>Calls [`sona_lighting_defaults`](../c/lighting-and-shadows.md#sona_lighting_defaults). |
| `fn environment_defaults() -> sys::sona_environment` | size set; kind BUILTIN, skin_red 1.2 (the built-in's).<br>Calls [`sona_environment_defaults`](../c/lighting-and-shadows.md#sona_environment_defaults). |
| `fn environment_irradiance(sh9: &[f32; 27]) -> Option<[f32; 27]>` | The irradiance the lit shader evaluates for 9 RGB SH coefficients of radiance. |
| `fn shader_source(lang: sys::sona_shader_lang, prog: sys::sona_program, stage: i32) -> Option<&'static [u8]>` | Text, or SPIR-V bytes; None when that language is not in this build.<br>Calls [`sona_shader_source`](../c/the-data-api.md#sona_shader_source). |
| `fn view_defaults() -> View` | The web's full-body framing.<br>Calls [`sona_view_defaults`](../c/the-frame.md#sona_view_defaults). |
| `fn camera_orbit(view: &mut View, target: [f64; 3], yaw_deg: f64, pitch_deg: f64, distance: f64)` | Places the eye on an orbit around target. |
| `fn view_matrices(view: &View) -> ([f32; 16], [f32; 16])` | Row-vector (view, projection), D3D depth 0..1. |
| `fn guid_parse(text: &str) -> Result<Guid>` | Parses the 36-character text form.<br>Calls [`sona_guid_parse`](../c/manifests.md#sona_guid_parse). |
| `fn guid_format(id: &Guid) -> String` | The id in its lowercase 36-character form.<br>Calls [`sona_guid_format`](../c/manifests.md#sona_guid_format). |
| `fn slot_of(id: &Guid) -> (Route, u32)` | Where an item goes, and its slot mask.<br>Calls [`sona_slot_of`](../c/manifests.md#sona_slot_of). |
| `fn base64_decode(text: &str) -> Result<Vec<u8>>` | The bytes the base64 text holds.<br>Calls [`sona_base64_decode`](../c/manifests.md#sona_base64_decode). |
| `fn section_name(section: u32) -> Option<&'static str>` | "shirt", "facialHair",...; None past the last section.<br>Calls [`sona_catalogue_section_name`](../c/the-offline-catalogue.md#sona_catalogue_section_name). |
| `fn prop_attach_defaults() -> sys::sona_prop_attach` | The defaults of a prop attachment (joint SONA_PROP_JOINT_AUTO, no offset, no second hand).<br>Calls [`sona_prop_attach_defaults`](../c/props-held-and-worn-objects.md#sona_prop_attach_defaults). |
| `fn prop_part_defaults() -> sys::sona_prop_part` | size set; colour 0xffffffff.<br>Calls [`sona_prop_part_defaults`](../c/props-held-and-worn-objects.md#sona_prop_part_defaults). |
| `fn prop_pets() -> Vec<String>` | The catalogue's pets, as the site's pet mode lists them.<br>Calls [`sona_prop_pet_count`](../c/props-held-and-worn-objects.md#sona_prop_pet_count), [`sona_prop_pet`](../c/props-held-and-worn-objects.md#sona_prop_pet), [`sona_guid_format`](../c/manifests.md#sona_guid_format). |
| `fn prop_is_pet(item_id: &str) -> bool` | 1 when the item id is one of the pets.<br>Calls [`sona_prop_is_pet`](../c/props-held-and-worn-objects.md#sona_prop_is_pet). |
| `fn mask_preset(preset: Mask) -> [f32; sys::SONA_JOINT_COUNT]` | Fills a mask: SONA_MASK_NONE, _FULL, _UPPER_BODY (Spine and below it), _LOWER_BODY (the hips and legs), _HEAD (from the Neck), _LEFT_ARM, _RIGHT_ARM, _ARMS (from the shoulders). |
| `fn mask_branch(mask: &mut [f32; sys::SONA_JOINT_COUNT], joint: u32, weight: f32) -> Result<()>` | Sets joint and every joint below it to weight. |
| `fn phoneme_mouth(symbol: &str) -> Option<u8>` | The mouth for a phoneme symbol (ARPAbet, IPA, viseme names or ids); None when it is none of them.<br>Calls [`sona_phoneme_mouth`](../c/lip-sync-and-voice-mouths.md#sona_phoneme_mouth). |
| `fn lipsync_phonemes(phonemes: &[(&str, f32, f32)]) -> Result<Vec<MouthKey>>` | Timed phonemes (symbol, start, end) to mouth keys.<br>Calls [`sona_lipsync_phonemes`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_phonemes). |
| `fn lipsync_text(text: &str, pcm: Option<&[f32]>, sample_rate: u32) -> Result<Vec<MouthKey>>` | Text to mouth keys, aligned to mono float audio at sample_rate when given, else at an even pace.<br>Calls [`sona_lipsync_text`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_text). |
| `fn mouth_keys_sample(keys: &[MouthKey], t: f64) -> LipSyncFrame` | The mouth at time t of a key list.<br>Calls [`sona_mouth_keys_sample`](../c/lip-sync-and-voice-mouths.md#sona_mouth_keys_sample). |
| `fn headless_devices(backend: sys::sona_backend) -> Vec<HeadlessDevice>` | Every device a headless renderer can open (backend 0: all of them).<br>Calls [`sona_headless_devices`](../c/headless-rendering-and-video-out.md#sona_headless_devices). |
| `fn video_formats(ffmpeg: Option<&str>) -> u32` | Bit 1 << SONA_VIDEO_* for each format this machine can write.<br>Calls [`sona_video_formats`](../c/headless-rendering-and-video-out.md#sona_video_formats). |
| `fn outfit_check(manifest: &[u8], maker: Option<&Maker<'_>>) -> Result<OutfitReport>` | Every issue of a manifest, errors first.<br>Calls [`sona_outfit_check`](../c/making-avatars-in-code.md#sona_outfit_check). |
| `fn outfit_fix(manifest: &mut [u8], maker: Option<&Maker<'_>>) -> Result<OutfitReport>` | Mends every error but a missing body in place; the report is the check after.<br>Calls [`sona_outfit_fix`](../c/making-avatars-in-code.md#sona_outfit_fix). |
| `fn outfit_clash(a: &Guid, b: &Guid, maker: Option<&Maker<'_>>) -> (u32, u32)` | sona_sys::SONA_CLASH_* bits and the slots two items share; without a maker by their ids alone.<br>Calls [`sona_outfit_clash`](../c/making-avatars-in-code.md#sona_outfit_clash). |
| `fn region_name(region: u32) -> Option<&'static str>` | None past the last region.<br>Calls [`sona_region_name`](../c/picking.md#sona_region_name). |
| `fn view_ray(view: &View, x: f64, y: f64) -> Result<([f32; 3], [f32; 3])>` | The ray through (x, y) of the view's picture, pixels from its top left: (origin, unit direction). |
| `fn abi() -> Result<sys::sona_abi_info>` | The loaded library's ABI: abi, oldest_abi (the oldest a caller may be built against) and its version.<br>Calls [`sona_abi_query`](../c/the-context.md#sona_abi_query). |
| `fn tier_defaults() -> sys::sona_tier_options` | size set; target_fps 60, avatars 20.<br>Calls [`sona_tier_defaults`](../c/rendering-quality.md#sona_tier_defaults). |
| `fn ik_foot_lock_defaults() -> sys::sona_ik_foot_lock` | size set; weight 1, max_slide 0.25, release_seconds 0.15.<br>Calls [`sona_ik_foot_lock_defaults`](../c/inverse-kinematics.md#sona_ik_foot_lock_defaults). |
| `fn ik_spine_defaults() -> sys::sona_ik_spine` | size set; weight 1, max_bend_deg 35, max_twist_deg 40, hips_share 0.2.<br>Calls [`sona_ik_spine_defaults`](../c/inverse-kinematics.md#sona_ik_spine_defaults). |
| `fn ik_fingers_defaults() -> sys::sona_ik_fingers` | size set; spread 0, weight 1, fade_seconds 0.15.<br>Calls [`sona_ik_fingers_defaults`](../c/inverse-kinematics.md#sona_ik_fingers_defaults). |
| `fn ik_eyes_defaults() -> sys::sona_ik_eyes` | size set; max_speed_deg 400, smoothing 0.05, lead_seconds 0.08.<br>Calls [`sona_ik_eyes_defaults`](../c/inverse-kinematics.md#sona_ik_eyes_defaults). |
| `fn emote_from_text(text: &str) -> Result<sys::sona_emote>` | A sentence to stock clips (with weights to blend), a speed and a face.<br>Calls [`sona_emote_from_text`](../c/text-to-emote.md#sona_emote_from_text). |

## Code

`struct Code(pub i32)`: A sona_result.

| Declaration | What it does |
|---|---|
| `fn name(self) -> &'static str` | The web SDK's word for it: "licence", "gate",...<br>Calls [`sona_result_name`](../c/results-and-errors.md#sona_result_name). |
| `fn is_error(self) -> bool` | True for a failed result (a negative sona_result). |

## Error

`struct Error`: An error: the code, what happened and what to do about it.

| Declaration | What it does |
|---|---|
| `fn new(code: Code, message: impl Into<String>, fix: impl Into<String>) -> Error` | An Error from a code, a message and a fix. |

## Request

`struct Request`: One read in flight.

| Declaration | What it does |
|---|---|
| `fn id(&self) -> RequestId` | The read's id, as the source was given it. |
| `fn complete(self, bytes: &[u8])` | The container bytes as stored (YTGR, raw STRB or an STFS package); the core copies them. |
| `fn not_found(self)` | This source does not have it; the next source is asked. |
| `fn failed(self)` | It failed; the core retries later. |
| `fn finish(self, status: Code, bytes: &[u8])` | Finishes one read, exactly once, also after cancel; the request stays valid until then.<br>Calls [`sona_complete`](../c/asset-sources.md#sona_complete). |

## Config

`struct Config`: What Context::open needs.

| Declaration | What it does |
|---|---|
| `fn new() -> Config` | Sets abi and leaves everything else at its default.<br>Calls [`sona_config_defaults`](../c/the-context.md#sona_config_defaults). |
| `fn app_id(mut self, id: &str) -> Self` | None (the default): the app id stamped into this build. |
| `fn licence(mut self, bytes: impl Into<Vec<u8>>) -> Self` | The bytes of sona-licence.json from your download. |
| `fn licence_file(self, path: impl AsRef<Path>) -> std::io::Result<Self>` | Reads the licence from a file into the config. |
| `fn dir(mut self, path: impl AsRef<Path>) -> Self` | A folder of item files you own, laid out as the gate serves them. |
| `fn console(mut self, content_root: impl AsRef<Path>) -> Self` | A console's Content root, or a PC folder holding a copy of one. |
| `fn gate(mut self, base: Option<&str>) -> Self` | The 360sona gate; None for https://360sona.com/g. |
| `fn source(mut self, s: impl Source + 'static) -> Self` | A host-written source. The C type sona_source. |
| `fn worker_threads(mut self, n: i32) -> Self` | -1: cores - 1 (default); 0: none, work runs inside update. |
| `fn seed(mut self, seed: u32) -> Self` | 0: from the clock. |
| `fn max_avatars(mut self, n: u32) -> Self` | Default 256, at most 16384. The C field sona_config.max_avatars (count). |
| `fn build_budget_ms(mut self, ms: f32) -> Self` | owner-thread loading work per sona_update (steps, commits; builds run on the workers); default 6. The C field sona_config.build_budget_ms (ms). |
| `fn face_size(mut self, px: u32) -> Self` | 0: auto; or 128, 256, 512. |
| `fn flags(mut self, flags: u32) -> Self` | sona_sys::SONA_CFG_* |
| `fn budget(mut self, b: Budget) -> Self` | The C field sona_config.budget (a sona_budget (see its fields)). |
| `fn check_host(mut self, host: &str) -> Self` | NULL: https://test.360sona.com, the devs site. The C field sona_config.check_host (text (UTF-8), NULL: none). |
| `fn log(mut self, f: impl Fn(LogLevel, &str) + Send + Sync + 'static) -> Self` | Called from any thread. |

## Context

`struct Context`: Owns a sona_ctx.

| Declaration | What it does |
|---|---|
| `fn open(cfg: Config) -> Result<Context>` | Checks the struct layout, then the licence.<br>Calls [`sona_open`](../c/the-context.md#sona_open). |
| `fn raw(&self) -> *mut sys::sona_ctx` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn app_id(&self) -> String` | The app id this context runs as.<br>Calls [`sona_app_id`](../c/the-context.md#sona_app_id). |
| `fn last_error(&self) -> Option<Error>` | The last error on a ctx.<br>Calls [`sona_last_error`](../c/results-and-errors.md#sona_last_error). |
| `fn frame(&self) -> Result<Frame<'_>>` | The context's one frame: updating and posing. |
| `fn add(&self, manifest: &[u8], opts: &AddOptions) -> Result<Avatar<'_>>` | Queues an avatar from its 1000 manifest bytes.<br>Calls [`sona_avatar_add`](../c/avatars.md#sona_avatar_add). |
| `fn add_manifest(&self, m: &Manifest, opts: &AddOptions) -> Result<Avatar<'_>>` | Adds an avatar from a Manifest (sona_avatar_add); it builds in the background. |
| `fn add_base64(&self, b64: &str, opts: &AddOptions) -> Result<Avatar<'_>>` | The same from base64 text (at most 4096 characters).<br>Calls [`sona_avatar_add_base64`](../c/avatars.md#sona_avatar_add_base64). |
| `fn add_waiting(&self, opts: &AddOptions) -> Result<Avatar<'_>>` | An avatar whose manifest is not known: QUEUED, a neutral figure while placeholders are on, until Avatar::set_manifest gives it one.<br>Calls [`sona_avatar_add_waiting`](../c/loading-placeholders.md#sona_avatar_add_waiting). |
| `fn poll_event(&self) -> Option<Event>` | The next event, or None when there are none; call it until it is None.<br>Calls [`sona_poll_event`](../c/events.md#sona_poll_event), [`sona_avatar_id`](../c/avatars.md#sona_avatar_id). |
| `fn clips(&self) -> Vec<ClipInfo>` | How many clips the context knows.<br>Calls [`sona_clip_count`](../c/clips.md#sona_clip_count), [`sona_clip_get`](../c/clips.md#sona_clip_get). |
| `fn stats(&self) -> SceneStats` | The scene statistics.<br>Calls [`sona_stats`](../c/the-frame.md#sona_stats). |
| `fn shading(&self) -> Result<Option<Shading>>` | None until the data files have loaded (SONA_PENDING).<br>Calls [`sona_shading_get`](../c/the-data-api.md#sona_shading_get). |
| `fn credit(&self, scale: u32) -> Result<Credit>` | The badge and its words.<br>Calls [`sona_credit_get`](../c/credit.md#sona_credit_get). |
| `fn png_encode(&self, rgba: &[u8], width: u32, height: u32) -> Result<Vec<u8>>` | PNG bytes with the web's three tEXt chunks (Software, Source, Comment).<br>Calls [`sona_png_encode`](../c/drawing-with-the-sdks-backends.md#sona_png_encode), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `fn fit_crowd(&self, view: &mut View)` | Fits every ready avatar (the web preset "crowd").<br>Calls [`sona_camera_fit_crowd`](../c/camera-helpers.md#sona_camera_fit_crowd). |
| `fn set_lod(&self, o: Option<&LodOptions>) -> Result<()>` | Level of detail and sprites from the next update.<br>Calls [`sona_lod_set`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_set). |
| `fn set_sway_world(&self, w: Option<&sys::sona_sway_world>) -> Result<()>` | The gravity and wind every swaying avatar feels; None for the defaults.<br>Calls [`sona_sway_world_set`](../c/hair-and-cloth-sway.md#sona_sway_world_set). |
| `fn lod(&self) -> Result<LodOptions>` | Copies the current options: before any sona_lod_set, thresholds 120 and 40 and no sprites (sprite_px 0).<br>Calls [`sona_lod_get`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_get). |
| `fn lod_stats(&self) -> LodStats` | The level-of-detail statistics: avatars in view at each step, those fading, the baked looks and the bakes of the last draw.<br>Calls [`sona_lod_stats_get`](../c/crowds-level-of-detail-and-sprites.md#sona_lod_stats_get). |
| `fn set_placeholders(&self, o: Option<&sys::sona_placeholder_options>) -> Result<()>` | Loading placeholders from the next update; None: placeholder_defaults.<br>Calls [`sona_placeholder_set`](../c/loading-placeholders.md#sona_placeholder_set). |
| `fn placeholders(&self) -> Result<Option<sys::sona_placeholder_options>>` | The options in use; None while placeholders are off.<br>Calls [`sona_placeholder_get`](../c/loading-placeholders.md#sona_placeholder_get). |
| `fn placeholders_off(&self) -> Result<()>` | Figures shown now fade out over appear_seconds.<br>Calls [`sona_placeholder_off`](../c/loading-placeholders.md#sona_placeholder_off). |
| `fn placeholder_stats(&self) -> sys::sona_placeholder_stats` | Figures in view at the last sona_update (by phase, and how many as sprites), how many were posed and the time that took, and the figure draws of the last sona_draw or sona_snapshot.<br>Calls [`sona_placeholder_stats_get`](../c/loading-placeholders.md#sona_placeholder_stats_get). |
| `fn pixel_art(&self, rgba: &[u8], width: u32, height: u32, opts: &PixelOptions) -> Result<Picture>` | Crisp pixel art from a straight RGBA8 picture (sona.h 3.12d): opaque or clear pixels, a small palette.<br>Calls [`sona_pixel_art`](../c/2d-outputs.md#sona_pixel_art). |
| `fn pixel_palette(&self, pictures: &[(&[u8], u32, u32)], colours: u32) -> Result<Vec<u32>>` | One palette (0xFFRRGGBB, darkest first) for several (rgba, width, height) pictures.<br>Calls [`sona_pixel_palette`](../c/2d-outputs.md#sona_pixel_palette). |
| `fn add_item_preview(&self, item_id: &str, opts: &PreviewOptions) -> Result<Avatar<'_>>` | One item worn alone on a grey stand-in body, framed by its slot.<br>Calls [`sona_item_preview_add`](../c/item-previews.md#sona_item_preview_add). |
| `fn start_interaction(&self, desc: &sys::sona_interaction_desc) -> Result<Interaction<'_>>` | Starts an interaction; fill the desc from interaction_defaults and set a and b (or b null for SIT) from Avatar::raw.<br>Calls [`sona_interaction_start`](../c/two-avatar-interactions-and-seats.md#sona_interaction_start). |
| `fn param_id(&self, name: &str) -> Option<u32>` | The id of a parameter name, numbered from 0 in the order first asked for; None for a bad name or past 32.<br>Calls [`sona_param_id`](../c/animation-layers.md#sona_param_id). |
| `fn blend_space(&self, param_x: &str, param_y: Option<&str>, samples: &[BlendSample<'_>], unsynced: bool, smooth_seconds: f32,) -> Result<BlendSpace<'_>>` | A blend space over param_x (and param_y when 2D); one serves every avatar of the context.<br>Calls [`sona_blend_space_defaults`](../c/animation-layers.md#sona_blend_space_defaults), [`sona_blend_space_create`](../c/animation-layers.md#sona_blend_space_create). |
| `fn state_machine(&self, states: &[StateSpec<'_>], transitions: &[TransitionSpec<'_>], initial: Option<&str>,) -> Result<StateMachine<'_>>` | A state machine; one serves every avatar of the context.<br>Calls [`sona_state_machine_defaults`](../c/animation-layers.md#sona_state_machine_defaults), [`sona_state_machine_create`](../c/animation-layers.md#sona_state_machine_create). |
| `fn prop_mesh(&self, parts: &[sys::sona_prop_part]) -> Result<PropMesh<'_>>` | A prop mesh from triangles; the parts' pointers need to live only for the call.<br>Calls [`sona_prop_mesh_create`](../c/props-held-and-worn-objects.md#sona_prop_mesh_create). |
| `fn prop_mesh_load(&self, bytes: &[u8], options: Option<&sys::sona_prop_load_options>) -> Result<PropMesh<'_>>` | A glTF 2.0 file (.glb, or.gltf with embedded buffers) as a prop mesh.<br>Calls [`sona_prop_mesh_load`](../c/props-held-and-worn-objects.md#sona_prop_mesh_load). |
| `fn prop_mesh_stock(&self, item_id: &str) -> Result<PropMesh<'_>>` | A stock prop item (a carryable) of the catalogue; its state is SONA_PENDING until it has loaded.<br>Calls [`sona_prop_mesh_stock`](../c/props-held-and-worn-objects.md#sona_prop_mesh_stock). |
| `fn pick_ray(&self, origin: [f32; 3], dir: [f32; 3], o: &PickOptions) -> Result<Option<PickHit>>` | The nearest hit along the ray; None when nothing is hit. |
| `fn pick_screen(&self, view: &View, x: f64, y: f64, o: &PickOptions) -> Result<Option<PickHit>>` | The nearest hit under (x, y) of the view's picture, sprites facing that view.<br>Calls [`sona_pick_screen`](../c/picking.md#sona_pick_screen). |
| `fn pick_ray_all(&self, origin: [f32; 3], dir: [f32; 3], cap: usize, o: &PickOptions) -> Vec<PickHit>` | Every avatar the ray hits, its nearest hit each, nearest first (at most cap). |
| `fn tier_apply(&self, renderer: Option<*mut sys::sona_renderer>, o: Option<&sys::sona_tier_options>) -> Result<()>` | Quality for a class of device on the ctx and, with one, a renderer.<br>Calls [`sona_tier_apply`](../c/rendering-quality.md#sona_tier_apply). |
| `fn item_colourways(&self, item_id: &str) -> Result<Option<Vec<[u32; 3]>>>` | An item's colourways (0xFFRRGGBB primary, secondary, tertiary). |
| `fn custom_item_pack_mesh(&self, m: &MeshItem) -> Result<Option<Vec<u8>>>` | A.sonaitem (format 1.1) from your own skinned glTF binary.<br>Calls [`sona_mesh_item_spec_defaults`](../c/custom-items.md#sona_mesh_item_spec_defaults), [`sona_custom_item_pack_mesh`](../c/custom-items.md#sona_custom_item_pack_mesh), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `fn award_define(&self, key: &str, title: &str, description: &str, item: &str, developer_key: &str) -> Result<u32>` | Defines an award item for the app (tools only: it takes the developer key).<br>Calls [`sona_award_def_defaults`](../c/award-items.md#sona_award_def_defaults), [`sona_award_define`](../c/award-items.md#sona_award_define). |
| `fn award_unlock(&self, player_token: &str, key: &str) -> Result<u32>` | Unlocks an award for a signed-in player.<br>Calls [`sona_award_unlock`](../c/award-items.md#sona_award_unlock). |
| `fn award_poll(&self, ticket: u32) -> Result<bool>` | Ok(false) while it runs, then Ok(true) once, or how it failed.<br>Calls [`sona_award_poll`](../c/award-items.md#sona_award_poll). |

## Interaction

`struct Interaction<'c>`: A running two-avatar interaction or seat.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> *mut sys::sona_interaction` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn end(&mut self) -> Result<()>` | Begins the end phase: letting go, standing up.<br>Calls [`sona_interaction_end`](../c/two-avatar-interactions-and-seats.md#sona_interaction_end). |
| `fn move_to(&mut self, position: [f32; 3], turn_deg: f32) -> Result<()>` | Moves the place (or the seat) while it runs. |
| `fn status(&self) -> Result<sys::sona_interaction_status>` | Where an interaction is: its kind and phase, the time in the phase and how far through it, whether the contacts are together, the widest gap at a contact, the clearance between the two bodies (negative: into each other),<br>Calls [`sona_interaction_status_get`](../c/two-avatar-interactions-and-seats.md#sona_interaction_status_get). |
| `fn events(&mut self) -> Vec<sys::sona_interaction_event>` | The events since the last call, oldest first.<br>Calls [`sona_interaction_events`](../c/two-avatar-interactions-and-seats.md#sona_interaction_events). |

## Frame

`struct Frame<'c>`: Updating and posing.

| Declaration | What it does |
|---|---|
| `fn update(&mut self, dt_seconds: f64, view: Option<&View>) -> Result<FrameStats>` | Advances every avatar by dt (clamped to 0..0.1 s), builds inside the budget, culls and poses.<br>Calls [`sona_update`](../c/the-frame.md#sona_update). |
| `fn pose<'a>(&'a self, avatar: &'a mut Avatar<'c>) -> Result<Pose<'a>>` | The avatar's pose as of the last update.<br>Calls [`sona_pose`](../c/the-data-api.md#sona_pose). |
| `fn pose_vertices(&self, avatar: &mut Avatar<'c>, mesh: u32, space: Space, positions: &mut [f32], normals: Option<&mut [f32]>, stride_floats: usize,) -> Result<()>` | CPU skinning of one mesh.<br>Calls [`sona_pose_vertices`](../c/the-data-api.md#sona_pose_vertices). |

## AvatarState

`enum AvatarState`: The C type sona_avatar_state.

| Declaration | What it does |
|---|---|
| `fn settled(self) -> bool` | Ready or failed: nothing more will happen without a new clip or manifest. |

## AddOptions

`struct AddOptions`: The C type sona_add_options.

| Declaration | What it does |
|---|---|
| `fn clip(mut self, clip: &str) -> Self` | A clip key, a raw clip id, "prop", "idle" or "still"; NULL: "idle". The C field sona_add_options.clip (text (UTF-8), NULL: none). |
| `fn start_at(mut self, seconds: f32) -> Self` | Seconds; negative means random, to desynchronise a crowd. The C field sona_add_options.start_at (s). |

## Avatar

`struct Avatar<'c>`: One avatar in a context.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> *mut sys::sona_avatar` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn id(&self) -> u32` | Unique within the context; events name avatars by it.<br>Calls [`sona_avatar_id`](../c/avatars.md#sona_avatar_id). |
| `fn state(&self) -> AvatarState` | The avatar's state.<br>Calls [`sona_avatar_state_of`](../c/avatars.md#sona_avatar_state_of). |
| `fn export(&self, opts: &ExportOptions) -> Result<(Vec<u8>, ExportReport)>` | The avatar as a.vrm (1.0 or 0.x) or.glb file, and what went into it.<br>Calls [`sona_export_defaults`](../c/skeleton-maps-and-vrm-export.md#sona_export_defaults), [`sona_export_avatar`](../c/skeleton-maps-and-vrm-export.md#sona_export_avatar), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |
| `fn play(&mut self, clip: &str, opts: &PlayOptions) -> Result<()>` | Before READY it is remembered and applied when the avatar appears.<br>Calls [`sona_avatar_play`](../c/avatars.md#sona_avatar_play). |
| `fn stop(&mut self)` | Holds the current pose.<br>Calls [`sona_avatar_stop`](../c/avatars.md#sona_avatar_stop). |
| `fn move_to(&mut self, to: &Placement, over_seconds: f32)` | Moves the avatar to a new placement over over_seconds.<br>Calls [`sona_avatar_move`](../c/avatars.md#sona_avatar_move). |
| `fn set_visible(&mut self, visible: bool)` | Shows or hides it.<br>Calls [`sona_avatar_set_visible`](../c/avatars.md#sona_avatar_set_visible). |
| `fn bounds(&self) -> ([f32; 3], f32)` | (centre, radius) |
| `fn camera_preset(&self, preset: Preset, view: &mut View) -> Result<()>` | Sets view.eye and view.target to one of the console's framings on this (ready) avatar.<br>Calls [`sona_camera_preset`](../c/camera-helpers.md#sona_camera_preset). |
| `fn remove(self)` | Frees what only it used. |
| `fn joint_world(&self, joint: u32) -> Result<[f32; 16]>` | A joint's world matrix at the last update: row-vector, metres, the placement applied. |
| `fn set_override(&mut self, joint: u32, rotation: Option<[f32; 4]>, weight: f32, mode: OverrideMode) -> Result<()>` | A pose override, applied after the clip each frame. |
| `fn clear_overrides(&mut self)` | Clears every override of the avatar.<br>Calls [`sona_avatar_clear_overrides`](../c/game-features.md#sona_avatar_clear_overrides). |
| `fn crossfade(&mut self, clip: &str, opts: &PlayOptions, seconds: f32) -> Result<()>` | Avatar::play, blending from the current pose over seconds (0: a cut).<br>Calls [`sona_avatar_crossfade`](../c/game-features.md#sona_avatar_crossfade). |
| `fn queue(&mut self, clip: &str, opts: &PlayOptions, fade_seconds: f32) -> Result<()>` | Plays clip when the current one ends.<br>Calls [`sona_avatar_queue`](../c/game-features.md#sona_avatar_queue). |
| `fn queued(&self) -> u32` | How many clips are waiting in the queue.<br>Calls [`sona_avatar_queued`](../c/game-features.md#sona_avatar_queued). |
| `fn capsule(&self) -> Result<Capsule>` | A vertical capsule around the posed body, in world space.<br>Calls [`sona_avatar_capsule`](../c/game-features.md#sona_avatar_capsule). |
| `fn set_expression(&mut self, values: Option<[u8; 5]>) -> Result<()>` | mouth, left eyebrow, right eyebrow, left eye, right eye: a shape index, or 255 to leave that part to the clip. |
| `fn attach_prop(&mut self, mesh: &PropMesh<'_>, options: Option<&sys::sona_prop_attach>) -> Result<u32>` | Attaches a prop mesh; returns its id on this avatar.<br>Calls [`sona_avatar_prop_attach`](../c/props-held-and-worn-objects.md#sona_avatar_prop_attach). |
| `fn set_prop(&mut self, id: u32, options: &sys::sona_prop_attach) -> Result<()>` | New placement, flags or hand for an attached prop (each frame for one that moves on the joint).<br>Calls [`sona_avatar_prop_set`](../c/props-held-and-worn-objects.md#sona_avatar_prop_set). |
| `fn swap_prop(&mut self, id: u32, mesh: &PropMesh<'_>) -> Result<()>` | Another mesh in the same place: a sword for a stick, an item for a placeholder.<br>Calls [`sona_avatar_prop_swap`](../c/props-held-and-worn-objects.md#sona_avatar_prop_swap). |
| `fn detach_prop(&mut self, id: u32) -> Result<()>` | Takes the prop off at once (its hand's IK target eases off).<br>Calls [`sona_avatar_prop_detach`](../c/props-held-and-worn-objects.md#sona_avatar_prop_detach). |
| `fn detach_all_props(&mut self)` | Takes every prop off the avatar at once.<br>Calls [`sona_avatar_prop_detach_all`](../c/props-held-and-worn-objects.md#sona_avatar_prop_detach_all). |
| `fn props(&self) -> Vec<u32>` | The ids of the avatar's props, in attach order.<br>Calls [`sona_avatar_prop_list`](../c/props-held-and-worn-objects.md#sona_avatar_prop_list). |
| `fn prop_frame(&self, id: u32) -> Result<sys::sona_prop_frame>` | One prop as the last update posed it (its palette pointer is valid until the next update).<br>Calls [`sona_avatar_prop_frame`](../c/props-held-and-worn-objects.md#sona_avatar_prop_frame). |
| `fn set_ik_target(&mut self, limb: u32, target: Option<&sys::sona_ik_target>) -> Result<()>` | A hand or foot target (sona_sys::SONA_IK_LEFT_HAND..<br>Calls [`sona_avatar_ik_target`](../c/inverse-kinematics.md#sona_avatar_ik_target). |
| `fn set_ik_feet(&mut self, feet: Option<&sys::sona_ik_feet>) -> Result<()>` | Foot planting; None turns it off.<br>Calls [`sona_avatar_ik_feet`](../c/inverse-kinematics.md#sona_avatar_ik_feet). |
| `fn set_ik_ground(&mut self, foot: u32, ground: Option<([f32; 3], [f32; 3])>) -> Result<()>` | SONA_IK_GROUND_POINTS: the ground under one foot; None for no ground there. |
| `fn set_style(&mut self, style: Option<&Style>) -> Result<()>` | The avatar's own art style; None clears it and the renderer's applies.<br>Calls [`sona_avatar_set_style`](../c/art-styles.md#sona_avatar_set_style). |
| `fn style(&self) -> Result<Style>` | The avatar's own art style (style_defaults when it has none).<br>Calls [`sona_avatar_style`](../c/art-styles.md#sona_avatar_style). |
| `fn set_ik_look(&mut self, look: Option<&sys::sona_ik_look>) -> Result<()>` | Look-at; None eases back to the clip.<br>Calls [`sona_avatar_ik_look`](../c/inverse-kinematics.md#sona_avatar_ik_look). |
| `fn set_ik_limits(&mut self, limits: Option<&sys::sona_ik_limits>) -> Result<()>` | Joint limits and the body checks; None for the defaults.<br>Calls [`sona_avatar_ik_limits`](../c/inverse-kinematics.md#sona_avatar_ik_limits). |
| `fn clear_ik(&mut self)` | Every target, the planting and the look-at off at once.<br>Calls [`sona_avatar_ik_clear`](../c/inverse-kinematics.md#sona_avatar_ik_clear). |
| `fn set_placeholder(&mut self, mode: i32) -> Result<()>` | Its loading placeholder: -1 follows the context, 0 never, 1 always.<br>Calls [`sona_avatar_placeholder`](../c/loading-placeholders.md#sona_avatar_placeholder). |
| `fn placeholder(&self) -> Result<sys::sona_placeholder_info>` | The avatar's figure at the last sona_update: its phase, opacity, height, which figure (male, female or neutral), whether it plays the avatar's clip, the seconds since the avatar was added and whether it is drawn as a s<br>Calls [`sona_avatar_placeholder_info`](../c/loading-placeholders.md#sona_avatar_placeholder_info). |
| `fn set_manifest(&mut self, manifest: &[u8]) -> Result<()>` | The manifest of an avatar added with Context::add_waiting, once.<br>Calls [`sona_avatar_set_manifest`](../c/loading-placeholders.md#sona_avatar_set_manifest). |
| `fn set_manifest_base64(&mut self, b64: &str) -> Result<()>` | sona_avatar_set_manifest with the manifest as base64 text.<br>Calls [`sona_avatar_set_manifest_base64`](../c/loading-placeholders.md#sona_avatar_set_manifest_base64). |
| `fn ik_status(&self) -> Result<sys::sona_ik_status>` | What the last pose did.<br>Calls [`sona_avatar_ik_status`](../c/inverse-kinematics.md#sona_avatar_ik_status). |
| `fn ragdoll(&mut self, options: Option<&sys::sona_ragdoll_options>) -> Result<Vec<sys::sona_ragdoll_body>>` | The ragdoll bodies fitted to this avatar now (colliders, masses, joints and limits), for any physics engine; starts the pose history ragdoll_state takes velocities from.<br>Calls [`sona_avatar_ragdoll`](../c/ragdolls.md#sona_avatar_ragdoll). |
| `fn ragdoll_state(&self) -> Result<Vec<sys::sona_ragdoll_state>>` | The bodies at the last pose with their velocities.<br>Calls [`sona_avatar_ragdoll_state`](../c/ragdolls.md#sona_avatar_ragdoll_state). |
| `fn ragdoll_drive(&mut self, bodies: Option<&[sys::sona_ragdoll_state]>, weight: f32, flags: u32) -> Result<()>` | The host's simulated bodies onto the avatar from the next pose; weight 0..1 blends from the clip; None stops.<br>Calls [`sona_avatar_ragdoll_drive`](../c/ragdolls.md#sona_avatar_ragdoll_drive). |
| `fn ragdoll_release(&mut self, blend_seconds: f32) -> Result<()>` | Back to the clip, blending from the last ragdoll pose over blend_seconds.<br>Calls [`sona_avatar_ragdoll_release`](../c/ragdolls.md#sona_avatar_ragdoll_release). |
| `fn ragdoll_info(&self) -> Result<sys::sona_ragdoll_info>` | The mode, the blend, where it lies and how to get up.<br>Calls [`sona_avatar_ragdoll_info`](../c/ragdolls.md#sona_avatar_ragdoll_info). |
| `fn ragdoll_clear(&mut self)` | Off at once: no tracking, no drive, no blend.<br>Calls [`sona_avatar_ragdoll_clear`](../c/ragdolls.md#sona_avatar_ragdoll_clear). |
| `fn set_sway(&mut self, o: Option<&sys::sona_sway>) -> Result<()>` | Hair and cloth sway; None turns it off.<br>Calls [`sona_avatar_sway`](../c/hair-and-cloth-sway.md#sona_avatar_sway). |
| `fn reset_sway(&mut self)` | Back to the modelled shape at the next pose.<br>Calls [`sona_avatar_sway_reset`](../c/hair-and-cloth-sway.md#sona_avatar_sway_reset). |
| `fn sway_info(&self) -> Result<sys::sona_sway_info>` | What sways and what the last pose did.<br>Calls [`sona_avatar_sway_info`](../c/hair-and-cloth-sway.md#sona_avatar_sway_info). |
| `fn sway_mesh_parts(&self, mesh: u32) -> u32` | The SONA_SWAY_* kinds one of the pose's meshes sways with.<br>Calls [`sona_avatar_sway_mesh_parts`](../c/hair-and-cloth-sway.md#sona_avatar_sway_mesh_parts). |
| `fn set_mouth(&mut self, shape: u8) -> Result<()>` | Only the mouth: a SONA_MOUTH_* or shape index, or 255 to hand it back to the clip.<br>Calls [`sona_avatar_mouth`](../c/lip-sync-and-voice-mouths.md#sona_avatar_mouth). |
| `fn voice(&mut self, state: &mut VoiceMouth, level: f32, dt: f32) -> Result<()>` | Voice chat: this speaker's audio level (linear RMS) moves the mouth.<br>Calls [`sona_avatar_voice`](../c/lip-sync-and-voice-mouths.md#sona_avatar_voice). |
| `fn expression_counts(&self) -> Result<[u32; 3]>` | Shapes this face has: mouths, eyebrows, eyes. |
| `fn clip_events(&mut self) -> Vec<ClipEvent>` | What happened on the clip since the last call, oldest first.<br>Calls [`sona_avatar_clip_events`](../c/game-features.md#sona_avatar_clip_events). |
| `fn mark(&mut self, seconds: f32, id: u32) -> Result<()>` | A ClipEventKind::Mark with this id each time the current clip passes seconds.<br>Calls [`sona_avatar_mark`](../c/game-features.md#sona_avatar_mark). |
| `fn clear_marks(&mut self)` | Removes the avatar's marks.<br>Calls [`sona_avatar_clear_marks`](../c/game-features.md#sona_avatar_clear_marks). |
| `fn set_root_motion(&mut self, mode: RootMotion) -> Result<()>` | What happens to the clip's sideways travel of the hips.<br>Calls [`sona_avatar_root_motion`](../c/game-features.md#sona_avatar_root_motion). |
| `fn take_root_motion(&mut self) -> Result<[f32; 3]>` | The travel collected since the last call, in world metres; clears it. |
| `fn lod(&self) -> (Lod, f32)` | The step at the last update, and how far it is from mesh (0) to sprite (1).<br>Calls [`sona_avatar_lod`](../c/crowds-level-of-detail-and-sprites.md#sona_avatar_lod). |
| `fn layer_play(&mut self, layer: u32, clip: &str, opts: &LayerOptions) -> Result<()>` | Plays a clip key or raw clip id on a layer (0..7), over the avatar's own clip.<br>Calls [`sona_avatar_layer_play`](../c/animation-layers.md#sona_avatar_layer_play). |
| `fn layer_blend(&mut self, layer: u32, blend: &BlendSpace<'c>, opts: &LayerOptions) -> Result<()>` | Plays a blend space of the same ctx on the layer.<br>Calls [`sona_avatar_layer_blend`](../c/animation-layers.md#sona_avatar_layer_blend). |
| `fn layer_machine(&mut self, layer: u32, machine: &StateMachine<'c>, opts: &LayerOptions) -> Result<()>` | Runs a state machine of the same ctx on the layer from its initial state (a STATE event with from_state -1).<br>Calls [`sona_avatar_layer_machine`](../c/animation-layers.md#sona_avatar_layer_machine). |
| `fn layer_goto(&mut self, layer: u32, state: u32, fade_seconds: f32) -> Result<()>` | Sends a machine layer to a state now, crossfading over fade_seconds.<br>Calls [`sona_avatar_layer_goto`](../c/animation-layers.md#sona_avatar_layer_goto). |
| `fn layer_weight(&mut self, layer: u32, weight: f32, over_seconds: f32) -> Result<()>` | Moves the layer's weight linearly to weight (0..1) over over_seconds; 0 or less sets it at once.<br>Calls [`sona_avatar_layer_weight`](../c/animation-layers.md#sona_avatar_layer_weight). |
| `fn layer_mask(&mut self, layer: u32, mask: Option<&[f32; sys::SONA_JOINT_COUNT]>) -> Result<()>` | None: every joint. |
| `fn layer_stop(&mut self, layer: u32, fade_seconds: f32) -> Result<()>` | Fades the layer out over fade_seconds and then empties it (a STOPPED event); 0 empties it now.<br>Calls [`sona_avatar_layer_stop`](../c/animation-layers.md#sona_avatar_layer_stop). |
| `fn layer_info(&self, layer: u32) -> Result<LayerInfo>` | The layer now: kind, mode, state (machines, else -1), clip (the sona_clip_get index, -1 for a raw id), weight with fades, time and normalized through the clip or cycle, ready (its clips have loaded) and<br>Calls [`sona_avatar_layer_info`](../c/animation-layers.md#sona_avatar_layer_info). |
| `fn layer_events(&mut self) -> Vec<LayerEvent>` | What happened on the layers since the last call, oldest first.<br>Calls [`sona_avatar_layer_events`](../c/animation-layers.md#sona_avatar_layer_events). |
| `fn set_param(&mut self, param: u32, value: f32) -> Result<()>` | Sets one parameter on the avatar; read at the next sona_update.<br>Calls [`sona_avatar_set_param`](../c/animation-layers.md#sona_avatar_set_param). |
| `fn set_params(&mut self, first: u32, values: &[f32]) -> Result<()>` | Parameters first..<br>Calls [`sona_avatar_set_params`](../c/animation-layers.md#sona_avatar_set_params). |
| `fn param(&self, param: u32) -> f32` | A parameter's value; 0 when unset or unknown.<br>Calls [`sona_avatar_param`](../c/animation-layers.md#sona_avatar_param). |
| `fn preview_bounds(&mut self) -> Result<([f32; 3], [f32; 3])>` | The previewed item's world box (lo, hi). |
| `fn preview_view(&mut self, width: u32, height: u32) -> Result<View>` | The framed camera for a width x height picture of this preview.<br>Calls [`sona_item_preview_view`](../c/item-previews.md#sona_item_preview_view). |
| `fn play_stock(&mut self, id: u32, opts: Option<&PlayOptions>, fade_seconds: f32) -> Result<()>` | A stock clip (an id from stock_clip_find), the variant for this avatar's body; fade_seconds > 0 crossfades.<br>Calls [`sona_avatar_play_stock`](../c/stock-clips.md#sona_avatar_play_stock). |
| `fn set_idle(&mut self, o: Option<&IdleOptions>) -> Result<()>` | The procedural idle (blinks, glances, weight shifts, breathing over any clip); None turns it off.<br>Calls [`sona_avatar_idle`](../c/stock-clips.md#sona_avatar_idle). |
| `fn idle_options(&self) -> Result<IdleOptions>` | The idle's options in use, seed resolved; parts 0 when off.<br>Calls [`sona_avatar_idle_get`](../c/stock-clips.md#sona_avatar_idle_get). |
| `fn idle_state(&self) -> Result<IdleState>` | What the idle gave the last pose.<br>Calls [`sona_avatar_idle_state`](../c/stock-clips.md#sona_avatar_idle_state). |
| `fn pick(&self, origin: [f32; 3], dir: [f32; 3], o: &PickOptions) -> Result<Option<PickHit>>` | The ray against this avatar alone; None when it misses. |
| `fn ik_foot_lock(&mut self, o: Option<&sys::sona_ik_foot_lock>) -> Result<()>` | Foot locking: planted feet stay where they landed.<br>Calls [`sona_avatar_ik_foot_lock`](../c/inverse-kinematics.md#sona_avatar_ik_foot_lock). |
| `fn ik_spine(&mut self, o: Option<&sys::sona_ik_spine>) -> Result<()>` | Spine assist for hand targets past reach.<br>Calls [`sona_avatar_ik_spine`](../c/inverse-kinematics.md#sona_avatar_ik_spine). |
| `fn ik_fingers(&mut self, hand: u32, o: Option<&sys::sona_ik_fingers>) -> Result<()>` | Finger curl over the clip's, for SONA_IK_LEFT_HAND or SONA_IK_RIGHT_HAND.<br>Calls [`sona_avatar_ik_fingers`](../c/inverse-kinematics.md#sona_avatar_ik_fingers). |
| `fn ik_eyes(&mut self, o: Option<&sys::sona_ik_eyes>) -> Result<()>` | Eye turns under look-at.<br>Calls [`sona_avatar_ik_eyes`](../c/inverse-kinematics.md#sona_avatar_ik_eyes). |
| `fn ragdoll_motors(&self) -> Result<Vec<sys::sona_ragdoll_motor>>` | The joint motor targets of the last pose, in ragdoll's order.<br>Calls [`sona_avatar_ragdoll_motors`](../c/ragdolls.md#sona_avatar_ragdoll_motors). |
| `fn emote(&mut self, e: &sys::sona_emote, fade_seconds: f32) -> Result<()>` | Plays an emote_from_text answer on the emote layers, faded in over fade_seconds.<br>Calls [`sona_avatar_emote`](../c/text-to-emote.md#sona_avatar_emote). |

## StockClip

`struct StockClip`: One stock clip.

| Declaration | What it does |
|---|---|
| `fn tag_names(&self) -> Vec<&'static str>` | The tag names, in bit order. |

## Pose

`struct Pose<'a>`: A view over sona_pose_data, valid until the next Frame::update.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> &'a sys::sona_pose_data` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn build_version(&self) -> u32` | Bumps when meshes, materials or textures change. |
| `fn world(&self) -> &'a [f32; 16]` | W = scale * rotateY(turn) * translate(position), row-vector. |
| `fn palette(&self) -> &'a [f32]` | 864 floats: per joint 3 float4, columns 0..2 of the row-vector skin matrix, avatar space. |
| `fn view_joints(&self) -> &'a [f32]` | 72 * 3 floats: each joint's translation before W. |
| `fn meshes(&self) -> &'a [Mesh]` | In draw order. |
| `fn materials(&self) -> &'a [Material]` | The C field sona_pose_data.materials (pointer to sona_material). |
| `fn textures(&self) -> &'a [Texture]` | The face sheet is one of them (its material has SONA_MAT_FACE). The C field sona_pose_data.textures (pointer to sona_texture). |
| `fn props(&self) -> &'a [PropPalette]` | Size arrays by prop_count, which can pass 4. The C field sona_pose_data.props (pointer to sona_prop_palette). |
| `fn expression(&self) -> [u8; 5]` | mouth, left eyebrow, right eyebrow, left eye, right eye |

## Mesh

`struct Mesh(sys::sona_mesh)`: One mesh: 76-byte vertices in host byte order and a u16 triangle list.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> &sys::sona_mesh` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn item(&self) -> &str` | The item it came from. The C field sona_mesh.item (text (UTF-8)). |
| `fn mask(&self) -> u32` | The item's AssetMask. The C field sona_mesh.mask (bit flags). |
| `fn batch(&self) -> u32` | The C field sona_mesh.batch (count). |
| `fn material(&self) -> u32` | Index into Pose::materials. |
| `fn pass(&self) -> Pass` | The C field sona_mesh.pass (sona_pass value). |
| `fn palette(&self) -> Option<usize>` | None: the body palette; else an index into Pose::props. |
| `fn vertex_count(&self) -> u32` | The C field sona_mesh.vertex_count (count). |
| `fn index_count(&self) -> u32` | The C field sona_mesh.index_count (count). |
| `fn vertices(&self) -> &[u8]` | Vertex_count * 76 bytes. The C field sona_mesh.vertices (pointer). |
| `fn indices(&self) -> &[u16]` | Triangle list. The C field sona_mesh.indices (pointer). |
| `fn key(&self) -> u32` | Stable while the geometry lives; shared by avatars wearing the same item. |

## Texture

`struct Texture(sys::sona_texture)`: The C type sona_texture.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> &sys::sona_texture` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn key(&self) -> u32` | Stable while the texture lives; use it to cache uploads. |
| `fn version(&self) -> u32` | Bumps when the pixels change (the face sheet). |
| `fn format(&self) -> i32` | sona_sys::SONA_TEX_* |
| `fn width(&self) -> u32` | The C field sona_texture.width (px). |
| `fn height(&self) -> u32` | The C field sona_texture.height (px). |
| `fn data(&self) -> &[u8]` | Width * height * 4 bytes for RGBA8. The C field sona_texture.data (pointer). |

## PropPalette

`struct PropPalette(sys::sona_prop_palette)`: The C type sona_prop_palette.

| Declaration | What it does |
|---|---|
| `fn item(&self) -> &str` | The C field sona_prop_palette.item (text (UTF-8)). |
| `fn playing(&self) -> bool` | While the prop's own clip plays; when false its meshes are not drawn. |
| `fn palette(&self) -> &[f32]` | 864 floats. The C field sona_prop_palette.palette (pointer). |

## Manifest

`struct Manifest`: An avatar's description and its edit verbs: wear, take off, colours, gender, body shape.

| Declaration | What it does |
|---|---|
| `fn parse(bytes: &[u8]) -> Result<Manifest>` | Reads 1000 bytes into a sona_manifest.<br>Calls [`sona_manifest_parse`](../c/manifests.md#sona_manifest_parse). |
| `fn from_base64(text: &str) -> Result<Manifest>` | A manifest from base64 text, as the web SDK and the lookup routes give them. |
| `fn to_bytes(&self) -> Result<Vec<u8>>` | Byte-exact: parse(x).to_bytes == x.<br>Calls [`sona_manifest_write`](../c/manifests.md#sona_manifest_write). |
| `fn raw(&self) -> &sys::sona_manifest` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn raw_mut(&mut self) -> &mut sys::sona_manifest` | The C struct sona_manifest, to change it field by field. |
| `fn gender(&self) -> u32` | 1 male, 2 female, 0 unknown. |
| `fn valid(&self) -> bool` | Derived: IsValid. The C field sona_manifest.valid (flag (0 or 1)). |
| `fn wear(&mut self, item: &Guid, colours: [u32; 3], flags: u32) -> Result<()>` | sona_sys::SONA_EDIT_* flags. |
| `fn unwear(&mut self, slot_mask: u32, flags: u32) -> Result<()>` | Takes off what is in the slots of slot_mask.<br>Calls [`sona_manifest_unwear`](../c/manifests.md#sona_manifest_unwear). |
| `fn undress_all(&mut self) -> Result<()>` | Takes everything off.<br>Calls [`sona_manifest_undress_all`](../c/manifests.md#sona_manifest_undress_all). |
| `fn set_colour(&mut self, colour_slot: u32, argb: u32) -> Result<()>` | Sets one of the nine body colours, by its index in colours.<br>Calls [`sona_manifest_set_colour`](../c/manifests.md#sona_manifest_set_colour). |
| `fn set_gender(&mut self, gender: u32, flags: u32) -> Result<()>` | Sets the gender: 1 male, 2 female.<br>Calls [`sona_manifest_set_gender`](../c/manifests.md#sona_manifest_set_gender). |
| `fn set_shape(&mut self, weight: f32, height: f32) -> Result<()>` | Sets the weight and height.<br>Calls [`sona_manifest_set_shape`](../c/manifests.md#sona_manifest_set_shape). |
| `fn ready_for_xbox(&self) -> bool` | 1 when the body (and so the gender) is known and the editor's Xbox clean-up would change nothing: the manifest can be saved to Xbox as it is.<br>Calls [`sona_manifest_ready_for_xbox`](../c/manifests.md#sona_manifest_ready_for_xbox). |

## Renderer

`struct Renderer<'c>`: Owns a sona_renderer over a device the host owns.

| Declaration | What it does |
|---|---|
| `unsafe fn new(ctx: &'c Context, dev: &sys::sona_device_desc) -> Result<Option<Renderer<'c>>>` | Ok(None) while the shading data has not arrived (SONA_PENDING): update and try again.<br>Calls [`sona_renderer_create`](../c/drawing-with-the-sdks-backends.md#sona_renderer_create). |
| `fn raw(&self) -> *mut sys::sona_renderer` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `unsafe fn draw(&mut self, view: &View, target: &sys::sona_target, opts: Option<&DrawOptions>) -> Result<Code>` | Draws every visible ready avatar into the target.<br>Calls [`sona_draw`](../c/drawing-with-the-sdks-backends.md#sona_draw). |
| `fn snapshot(&mut self, view: &View, width: u32, height: u32, opts: Option<&DrawOptions>) -> Result<Vec<u8>>` | Straight RGBA8, row 0 at the top.<br>Calls [`sona_snapshot`](../c/drawing-with-the-sdks-backends.md#sona_snapshot). |
| `fn frame_index(&self) -> u64` | The index of the last frame recorded (0 before the first).<br>Calls [`sona_renderer_frame_index`](../c/drawing-with-the-sdks-backends.md#sona_renderer_frame_index). |
| `fn frame_done(&mut self, completed_frame: u64)` | Vulkan, D3D12 and Metal: every frame up to and including completed_frame has finished on the GPU.<br>Calls [`sona_renderer_frame_done`](../c/drawing-with-the-sdks-backends.md#sona_renderer_frame_done). |
| `fn lost(&mut self)` | After a device loss: forget every GPU object.<br>Calls [`sona_renderer_lost`](../c/drawing-with-the-sdks-backends.md#sona_renderer_lost). |
| `unsafe fn reset(&mut self, dev: &sys::sona_device_desc) -> Result<()>` | Makes the renderer's GPU objects again on a device after a loss; unsafe as Renderer::new is.<br>Calls [`sona_renderer_reset`](../c/drawing-with-the-sdks-backends.md#sona_renderer_reset). |
| `fn set_style(&mut self, style: Option<&Style>) -> Result<()>` | The art style of every avatar without its own (with SONA_STYLE_OVERRIDE, of every avatar); None clears it.<br>Calls [`sona_renderer_set_style`](../c/art-styles.md#sona_renderer_set_style). |
| `fn style(&self) -> Result<Style>` | The renderer's style; Err(SONA_E_UNSUPPORTED) when its backend draws no styles.<br>Calls [`sona_renderer_style`](../c/art-styles.md#sona_renderer_style). |
| `fn set_quality(&mut self, q: Option<&Quality>) -> Result<()>` | From the next draw or snapshot.<br>Calls [`sona_renderer_set_quality`](../c/rendering-quality.md#sona_renderer_set_quality). |
| `fn quality(&self) -> Result<Quality>` | What the renderer uses: msaa is the sample count this device draws with.<br>Calls [`sona_renderer_quality`](../c/rendering-quality.md#sona_renderer_quality). |
| `fn set_lighting(&mut self, l: Option<&Lighting>) -> Result<()>` | The host's lights from the next draw; None: the original look again.<br>Calls [`sona_renderer_set_lighting`](../c/lighting-and-shadows.md#sona_renderer_set_lighting). |
| `fn lighting(&self) -> Result<Option<Lighting>>` | The lighting set, or None.<br>Calls [`sona_renderer_lighting`](../c/lighting-and-shadows.md#sona_renderer_lighting). |
| `fn snapshot_lit(&mut self, view: &View, width: u32, height: u32, opts: Option<&DrawOptions>, l: &Lighting) -> Result<Vec<u8>>` | Renderer::snapshot with this lighting for one picture.<br>Calls [`sona_snapshot_lit`](../c/lighting-and-shadows.md#sona_snapshot_lit). |
| `fn set_environment_sh(&mut self, sh9: Option<&[f32; 27]>, skin_red: f32) -> Result<()>` | The lit avatars' environment: 9 RGB SH coefficients of radiance; None: the built-in cube. |
| `unsafe fn set_host_shadow(&mut self, s: Option<&sys::sona_host_shadow>) -> Result<()>` | The host's shadow map, which the lit avatars receive; None: none.<br>Calls [`sona_renderer_set_host_shadow`](../c/lighting-and-shadows.md#sona_renderer_set_host_shadow). |
| `fn shadow_map(&self) -> Result<Option<sys::sona_shadow_map>>` | The renderer's own shadow map after its last lit frame with shadows, or None before one.<br>Calls [`sona_renderer_shadow_map`](../c/lighting-and-shadows.md#sona_renderer_shadow_map). |
| `unsafe fn preview_draw(&mut self, preview: &mut Avatar<'c>, view: Option<&View>, target: &sys::sona_target, opts: Option<&DrawOptions>,) -> Result<Code>` | Renderer::draw with only this preview in the frame.<br>Calls [`sona_item_preview_draw`](../c/item-previews.md#sona_item_preview_draw). |
| `fn preview_snapshot(&mut self, preview: &mut Avatar<'c>, width: u32, height: u32, opts: Option<&DrawOptions>,) -> Result<Vec<u8>>` | Straight RGBA8 of only this preview, framed for width x height, row 0 at the top.<br>Calls [`sona_item_preview_snapshot`](../c/item-previews.md#sona_item_preview_snapshot). |
| `fn sticker(&mut self, avatar: &mut Avatar<'c>, opts: &StickerOptions, clip: Option<&str>) -> Result<Option<Picture>>` | A transparent, outlined cut-out (sona.h 3.12d).<br>Calls [`sona_sticker`](../c/2d-outputs.md#sona_sticker). |
| `fn sheet(&mut self, avatar: &mut Avatar<'c>, opts: &SheetOptions, clip: Option<&str>, name: Option<&str>, pixel: Option<&PixelOptions>,) -> Result<Option<Sheet<'c>>>` | A sprite sheet of the clip at frames x directions (sona.h 3.12d).<br>Calls [`sona_sheet_render`](../c/2d-outputs.md#sona_sheet_render). |
| `fn pick_gpu(&mut self, view: &View, x: f64, y: f64, o: &PickOptions) -> Result<Option<PickHit>>` | The pick through the GPU id buffer (Vulkan, GL, GLES; UNSUPPORTED elsewhere).<br>Calls [`sona_pick_gpu`](../c/picking.md#sona_pick_gpu). |
| `fn pick_gpu_ids(&mut self, view: &View, x: u32, y: u32, w: u32, h: u32, o: &PickOptions) -> Result<(Vec<u32>, Vec<u16>)>` | The id buffer of a region of the view's picture: (avatar ids, mesh index + 1), w * h each, row 0 on top.<br>Calls [`sona_pick_gpu_ids`](../c/picking.md#sona_pick_gpu_ids). |

## Sheet

`struct Sheet<'c>`: A rendered sprite sheet: pages, frames and their atlases.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> *mut sys::sona_sheet` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn page_count(&self) -> u32` | The number of pages; 0 for NULL.<br>Calls [`sona_sheet_page_count`](../c/2d-outputs.md#sona_sheet_page_count). |
| `fn page(&self, page: u32) -> Result<(&[u8], u32, u32)>` | One page's pixels (straight RGBA8), its width and height; owned by the sheet.<br>Calls [`sona_sheet_page`](../c/2d-outputs.md#sona_sheet_page). |
| `fn frame_count(&self) -> u32` | frames * directions; 0 for NULL.<br>Calls [`sona_sheet_frame_count`](../c/2d-outputs.md#sona_sheet_frame_count). |
| `fn frame(&self, index: u32) -> Result<SheetFrame>` | One frame (index = direction * frames + frame): its page and rectangle, where the rectangle sits in the full cell (trim_x, trim_y), the cell's size, the pivot (the avatar's feet) in the cell, its direction, facing, t<br>Calls [`sona_sheet_frame_get`](../c/2d-outputs.md#sona_sheet_frame_get). |
| `fn atlas(&self, format: u32, page: u32, image: &str) -> Result<String>` | The atlas JSON: sys::SONA_ATLAS_ASEPRITE or _TEXTUREPACKER, one page (or SONA_ATLAS_ALL_PAGES with TexturePacker); image names the page file ("{n}" becomes the page number).<br>Calls [`sona_sheet_atlas`](../c/2d-outputs.md#sona_sheet_atlas), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |

## Catalogue

`struct Catalogue`: sona-catalogue.bin, loaded: every item id with its name, slots, game and source.

| Declaration | What it does |
|---|---|
| `fn load(path: impl AsRef<Path>) -> Result<Catalogue>` | Errors come back as codes only (Catalogue::load_with gives messages). |
| `fn load_with(ctx: &Context, path: impl AsRef<Path>) -> Result<Catalogue>` | With the context's allocator; errors carry its message and fix. |
| `fn from_bytes(bytes: &[u8]) -> Result<Catalogue>` | A copy of the file's bytes; the catalogue keeps its own.<br>Calls [`sona_catalogue_load_memory`](../c/the-offline-catalogue.md#sona_catalogue_load_memory). |
| `fn raw(&self) -> *mut sys::sona_catalogue` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn len(&self) -> u32` | Items, sorted by id.<br>Calls [`sona_catalogue_count`](../c/the-offline-catalogue.md#sona_catalogue_count). |
| `fn is_empty(&self) -> bool` | True when the catalogue holds no item. |
| `fn get(&self, index: u32) -> Option<Item<'_>>` | One item.<br>Calls [`sona_catalogue_get`](../c/the-offline-catalogue.md#sona_catalogue_get). |
| `fn iter(&self) -> impl Iterator<Item = Item<'_>> + '_` | Every item, in the catalogue's order. |
| `fn find(&self, id: &str) -> Option<u32>` | 32 hex digits, with or without dashes, braces or spaces, any case.<br>Calls [`sona_catalogue_find`](../c/the-offline-catalogue.md#sona_catalogue_find). |
| `fn find_guid(&self, id: &Guid) -> Option<u32>` | The same from a parsed GUID.<br>Calls [`sona_catalogue_find_guid`](../c/the-offline-catalogue.md#sona_catalogue_find_guid). |
| `fn search(&self, q: &Query, max: u32) -> Result<(Vec<u32>, u32)>` | Up to max matching indexes in id order, after q.offset, and the count of every match.<br>Calls [`sona_catalogue_search`](../c/the-offline-catalogue.md#sona_catalogue_search). |
| `fn games(&self) -> Vec<(&str, u32)>` | The games items come from, sorted by name, each with its item count.<br>Calls [`sona_catalogue_game_count`](../c/the-offline-catalogue.md#sona_catalogue_game_count), [`sona_catalogue_game`](../c/the-offline-catalogue.md#sona_catalogue_game). |
| `fn generated(&self) -> &str` | When its data was made, ISO 8601.<br>Calls [`sona_catalogue_generated`](../c/the-offline-catalogue.md#sona_catalogue_generated). |
| `fn languages(&self) -> Vec<&str>` | The BCP 47 tags of every language item names come in, sorted; "en" is always one.<br>Calls [`sona_catalogue_language_count`](../c/the-offline-catalogue.md#sona_catalogue_language_count), [`sona_catalogue_language`](../c/the-offline-catalogue.md#sona_catalogue_language). |
| `fn item_name(&self, index: u32, lang: &str) -> Result<Option<&str>>` | An item's name in lang; None when it has none there (show Item::name).<br>Calls [`sona_catalogue_item_name`](../c/the-offline-catalogue.md#sona_catalogue_item_name). |

## PropMesh

`struct PropMesh<'c>`: A prop mesh of one context.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> *mut sys::sona_prop_mesh` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn state(&self) -> c_int` | SONA_OK, SONA_PENDING (a stock prop still loading), or why it failed.<br>Calls [`sona_prop_mesh_state`](../c/props-held-and-worn-objects.md#sona_prop_mesh_state). |
| `fn info(&self) -> Option<sys::sona_prop_mesh_info>` | None while it loads.<br>Calls [`sona_prop_mesh_info_get`](../c/props-held-and-worn-objects.md#sona_prop_mesh_info_get). |
| `fn data(&self) -> Option<sys::sona_prop_data>` | The meshes in the data API's form, valid while the mesh lives; None while it loads.<br>Calls [`sona_prop_mesh_data`](../c/props-held-and-worn-objects.md#sona_prop_mesh_data). |

## BlendSpace

`struct BlendSpace<'c>`: A blend space of one context.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> *mut sys::sona_blend_space` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn weights(&self, x: f32, y: f32) -> Vec<f32>` | Each sample's weight at (x, y).<br>Calls [`sona_blend_space_weights`](../c/animation-layers.md#sona_blend_space_weights). |

## StateMachine

`struct StateMachine<'c>`: A state machine of one context.

| Declaration | What it does |
|---|---|
| `fn raw(&self) -> *mut sys::sona_state_machine` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn find(&self, state: &str) -> Option<u32>` | A state's index by name, -1 if unknown.<br>Calls [`sona_state_machine_find`](../c/animation-layers.md#sona_state_machine_find). |
| `fn state_name(&self, state: u32) -> Option<String>` | A state's name, NULL past the last.<br>Calls [`sona_state_machine_state_name`](../c/animation-layers.md#sona_state_machine_state_name). |

## LipSync

`struct LipSync`: Audio in, mouths out: PCM in any chunks, a frame every 10 ms, the same frames however it is chunked.

| Declaration | What it does |
|---|---|
| `fn new(sample_rate: u32, channels: u32) -> Result<LipSync>` | Float samples in -1..1 (interleaved when channels > 1). |
| `fn with_format(sample_rate: u32, channels: u32, s16: bool) -> Result<LipSync>` | s16: 16-bit samples, for LipSync::feed_i16.<br>Calls [`sona_lipsync_create`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_create). |
| `fn feed(&mut self, pcm: &[f32]) -> Result<()>` | frames: samples per channel.<br>Calls [`sona_lipsync_feed`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_feed). |
| `fn feed_i16(&mut self, pcm: &[i16]) -> Result<()>` | For an analyser made with s16.<br>Calls [`sona_lipsync_feed`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_feed). |
| `fn read(&mut self) -> Vec<LipSyncFrame>` | The frames made since the last read, oldest first.<br>Calls [`sona_lipsync_read`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_read). |
| `fn current(&self) -> LipSyncFrame` | The newest frame.<br>Calls [`sona_lipsync_current`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_current). |
| `fn latency(&self) -> f64` | Seconds from a sample being fed to the first frame that hears it.<br>Calls [`sona_lipsync_latency`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_latency). |
| `fn reset(&mut self)` | Back to time 0: hints and frames waiting to be read are dropped.<br>Calls [`sona_lipsync_reset`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_reset). |
| `fn hint(&mut self, phonemes: &[(&str, f32, f32)]) -> Result<()>` | Phonemes the host's TTS reported (symbol, start, end), on the fed audio's clock.<br>Calls [`sona_lipsync_hint`](../c/lip-sync-and-voice-mouths.md#sona_lipsync_hint). |

## VoiceMouth

`struct VoiceMouth(pub sys::sona_voice_mouth)`: Voice chat: one speaker's mouth from its audio level alone.

| Declaration | What it does |
|---|---|
| `fn new(seed: u32) -> VoiceMouth` | Sets size and starts the state from seed.<br>Calls [`sona_voice_mouth_init`](../c/lip-sync-and-voice-mouths.md#sona_voice_mouth_init). |
| `fn step(&mut self, level: f32, dt: f32) -> (u8, f32)` | (mouth, open) after dt seconds at this level (linear RMS).<br>Calls [`sona_voice_mouth_step`](../c/lip-sync-and-voice-mouths.md#sona_voice_mouth_step). |

## HeadlessOptions

`struct HeadlessOptions(pub sys::sona_headless_options)`: How to open a headless renderer; Default is sona_headless_defaults.

| Declaration | What it does |
|---|---|
| `fn device(mut self, kind: sys::sona_device_kind) -> Self` | SONA_DEVICE_AUTO, _GPU or _SOFTWARE. |
| `fn backend(mut self, b: sys::sona_backend) -> Self` | 0 (Vulkan, then GL), SONA_BACKEND_VULKAN or SONA_BACKEND_GL. |
| `fn batch_in_flight(mut self, n: u32) -> Self` | Avatars a batch builds ahead; 0: 8, at most 32. The C field sona_headless_options.batch_in_flight (count). |

## SequenceOptions

`struct SequenceOptions(pub sys::sona_sequence_options)`: Frames of a clip at a fixed rate; its Default is what sona_sequence_defaults sets (frames 0: the clip's length).

| Declaration | What it does |
|---|---|
| `fn turntable(frames: u32) -> Self` | A turntable: frames pictures over one turn. |

## Headless

`struct Headless<'c>`: A renderer on the library's own device: the best GPU, or lavapipe or llvmpipe.

| Declaration | What it does |
|---|---|
| `fn open(ctx: &'c Context, o: &HeadlessOptions) -> Result<Headless<'c>>` | Makes the device and a renderer on it, waiting up to wait_seconds for the ctx's shading data.<br>Calls [`sona_headless_open`](../c/headless-rendering-and-video-out.md#sona_headless_open). |
| `fn raw(&self) -> *mut sys::sona_headless` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn info(&self) -> HeadlessDevice` | The device it drew on.<br>Calls [`sona_headless_info_get`](../c/headless-rendering-and-video-out.md#sona_headless_info_get). |
| `fn render(&self, a: &Avatar<'c>, o: &RenderOptions) -> Result<Vec<u8>>` | One picture of an avatar of the context, alone.<br>Calls [`sona_headless_render`](../c/headless-rendering-and-video-out.md#sona_headless_render). |
| `fn render_manifest(&self, manifest: &[u8], o: &RenderOptions) -> Result<Vec<u8>>` | Adds the avatar (hidden, standing still or playing clip from time), draws it and removes it.<br>Calls [`sona_headless_render_manifest`](../c/headless-rendering-and-video-out.md#sona_headless_render_manifest). |
| `fn batch(&self, manifests: &[&[u8]], o: &RenderOptions) -> Result<Vec<(Code, Option<Vec<u8>>)>>` | One (result, pixels) per manifest, in order; a bad manifest gives its code and no pixels.<br>Calls [`sona_headless_batch`](../c/headless-rendering-and-video-out.md#sona_headless_batch). |
| `fn sequence(&self, a: &Avatar<'c>, o: &RenderOptions, s: &SequenceOptions) -> Result<Vec<Vec<u8>>>` | Every frame: frame i at the clip's start + i / fps, turned turn_deg * i / frames.<br>Calls [`sona_headless_sequence`](../c/headless-rendering-and-video-out.md#sona_headless_sequence). |
| `fn record(&self, a: &Avatar<'c>, o: &RenderOptions, s: &SequenceOptions, v: &mut Video<'c>) -> Result<()>` | sona_headless_sequence into a video.<br>Calls [`sona_headless_record`](../c/headless-rendering-and-video-out.md#sona_headless_record). |
| `fn tier_detect(&self) -> Result<u32>` | The tier (SONA_TIER_LOW..<br>Calls [`sona_tier_detect`](../c/rendering-quality.md#sona_tier_detect), [`sona_headless_renderer`](../c/headless-rendering-and-video-out.md#sona_headless_renderer). |

## Video

`struct Video<'c>`: A PNG sequence, GIF, MP4 or WebM.

| Declaration | What it does |
|---|---|
| `fn open(ctx: &'c Context, path: Option<&Path>, o: &sys::sona_video_options, ffmpeg: Option<&str>) -> Result<Video<'c>>` | o: sona_video_defaults with width and height set (and anything else).<br>Calls [`sona_video_open`](../c/headless-rendering-and-video-out.md#sona_video_open). |
| `fn defaults(width: u32, height: u32) -> sys::sona_video_options` | sona_video_defaults at this size.<br>Calls [`sona_video_defaults`](../c/headless-rendering-and-video-out.md#sona_video_defaults). |
| `fn frame(&mut self, rgba: &[u8]) -> Result<()>` | One frame of width * height straight RGBA8, row 0 at the top.<br>Calls [`sona_video_frame`](../c/headless-rendering-and-video-out.md#sona_video_frame). |
| `fn finish(mut self) -> Result<Option<Vec<u8>>>` | Ends the file: the bytes of an in-memory video, else None.<br>Calls [`sona_video_finish`](../c/headless-rendering-and-video-out.md#sona_video_finish), [`sona_free`](../c/drawing-with-the-sdks-backends.md#sona_free). |

## Players

`struct Players`: Friends, lobby members and leaderboard rows by id: a gamertag, "a:<account>/<slot>" or "w:<case key>".

| Declaration | What it does |
|---|---|
| `fn open(o: &PlayersOptions) -> Result<Players>` | Zeroes the config and sets size; zero fields take the defaults (2048 looks, an interval of 600 s, 60 an hour, 4 at once, a timeout of 15 s).<br>Calls [`sona_players_defaults`](../c/other-players-avatars-by-id.md#sona_players_defaults), [`sona_players_open`](../c/other-players-avatars-by-id.md#sona_players_open). |
| `fn watch(&mut self, ids: &[&str], priority: i32) -> Result<()>` | Ok, or the first problem (an id that is not an id, over max_players); the others are watched all the same.<br>Calls [`sona_players_watch`](../c/other-players-avatars-by-id.md#sona_players_watch). |
| `fn unwatch(&mut self, ids: Option<&[&str]>) -> Result<()>` | None: every id.<br>Calls [`sona_players_unwatch`](../c/other-players-avatars-by-id.md#sona_players_unwatch). |
| `fn refresh(&mut self, ids: Option<&[&str]>) -> Result<()>` | None: every watched id.<br>Calls [`sona_players_refresh`](../c/other-players-avatars-by-id.md#sona_players_refresh). |
| `fn update(&mut self) -> u32` | Each frame.<br>Calls [`sona_players_update`](../c/other-players-avatars-by-id.md#sona_players_update). |
| `fn poll(&mut self) -> Vec<PlayerEvent>` | Every event waiting, oldest first; an empty list when there are none.<br>Calls [`sona_players_poll`](../c/other-players-avatars-by-id.md#sona_players_poll). |
| `fn look(&mut self, id: &str) -> (PlayerLook, Result<()>)` | Always a look to draw; Err(NOT_FOUND) for an id never watched nor cached, Err(ARGUMENT) for one that is not an id.<br>Calls [`sona_players_look`](../c/other-players-avatars-by-id.md#sona_players_look). |
| `fn forget(&mut self, id: &str) -> Result<()>` | Drops the id's look from memory and, at the next write, from the cache file, and stops watching it.<br>Calls [`sona_players_forget`](../c/other-players-avatars-by-id.md#sona_players_forget). |
| `fn stats(&self) -> sys::sona_players_stats` | Looks kept, ids watched, requests in flight and due, and counts since open: requests, changed, the same, 304s, gone, failed, read from disk, disk writes, waits for per_hour; paused_until.<br>Calls [`sona_players_stats_get`](../c/other-players-avatars-by-id.md#sona_players_stats_get). |
| `fn placeholder() -> Vec<u8>` | The built-in placeholder look.<br>Calls [`sona_players_placeholder`](../c/other-players-avatars-by-id.md#sona_players_placeholder). |

## Maker

`struct Maker<'a>`: A catalogue's outfit rules, indexed once: seeded random avatars, dress like, clashes, matched sets and the outfit check.

| Declaration | What it does |
|---|---|
| `fn new(catalogue: &'a Catalogue) -> Result<Maker<'a>>` | Indexes a catalogue's outfit rules once: candidate items per body and section, gender variants and matched sets.<br>Calls [`sona_maker_create`](../c/making-avatars-in-code.md#sona_maker_create). |
| `fn raw(&self) -> *const sys::sona_maker` | The native pointer this value wraps, for a call through sona360-sys that the safe layer does not cover. |
| `fn random(&self, seed: u32, o: &RandomOptions<'_>) -> Result<RandomAvatar>` | A seeded random avatar: the same seed and options give the same bytes.<br>Calls [`sona_random_defaults`](../c/making-avatars-in-code.md#sona_random_defaults), [`sona_make_random`](../c/making-avatars-in-code.md#sona_make_random). |
| `fn dress_like(&self, body: &[u8], like: &[u8], parts: u32, match_: u32, layer: bool) -> Result<DressedLike>` | body wearing like's parts (sona_sys::SONA_LIKE_*; 0: clothes and props), each item resolved for body.<br>Calls [`sona_like_defaults`](../c/making-avatars-in-code.md#sona_like_defaults), [`sona_make_dress_like`](../c/making-avatars-in-code.md#sona_make_dress_like). |
| `fn variant(&self, item: &Guid, body: u32, match_: u32) -> (u32, Option<Guid>)` | What body (1 or 2) wears for item: sona_sys::SONA_RESOLVED_* and the item, None when dropped.<br>Calls [`sona_make_variant`](../c/making-avatars-in-code.md#sona_make_variant). |
| `fn conflicts(&self, manifest: &[u8], item: &Guid) -> Result<Vec<Guid>>` | The ids wearing item would take off manifest.<br>Calls [`sona_outfit_conflicts`](../c/making-avatars-in-code.md#sona_outfit_conflicts). |
| `fn set_count(&self) -> u32` | How many matched sets (outfits sold as one) the maker knows.<br>Calls [`sona_outfit_set_count`](../c/making-avatars-in-code.md#sona_outfit_set_count). |
| `fn set(&self, index: u32) -> Option<OutfitSet<'_>>` | Set set: its item count, which bodies wear it, the sections it has items in and the slots it covers.<br>Calls [`sona_outfit_set_get`](../c/making-avatars-in-code.md#sona_outfit_set_get). |
| `fn set_of(&self, item: &Guid) -> Option<u32>` | The matched set an item belongs to, or -1 when it is in none.<br>Calls [`sona_outfit_set_of`](../c/making-avatars-in-code.md#sona_outfit_set_of). |
| `fn set_items(&self, set: u32, body: u32) -> Vec<u32>` | Catalogue indexes of a set's items a body wears (0: every item).<br>Calls [`sona_outfit_set_items`](../c/making-avatars-in-code.md#sona_outfit_set_items). |
| `fn check(&self, manifest: &[u8]) -> Result<OutfitReport>` | Checks a manifest's outfit for clashes and missing pieces (sona_outfit_check). |
| `fn fix(&self, manifest: &mut [u8]) -> Result<OutfitReport>` | As outfit_fix with this maker: repairs the manifest in place and reports what it changed. |

## PickHit

`struct PickHit`: One pick: the avatar (by id and handle), the item, mesh and triangle, the joint and body region, and where.

| Declaration | What it does |
|---|---|
| `fn avatar_id(&self) -> u32` | Sona_avatar_id. The C field sona_pick_hit.avatar_id (index or id). |
| `fn avatar(&self) -> *mut sys::sona_avatar` | The native handle, to compare with Avatar::raw. |
| `fn item(&self) -> String` | The item's id ("" for a bounds hit). |
| `fn mesh(&self) -> Option<u32>` | Index into sona_pose_data.meshes; -1 for a sphere hit. The C field sona_pick_hit.mesh (index or id). |
| `fn joint(&self) -> Option<u32>` | The named joint (sona_joint_name) that moves the point most; -1 for a prop. The C field sona_pick_hit.joint (index or id). |
| `fn region(&self) -> &'static str` | Sona_body_region of that joint. The C field sona_pick_hit.region (sona_body_region value). |
| `fn distance(&self) -> f32` | Metres from the ray's origin, along its unit direction. The C field sona_pick_hit.distance (m (world units)). |
| `fn point(&self) -> [f32; 3]` | World. The C field sona_pick_hit.point (m (world units)). |
| `fn normal(&self) -> [f32; 3]` | World, unit, toward the ray: the triangle's, or the sprite's for a picture. The C field sona_pick_hit.normal (direction (unit vector)). |

## Theme

`struct Theme<'a>`: The game's colours (0xAARRGGBB), corner radius, scale and font.

| Declaration | What it does |
|---|---|
| `fn dark() -> Theme<'static>` | The console slate. |
| `fn light() -> Theme<'static>` | 360sona.com's editor. |

## Control

`struct Control`: One control on screen, for a screen reader or the host's own hit tests.

| Declaration | What it does |
|---|---|
| `fn focused(&self) -> bool` | The control has the focus. |
| `fn selected(&self) -> bool` | The control is the chosen one: a worn item, the current tab. |

## Editor

`struct Editor<'c>`: The player editor.

| Declaration | What it does |
|---|---|
| `fn open(ctx: &'c Context, cat: &'c Catalogue, o: &Options, theme: Option<&Theme>) -> Result<Editor<'c>>` | theme None: the light theme.<br>Calls [`sona_editor_defaults`](../c/player-editor.md#sona_editor_defaults), [`sona_editor_open`](../c/player-editor.md#sona_editor_open). |
| `fn raw(&self) -> *mut sys::sona_editor` | The native pointer, for a sona-editor-sys call this crate does not wrap. |
| `fn feed(&mut self, input: &sys::sona_editor_input) -> Result<()>` | One input event as sona_editor.h has it; the calls below make them.<br>Calls [`sona_editor_feed`](../c/player-editor.md#sona_editor_feed). |
| `fn button(&mut self, b: Pad, down: bool) -> Result<()>` | A gamepad button pressed (down true) or released. |
| `fn press(&mut self, b: Pad, dt: f64) -> Result<Status>` | Down, an update, up, an update. |
| `fn axis(&mut self, a: Axis, value: f32) -> Result<()>` | A stick's or a trigger's position. |
| `fn key(&mut self, k: Key, down: bool, mods: u32) -> Result<()>` | mods: sys::SONA_EDITOR_MOD_*. |
| `fn text(&mut self, s: &str) -> Result<()>` | Typed text, for the search box. |
| `fn pointer(&mut self, x: f32, y: f32, down: Option<bool>, id: u32) -> Result<()>` | x, y in the editor's pixels; down Some(true) pressed, Some(false) released, None moved; id a touch or 0. |
| `fn wheel(&mut self, x: f32, y: f32, lines: f32) -> Result<()>` | lines: + is up. |
| `fn update(&mut self, dt: f64) -> Status` | Advances dt seconds (and, unless HOST_UPDATES, updates the context).<br>Calls [`sona_editor_update`](../c/player-editor.md#sona_editor_update). |
| `fn status(&self) -> Status` | SONA_EDITOR_RUNNING, _DONE or _CANCELLED, as the last sona_editor_update returned.<br>Calls [`sona_editor_status`](../c/player-editor.md#sona_editor_status). |
| `fn result(&self) -> Result<[u8; MANIFEST_BYTES]>` | The avatar as it stands; after Cancelled, the start manifest. |
| `fn screen(&self) -> Screen` | The screen shown now.<br>Calls [`sona_editor_screen_get`](../c/player-editor.md#sona_editor_screen_get). |
| `fn set_screen(&mut self, s: Screen) -> Result<()>` | Refused (ARGUMENT) for a screen the mode does not have.<br>Calls [`sona_editor_set_screen`](../c/player-editor.md#sona_editor_set_screen). |
| `fn screens(&self) -> Vec<Screen>` | The mode's screens in tab order.<br>Calls [`sona_editor_screens`](../c/player-editor.md#sona_editor_screens). |
| `fn set_search(&mut self, text: Option<&str>) -> Result<()>` | The search box, for a host with its own on-screen keyboard; None clears it.<br>Calls [`sona_editor_set_search`](../c/player-editor.md#sona_editor_set_search). |
| `fn set_theme(&mut self, t: &Theme) -> Result<()>` | Changes the colours and sizes from the next frame.<br>Calls [`sona_editor_set_theme`](../c/player-editor.md#sona_editor_set_theme). |
| `fn resize(&mut self, width: u32, height: u32) -> Result<()>` | The editor's size in pixels, the size of the target it is drawn into.<br>Calls [`sona_editor_resize`](../c/player-editor.md#sona_editor_resize). |
| `fn size(&self) -> (u32, u32)` | The editor's size in pixels. |
| `fn busy(&self) -> bool` | True while an avatar is still building.<br>Calls [`sona_editor_busy`](../c/player-editor.md#sona_editor_busy). |
| `fn build_failures(&self) -> u32` | How many avatar builds failed since open (the screen reader is told each time).<br>Calls [`sona_editor_build_failures`](../c/player-editor.md#sona_editor_build_failures). |
| `fn undo(&mut self, redo: bool) -> bool` | Undo (or redo) one step; false when there is none.<br>Calls [`sona_editor_undo`](../c/player-editor.md#sona_editor_undo). |
| `fn can_undo(&self, redo: bool) -> bool` | 1 when sona_editor_undo with the same redo would step: use it to grey out the buttons.<br>Calls [`sona_editor_can_undo`](../c/player-editor.md#sona_editor_can_undo). |
| `fn zoom(&self) -> f64` | 1 is the editor's framing.<br>Calls [`sona_editor_zoom`](../c/player-editor.md#sona_editor_zoom). |
| `fn set_zoom(&mut self, zoom: f64) -> f64` | 0.6 to 3.<br>Calls [`sona_editor_zoom`](../c/player-editor.md#sona_editor_zoom). |
| `fn turn(&mut self, degrees: f64)` | Positive turns the avatar to its left.<br>Calls [`sona_editor_turn`](../c/player-editor.md#sona_editor_turn). |
| `fn view(&self) -> Result<View>` | The camera the avatar layer is drawn with.<br>Calls [`sona_editor_view`](../c/player-editor.md#sona_editor_view). |
| `unsafe fn draw(&mut self, r: &mut Renderer<'_>, target: &sona_sys::sona_target, opts: Option<&DrawOptions>) -> Result<Code>` | The whole editor into the target: the avatar with the renderer, the UI over it.<br>Calls [`sona_editor_draw`](../c/player-editor.md#sona_editor_draw). |
| `unsafe fn draw_avatar(&mut self, r: &mut Renderer<'_>, target: &sona_sys::sona_target, opts: Option<&DrawOptions>) -> Result<Code>` | The avatar layer alone, for a host that draws the UI with its own 2D pass (Editor::draw_data).<br>Calls [`sona_editor_draw_avatar`](../c/player-editor.md#sona_editor_draw_avatar). |
| `fn thumbnails(&mut self, r: &mut Renderer<'_>, budget: u32) -> u32` | Renders up to budget pending item pictures, for a host that draws the avatar with its own sona_draw.<br>Calls [`sona_editor_thumbnails`](../c/player-editor.md#sona_editor_thumbnails). |
| `fn snapshot(&mut self, r: &mut Renderer<'_>) -> Result<Vec<u8>>` | The whole picture at the editor's size, straight RGBA8.<br>Calls [`sona_editor_snapshot`](../c/player-editor.md#sona_editor_snapshot). |
| `fn render_ui(&mut self, width: u32, height: u32) -> Result<Vec<u8>>` | The UI layer on the CPU, straight RGBA8 on a transparent clear.<br>Calls [`sona_editor_render_ui`](../c/player-editor.md#sona_editor_render_ui). |
| `fn render_ui_over(&mut self, rgba: &mut [u8], width: u32, height: u32) -> Result<()>` | The UI layer blended over a picture of the avatar layer (width x height straight RGBA8).<br>Calls [`sona_editor_render_ui`](../c/player-editor.md#sona_editor_render_ui). |
| `fn draw_data(&mut self) -> Result<DrawData<'_>>` | The UI layer's triangles; they borrow the editor until the next update.<br>Calls [`sona_editor_draw_data_get`](../c/player-editor.md#sona_editor_draw_data_get). |
| `fn texture(&mut self, id: u32) -> Result<Texture<'_>>` | A texture the draw data names by id, with its pixels (straight RGBA8, owned by the editor) and the rectangle that changed since an older revision, for a host that draws the UI layer itself.<br>Calls [`sona_editor_texture_get`](../c/player-editor.md#sona_editor_texture_get). |
| `fn controls(&self) -> Vec<Control>` | Every control on screen, in reading order.<br>Calls [`sona_editor_control_count`](../c/player-editor.md#sona_editor_control_count), [`sona_editor_control_get`](../c/player-editor.md#sona_editor_control_get). |
| `fn focus(&self) -> Option<Control>` | None when nothing has focus (pointer-only use).<br>Calls [`sona_editor_focus_get`](../c/player-editor.md#sona_editor_focus_get). |
| `fn announcement(&mut self) -> Option<String>` | What a screen reader should say since the last call; None when nothing changed.<br>Calls [`sona_editor_announcement`](../c/player-editor.md#sona_editor_announcement). |

## Types

| Declaration | What it does |
|---|---|
| `type Result<T> = std::result::Result<T, Error>` | The C type sona_result. |
| `enum ReadKind` | The C type sona_read_kind. |
| `struct RequestId(usize)` | Identifies one read, so cancel can match it. |
| `trait Source: Send` | A host-written source. |
| `enum LogLevel` | How serious a log line is: debug, info, warn, error (SONA_LOG_*). |
| `type Budget = sys::sona_budget` | Memory budget in bytes. The C type sona_budget. |
| `struct Placement` | The C type sona_placement. |
| `struct PlayOptions` | The C type sona_play_options. |
| `enum Preset` | The C type sona_preset. |
| `enum Space` | Which space a pose or target is given in: world or the avatar's own (SONA_SPACE_*). |
| `enum OverrideMode` | How a joint override applies: replace the clip's rotation or add to it (SONA_OVERRIDE_*). |
| `enum RootMotion` | What happens to a clip's root motion: off, extract or apply (SONA_ROOT_MOTION_*). |
| `enum Lod` | The level of detail an avatar was drawn at: full, sampled, quarter, sprite (SONA_LOD_*). |
| `enum ClipEventKind` | The C type sona_clip_event_kind. |
| `struct ClipEvent` | The C type sona_clip_event. |
| `enum Skeleton` | The skeletons the rig's joints map onto. |
| `struct ExportOptions` | What Avatar::export writes. |
| `type ExportReport = sys::sona_export_report` | The C type sona_export_report. |
| `type IdleOptions = sys::sona_idle_options` | The C type sona_idle_options. |
| `type IdleState = sys::sona_idle_state` | The C type sona_idle_state. |
| `struct Picture` | A straight RGBA8 picture, row 0 at the top. |
| `type Style = sys::sona_style` | An art style: the original look, no outline, every parameter at its default; set kind and flags after. |
| `enum EventKind` | What an event says: ready, failed, an error, the licence checked (SONA_EVENT_*). |
| `struct Event` | The C type sona_event. |
| `struct ClipInfo` | The C type sona_clip_info. |
| `type FrameStats = sys::sona_frame_stats` | The C type sona_frame_stats. |
| `type SceneStats = sys::sona_scene_stats` | The C type sona_scene_stats. |
| `type View = sys::sona_view` | The C struct sona_view under its Rust name: A camera: the eye, the target, the vertical field of view in degrees, near and far, and the target size in pixels, kept in doubles. |
| `type Material = sys::sona_material` | Address modes: bit 0 set = U wraps, bit 1 set = V wraps; clear = clamp. The C type sona_material. |
| `type DrawOptions = sys::sona_draw_options` | The C type sona_draw_options. |
| `type Guid = sys::sona_guid` | The C type sona_guid. |
| `type Capsule = sys::sona_capsule` | A vertical capsule around the posed body, in world space, for collisions: the segment a..b and its radius. The C type sona_capsule. |
| `type LodOptions = sys::sona_lod_options` | Each sona_update gives every avatar in view a step by its height on screen in pixels: FULL (posed every frame), SAMPLED (posed when the clip reaches a new frame), QUARTER (also at most every 4th frame) and SPRITE (a pict The C type sona_lod_options. |
| `type LodStats = sys::sona_lod_stats` | The C type sona_lod_stats. |
| `type PreviewOptions = sys::sona_preview_options` | The C type sona_preview_options. |
| `type Quality = sys::sona_quality` | The C type sona_quality. |
| `type Lighting = sys::sona_lighting` | sona.h 3.12e: the host's lights and shadows. |
| `type PixelOptions = sys::sona_pixel_options` | The C type sona_pixel_options. |
| `type StickerOptions = sys::sona_sticker_options` | The C type sona_sticker_options. |
| `type SheetOptions = sys::sona_sheet_options` | The C type sona_sheet_options. |
| `type SheetFrame = sys::sona_sheet_frame` | One frame of a sheet. The C type sona_sheet_frame. |
| `struct Shading` | The fixed shading inputs, for hosts that rebuild our look in their own shaders. The C type sona_shading. |
| `struct Credit` | The C type sona_credit. |
| `enum Pass` | The C type sona_pass. |
| `enum Route` | The C type sona_route. |
| `struct Query` | What Catalogue::search matches. |
| `struct Item<'a>` | One item. |
| `enum LayerKind` | What a layer plays: a clip, a blend space or a state machine. |
| `struct LayerOptions` | What a layer plays and how: Avatar::layer_play, Avatar::layer_blend, Avatar::layer_machine. |
| `struct LayerInfo` | The C type sona_layer_info. |
| `enum LayerEventKind` | The C type sona_layer_event_kind. |
| `struct LayerEvent` | The C type sona_layer_event. |
| `struct BlendSample<'a>` | The C type sona_blend_sample. |
| `enum Motion<'a>` | What a state plays: a clip by key or a blend space. |
| `struct StateSpec<'a>` | One state of a state machine: its name, what it plays, its loop and speed (sona_state_desc). |
| `enum Cond` | A transition's condition on a parameter: greater, less, equal, or a trigger (sona_condition). |
| `struct TransitionSpec<'a>` | A transition between states: where to, its fade, its exit time and conditions (sona_transition_desc). |
| `enum Mask` | The joint masks layers play on: a preset or a branch from a joint (sona_mask_preset, sona_mask_branch). |
| `type LipSyncFrame = sys::sona_lipsync_frame` | One step of the lip sync analysis of a LipSync: time, mouth, open, level and the shape weights (sona_lipsync_frame). |
| `type MouthKey = sys::sona_mouth_key` | A mouth from time on. |
| `struct HeadlessDevice` | One device a headless renderer can open. |
| `struct RenderOptions` | What one picture looks like. |
| `enum PlayerState` | Where an id's look stands. |
| `struct PlayerLook` | The look to draw for an id: the player's, or the placeholder. |
| `enum PlayerEvent` | What changed for an id since the last poll. |
| `struct PlayersOptions` | The options of Players::open; zero fields take the library's defaults. |
| `struct RandomOptions<'f>` | The options of Maker::random. |
| `struct RandomAvatar` | What Maker::random made. |
| `struct LikeItem` | One item Maker::dress_like copied: from, what this body wears for it, and how it came across. |
| `struct DressedLike` | What sona_make_dress_like kept, varied, swapped and dropped (sona_like_report). |
| `struct OutfitSet<'a>` | One matched set. |
| `struct OutfitIssue` | One issue of outfit_check. |
| `struct OutfitReport` | The C type sona_outfit_report. |
| `struct PickOptions` | Which avatars a pick considers and how far it looks. |
| `struct MeshItem` | A custom item of your own skinned mesh (format 1.1): what Context::custom_item_pack_mesh takes. |
| `enum Mode` | Which editor opens: the full one, the quick creator or the wardrobe picker. |
| `enum Status` | What the editor answers each update; Done and Cancelled stay. |
| `enum Screen` | A screen of the editor. |
| `enum Pad` | A gamepad button. |
| `enum Axis` | A stick axis (-1 to 1, +y down) or a trigger (0 to 1). |
| `enum Key` | A keyboard key the editor takes (text for the search box comes through Editor::text). |
| `struct Options<'a>` | How the editor opens. |
| `struct DrawData<'e>` | The UI layer as triangles for the host's own 2D pass, as of the last update. |
