To implement these models, create a new file in src-tauri/src named models.rs and add the following code to it. This enum provides variants for both and a method to return the appropriate URL for a request. Some URLs need to be appended to the base GitHub API URL while others are fully-qualified URLs that require no extra formatting. URL: This is an enum that captures the two variants of URLs you will encounter in this application.Repository: This corresponds to a GitHub repository response object.NewGistResponse: This corresponds to the response when a new Gist is created.In this application, this will contain only the user’s profile name and avatar URL. GithubUser: This corresponds to a user on GitHub. GistFile: This corresponds to a file associated with a Gist.GistInput: This corresponds to the input required to create a new Gist.This model corresponds to the string content of a single GistFile. GistContent: A Gist is made up of one or more files ( GistFile in this application).Gist: This corresponds to a GitHub Gist response object.It is important to note that, sometimes, this object may not be present in the response. CommitNode: This corresponds to the inner commit object found in a GitHub Commit response object.Commit: This corresponds to a GitHub commit response object.The error arm will be the earlier declared TauriError. APIResult: This is a generic wrapper type around Rust’s in-built Result enum.The application will have the following models: Getting startedĬreate a new Tauri project using the following command. While this may require some extra work, I will walk you through the process of doing that. The invoke() function returns a Promise, if your command returns data then the Promise resolves to the returned value. If your function takes any arguments, the arguments can be passed as a JSON object. On the front-end, Tauri provides a special function named invoke() which allows you to invoke your command. Commands are simply functions with the # annotation. Tauri uses a command system to expose functions to the front-end. A basic understanding of Rust, Typescript, and React.Ĭheck the Tauri prerequisites to ensure that your development environment is ready.To follow this tutorial, you will need the following: The UI components will be created using Ant Design (AntD). React, Typescript, and Vite will be used for the front-end.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |