हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
Android Rust के बारे में जानकारी
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Android प्लैटफ़ॉर्म, Rust में नेटिव ओएस कॉम्पोनेंट डेवलप करने की सुविधा देता है. यह एक आधुनिक सिस्टम-प्रोग्रामिंग भाषा है, जो C/C++ के बराबर परफ़ॉर्मेंस के साथ, मेमोरी की सुरक्षा की गारंटी देती है. Rust, कंपाइल के समय की जांचों के कॉम्बिनेशन का इस्तेमाल करती है, जो ऑब्जेक्ट के लाइफ़टाइम और मालिकाना हक को लागू करती हैं. साथ ही, रनटाइम की जांचों से यह पक्का किया जाता है कि मेमोरी का सही तरीके से ऐक्सेस किया जा रहा है. इससे, गै़रबेज कलेक्टर की ज़रूरत नहीं पड़ती.
Rust में, आधुनिक लैंग्वेज की कई सुविधाएं मिलती हैं. इनकी मदद से, डेवलपर अपने कोड को ज़्यादा बेहतर तरीके से लिख पाते हैं और उस पर भरोसा कर पाते हैं:
- सुरक्षित कॉन्करंट प्रोग्रामिंग - इसकी मदद से, उपयोगकर्ता आसानी से बेहतर और थ्रेड-सेफ़ कोड लिख सकते हैं. इस वजह से, Rust का स्लोगन फ़ियरलेस कॉन्करेंसी है.
- ज़्यादा जानकारी देने वाला टाइप सिस्टम - Rust, ज़्यादा जानकारी देने वाले टाइप (जैसे, Newtype रैपर और कॉन्टेंट वाले enum वैरिएंट) की अनुमति देकर, लॉजिकल प्रोग्रामिंग बग को रोकने में मदद करता है.
- कंपाइल करने के समय ज़्यादा जांच - कंपाइल करने के समय ज़्यादा गड़बड़ियां मिलने पर, डेवलपर को भरोसा होता है कि कोड सही तरीके से काम करेगा.
- बिल्ट-इन टेस्टिंग फ़्रेमवर्क - Rust में एक बिल्ट-इन टेस्टिंग फ़्रेमवर्क होता है, जहां यूनिट टेस्ट को लागू करने के साथ-साथ रखा जा सकता है. इससे यूनिट टेस्ट को शामिल करना आसान हो जाता है.
- एनफ़ोर्समेंट की गड़बड़ी को ठीक करना - जिन फ़ंक्शन में गड़बड़ियां ठीक की जा सकती हैं वे नतीजे का टाइप दिखा सकते हैं. यह नतीजा, सफलता वाला वैरिएंट या गड़बड़ी वाला वैरिएंट हो सकता है. कंपाइलर के लिए ज़रूरी है कि कॉल करने वाले, फ़ंक्शन कॉल से मिले
Result
enum के गड़बड़ी वाले वैरिएंट की जांच करें और उसे मैनेज करें. इससे, गड़बड़ियों को मैनेज न किए जाने की वजह से होने वाली गड़बड़ियों की संभावना कम हो जाती है.
- शुरू करना - Rust में, हर वैरिएबल को इस्तेमाल करने से पहले, उसके टाइप के किसी मान्य सदस्य के तौर पर शुरू करना ज़रूरी है. इससे, गलती से किसी असुरक्षित वैल्यू के तौर पर शुरू होने से रोका जा सकता है.
- इंटिजर को सुरक्षित तरीके से मैनेज करना - इंटिजर टाइप के सभी कन्वर्ज़न, साफ़ तौर पर कास्ट किए जाते हैं.
डेवलपर, फ़ंक्शन कॉल के दौरान किसी वैरिएबल को असाइन करते समय या अन्य टाइप के साथ अंकगणितीय कार्रवाई करते समय, गलती से कास्ट नहीं कर सकते. Android for Rust में, ओवरफ़्लो की जांच करने की सुविधा डिफ़ॉल्ट रूप से चालू होती है. इसके लिए, ओवरफ़्लो ऑपरेशन साफ़ तौर पर होने चाहिए.
ज़्यादा जानकारी के लिए, Android Rust के लिए सहायता से जुड़ी ब्लॉग पोस्ट की सीरीज़ देखें:
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# Android Rust introduction\n\nThe Android platform provides support for developing native OS components in Rust,\na modern systems-programming language that provides memory safety guarantees with\nperformance equivalent to C/C++. Rust uses a combination of compile-time checks\nthat enforce object lifetime and ownership, and runtime checks that ensure valid\nmemory accesses, thereby eliminating the need for a garbage collector.\n\nRust provides a range of modern language features which allow developers to be\nmore productive and confident in their code:\n\n- **Safe concurrent programming** - The ease with which this allows users to write efficient, thread-safe code has given rise to Rust's [Fearless Concurrency](https://doc.rust-lang.org/book/ch16-00-concurrency.html) slogan.\n- **Expressive type system** - Rust helps prevent logical programming bugs by allowing for highly expressive types (such as Newtype wrappers, and enum variants with contents).\n- **Stronger Compile-time Checks** - More bugs caught at compile-time increases developer confidence that when code compiles successfully, it works as intended.\n- **Built-in Testing Framework** - Rust provides a built-in testing framework where unit tests can be placed alongside the implementation they test, making unit testing easier to include.\n- **Error handling enforcement** - Functions with recoverable failures can return a [Result type](https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html), which will be either a success variant or an error variant. The compiler requires callers to check for and handle the error variant of a `Result` enum returned from a function call. This reduces the potential for bugs resulting from unhandled failures.\n- **Initialization** - Rust requires every variable to be initialized to a legal member of its type before use, preventing an unintentional initialization to an unsafe value.\n- **Safer integer handling** - All integer-type conversions are explicit casts. Developers can't accidentally cast during a function call when assigning to a variable, or when attempting to do arithmetic with other types. Overflow checking is on by default in Android for Rust, which requires overflow operations to be explicit.\n\nFor more information, see the series of blog posts on Android Rust support:\n\n- [Rust in the Android Platform](https://security.googleblog.com/2021/04/rust-in-android-platform.html) \n Provides an overview on why the Android team introduced Rust as a new platform language.\n- [Integrating Rust into the Android Open Source Project](https://security.googleblog.com/2021/05/integrating-rust-into-android-open.html) \n Discusses how Rust support has been introduced to the build system, and why certain design decisions were made.\n- [Rust/C++ interop in the Android Platform](https://security.googleblog.com/2021/06/rustc-interop-in-android-platform.html) \n Discusses the approach to Rust/C++ interoperability within Android."]]