https://www.iotworldtoday.com/wp-content/themes/ioti_child/assets/images/logo/mobile-logo.png
  • Home
  • News
    • Back
    • Roundups
  • Strategy
  • Special Reports
  • Business Resources
    • Back
    • Webinars
    • White Papers
    • Industry Perspectives
    • Featured Vendors
  • Other Content
    • Back
    • Q&As
    • Case Studies
    • Features
    • How-to
    • Opinion
    • Podcasts
    • Strategic Partners
    • Latest videos
  • More
    • Back
    • About Us
    • Contact
    • Advertise
    • Editorial Submissions
  • Events
    • Back
    • Embedded IoT World (Part of DesignCon) 2022
Iot World Today
  • NEWSLETTER
  • Home
  • News
    • Back
    • Roundups
  • Strategy
  • Special Reports
  • Business Resources
    • Back
    • Webinars
    • White Papers
    • Industry Perspectives
    • Featured Vendors
  • Other Content
    • Back
    • Q&As
    • Case Studies
    • Features
    • How-to
    • Opinion
    • Podcasts
    • Strategic Partners
    • Latest videos
  • More
    • Back
    • About Us
    • Contact
    • Advertise
    • Editorial Submissions
  • Events
    • Back
    • Embedded IoT World (Part of DesignCon) 2022
  • newsletter
  • IIoT
  • Cities
  • Energy
  • Homes/Buildings
  • Transportation/Logistics
  • Connected Health Care
  • Retail
  • AI
  • Metaverse
  • Development
  • Security
ioti.com

Embedded Computing


Thinkstock

Training and Development on the Mechanism of Metal Gears. in the design of information related to business

Developing IoT Applications with Rust: Using a Rust Development Environment

Developing for IoT with Rust has matured to the point that its ecosystem now includes an array of key support tools. One tool is Cargo.
  • Written by Dan Sullivan
  • 24th February 2021

Developers are most productive when they have tools to support all aspects of the software development cycle.

This includes programming languages, library and package managers, and testing and deployment tools. The Rust programming language has matured to the point that its ecosystem now includes an array of key support tools. One of these tools is Cargo.

Cargo is a package manager that supports all the core tasks of package management in both binary and library form. Cargo handles a lot of tasks, such as building your code, downloading the libraries your code depends on, and building those libraries, or dependencies.

Once Rust is installed, you canuse Cargo’s from the command line. Cargo commands are intuitive to the point of being obvious. For example, the cargonew’ command instructs Cargo to create a new package, which includes a directory structure for the package and a specification for the package, which is called a manifest. The manifest will contain metadata used by the Rust compiler.

Application code often has dependencies on other libraries and artifacts.  When a Rust application has dependencies, Cargo can get those dependencies during the build process. Not surprisingly, to build a package, we use the ‘rustc’ command, to call the Rust compiler.

Cargo observes conventions regarding package directory structure. Subdirectories include src (for source code), benches (for benchmark code) and tests (for integration test). The default executable file is src/main.rs. However, you can find other binaries in /src/bin/.

Cargo’s configuration metadata is defined in Cargo.toml and will be created and maintained manually. Another metadata file, Cargo.lock, contains metadata about dependencies. Unlike Cargo.toml, Cargo.lock is

maintained by Cargo and won’t be edited by developers. Configuration data is specified in TOML format, which is designed to have obvious semantics.

Cargo.toml contains sections describing the package, dependencies and features. The package section includes name, version, authors, path to build script, and license information. The dependencies section holds package dependencies, test dependencies, and build dependencies. Lastly, the features section specifies conditional compilation conditions, which is useful when working with multiple environments that need different configurations.

Developers can specify integration tests and run those tests using the ‘cargo test’ command. It’s common practice to use both unit tests and integration tests. Unit tests are designed to test one component or application function at a time, while integration tests will test the application in ways similar to how the application will be used in production. By convention, Rust expects to find tests in the tests subdirectory of a package. Each file in the tests subdirectory is compiled as a separate crate.

Often, developers will re-use common functions across tests and this is easily done with Rust. Developers can create public functions in modules and then import them into tests.

When looking at the organization of a Rust application, there are multiple levels of structure. The lowest level is the function, common across programming languages. Modules are different related functions grouped into a single file. Crates, the next level up, contain modules and, as noted earlier, are the unit of compilation. The last organizational unit is workspaces. These are used to organize multiple crates in the same application.

Rust extends the advantages of this modular application structure beyond just what one developer creates. The Crates.io site contains tens of thousands of crates that are available for use. There are widely used crates for common functional requirements, like generating random numbers, logging, and parsing command line arguments.  In addition, there are many specialized crates, including ones for IoT application development. There will be more specifics on those IoT crates in the next article of this series.

 

 

 

Tags: IoT platforms Developers Architecture Technologies

Related


  • The Future of IoT: Top Trends We Expect to See in 2022
    Edge computing, 5G and AI will drive value for the connected enterprise this year
  • Fox Sports Taps OpenDrives for Data Management Architecture
    OpenDrives software and hardware ­­is expected to reduce the data management footprint of Fox Sports live broadcasts.
  • Fleet Space Raises $26M for IoT Nanosatellite Connectivity
    Australia-based Fleet Space Technologies ­plans to use the funding to drive the expansion of its nanosatellite IoT connectivity fleet.
  • Ericsson’s Intelligent Automation Platform Creates Smarter, Faster Networks
    The company's automated orchestration tools allow mobile network operators to optimize service delivery using machine learning.

Leave a comment Cancel reply

-or-

Log in with your IoT World Today account

Alternatively, post a comment by completing the form below:

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Content

  • Open Source IoT Development Tools vs. Vendor-Supported Tools
  • Water Authority Bolsters IoT Resilience With Cisco Cyber Vision
  • Exploring IoT Connectivity Options
  • IoT Wireless Connectivity Matures, Industry Watchers Say

Roundups

View all

IoT Product Roundup: PTC, Nokia, Arm and More

19th May 2022

IoT Deals, Partnerships Roundup: Intel, Nauto, Helium and more

14th May 2022

IoT Product Roundup: Amazon, Synaptics, Urban Control and More

27th April 2022

White Papers

View all

The Role of Manufacturing Technology in Continuous Improvement Ebook

6th April 2022

IIoT Platform Trends for Manufacturing in 2022

6th April 2022

Latest Videos

View all
Dylan Kennedy of EMQ

Embedded IoT World 2022: Dylan Kennedy of EMQ

Dylan Kennedy, EMQ’s VP of global operations, sat down with Chuck Martin at Embedded IoT World 2022.

Embedded IoT World 2022: Omdia’s Sang Oh Talks Vehicle Chip Shortage

Omdia’s automotive semiconductor analyst sits down with Chuck Martin at this year’s event

E-books

View all

How Remote Access Helps Enterprises Improve IT Service and Employee Satisfaction

12th January 2022

An Integrated Approach to IoT Security

6th November 2020

Webinars

View all

Rethinking the Database in the IoT Era

18th May 2022

Jumpstarting Industrial IoT solutions with an edge data management platform

12th May 2022

AI led Digital Transformation of Manufacturing: Time is NOW

9th December 2021

Special Reports

View all

Omdia’s Smart Home Market Dynamics Report

7th January 2022

Cybersecurity Protection Increasingly Depends on Machine Learning

28th October 2020

IoT Security Best Practices for Industry and Enterprise

20th October 2020

Twitter

IoTWorldToday, IoTWorldSeries

Swiss-startup Airyacht is developing an eponymously named vehicle that it says will take the luxury-yacht experienc… twitter.com/i/web/status/1…

23rd May 2022
IoTWorldToday, IoTWorldSeries

@Tesla’s #Autopilot being investigated once again following fatal crash in Newport Beach, California. iotworldtoday.com/2022/05/23/tes…

23rd May 2022
IoTWorldToday, IoTWorldSeries

A new Kansas law will enable #driverless deliveries from @Walmart and its partner @Gatik_AI. #AVs… twitter.com/i/web/status/1…

23rd May 2022
IoTWorldToday, IoTWorldSeries

Access a world of opportunity in 2022 with @IoTWorldToday ➡️ Now is time to unlock ROI, by accessing a global com… twitter.com/i/web/status/1…

23rd May 2022
IoTWorldToday, IoTWorldSeries

3D Home Printer to Build 72 Residences for National Homebuilder dlvr.it/SQhWSF https://t.co/XJOs70DqzH

19th May 2022
IoTWorldToday, IoTWorldSeries

Microsoft Ramping up Cybersecurity Service Offerings dlvr.it/SQhPR0 https://t.co/nYzaDRnyVY

19th May 2022
IoTWorldToday, IoTWorldSeries

IoT Product Roundup: PTC, Nokia, Arm and More dlvr.it/SQhNNF https://t.co/ZApdw3RHdu

19th May 2022
IoTWorldToday, IoTWorldSeries

Britain’s postal service has plans to run a fleet of autonomous #drones to make rural postal deliveries easier.… twitter.com/i/web/status/1…

19th May 2022

Newsletter

Sign up for IoT World Today newsletters: vertical industry coverage on Tuesdays and horizontal tech coverage on Thursdays.

Special Reports

Our Special Reports take an in-depth look at key topics within the IoT space. Download our latest reports.

Business Resources

Find the latest white papers and other resources from selected vendors.

Media Kit and Advertising

Want to reach our audience? Access our media kit.

DISCOVER MORE FROM INFORMA TECH

  • IoT World Series
  • Channel Futures
  • RISC-V
  • Dark Reading
  • ITPro Today
  • Web Hosting Talk

WORKING WITH US

  • Contact
  • About Us
  • Advertise
  • Login/Register

FOLLOW IoT World Today ON SOCIAL

  • Privacy
  • CCPA: “Do Not Sell My Data”
  • Cookies Policy
  • Terms
Copyright © 2022 Informa PLC. Informa PLC is registered in England and Wales with company number 8860726 whose registered and Head office is 5 Howick Place, London, SW1P 1WG.
This website uses cookies, including third party ones, to allow for analysis of how people use our website in order to improve your experience and our services. By continuing to use our website, you agree to the use of such cookies. Click here for more information on our Cookie Policy and Privacy Policy.
X