@@ -150,11 +150,52 @@ Consumers access the feature through the application interface:
150150let folders = client . vault (). folders (). list (). await ? ;
151151```
152152
153+ ## 6. Add mobile bindings
154+
155+ If the new functionality needs to be available on mobile platforms (Android / iOS), add a
156+ [ UniFFI] ( language-bindings.md#mobile-bindings ) wrapper in the ` bitwarden-uniffi ` crate.
157+
158+ ### Expose the client
159+
160+ Add an accessor method on the appropriate UniFFI client — typically in
161+ [ ` bitwarden-uniffi/src/lib.rs ` ] [ uniffi-lib ] or a sub-client — that returns a new wrapper struct:
162+
163+ ``` rust
164+ impl Client {
165+ pub fn vault (& self ) -> Arc <VaultClient > {
166+ Arc :: new (VaultClient (self . 0. clone ()))
167+ }
168+ }
169+ ```
170+
171+ ### Create the wrapper
172+
173+ Create a wrapper struct that holds the SDK ` Client ` and delegates to the underlying Rust client. See
174+ [ ` bitwarden-uniffi/src/tool/sends.rs ` ] [ uniffi-sends ] for a complete example.
175+
176+ ``` rust
177+ use crate :: Result ;
178+
179+ pub struct FoldersClient (pub (crate ) SharedClient );
180+
181+ #[uniffi:: export]
182+ impl FoldersClient {
183+ pub async fn get (& self , folder_id : FolderId ) -> Result <FolderView > {
184+ Ok (self . 0. vault (). folders (). get (folder_id ). await ? )
185+ }
186+ }
187+ ```
188+
189+ The wrapper should convert errors into ` BitwardenError ` .
190+
153191## Ownership
154192
155193Feature and domain crates are usually owned and maintained by individual teams. When creating a new
156194crate, coordinate with the Platform team to establish ownership and review expectations.
157195
158196[ pm-lib ] : https://github.com/bitwarden/sdk-internal/blob/main/crates/bitwarden-pm/src/lib.rs
159197[ state-crate ] : https://github.com/bitwarden/sdk-internal/tree/main/crates/bitwarden-state
198+ [ uniffi-lib ] : https://github.com/bitwarden/sdk-internal/blob/main/crates/bitwarden-uniffi/src/lib.rs
199+ [ uniffi-sends] :
200+ https://github.com/bitwarden/sdk-internal/blob/main/crates/bitwarden-uniffi/src/tool/sends.rs
160201[ vault-crate ] : https://github.com/bitwarden/sdk-internal/tree/main/crates/bitwarden-vault
0 commit comments