coin trading PYTHON LIBRARIES
Aqua Utopia๏ฝๆตทใฎๅบใง่จๆถใ็ดกใ
Not today Justin
Three Goblin Art
Monterey Bay Aquarium
Today's Document
$LAYYYTER

Andulka

tannertan36
sheepfilms

Origami Around
ojovivo

izzy's playlists!
Sweet Seals For You, Always
Peter Solarz
i don't do bad sauce passes
AnasAbdin
DEAR READER

JBB: An Artblog!

blake kathryn
seen from Spain

seen from Malaysia

seen from Germany
seen from Jordan

seen from United States
seen from United States

seen from Netherlands

seen from China

seen from Spain

seen from Japan

seen from Norway

seen from United States

seen from Tรผrkiye
seen from United States

seen from Germany

seen from United Kingdom
seen from Singapore

seen from Czechia

seen from Japan
seen from United States
@jacob-cs
coin trading PYTHON LIBRARIES

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch โข No registration required โข HD streaming
FREE SSL FOR wordpress
flask, nginx, uwgsi
A conversational AI system that listens, learns, and challenges
godaddy flask setup
Flask is a popular micro web framework for Python that allows you to easily create web applications and APIs. Cpanel is a web-basedโฆ
replit selenium , nix
replit ์์ selenium์ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์ง ์๋ ค์ฃผ๋ ๊ธ
Run code live in your browser. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter.
nix๋ฅผ ์ด์ฉํ ํํค์ง ๊ด๋ฆฌ๋ฐฉ๋ฒ

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch โข No registration required โข HD streaming
RADIX scrypto 2
vault method
Accepting a Bucket of Resource
if the ResourceAddress of the resource contained in the Bucket doesnโt match the ResourceAddress of the Vault, then the Radix Engine will not allow the resource to be passed into this Vault. Although, we can create some safety measures using assertions or simply send friendly messages!
Returning a Bucket of Resource
When we need to send back tokens to the user, weโll return the user a Bucket of tokens.
Returning Overpayments
you can specify behaviors to mark a resource as mintable, burnable or even restrict its withdrawal, making them โSoulboundโ tokens. When specifying resource behaviors, you can also specify authorization rules around it to determine what badges need to be present before that action can be taken. We can also determine the mutability of these authorization rules to have the ability to change the authorization rules in the future or lock its mutability to prevent its rules from being changed.
List of Resource Behaviors
Making a Resource Mintable
mintable(AccessRule, Mutability)
The first argument is an AccessRule . ย in brief, it is a Scrypto native concept which allows you to specify rules around the action you want to enforce. With this argument, we offer a macro rule!() that you can call for convenience. Since we specified rule!(allow_all), weโve indicated that this resource can be minted by anyone.
The second argument is Mutability , this deals with the mutability of the rule.ย determine whether this rule can be changed in the future. The Mutability argument under the hood is actually an enum, one of the selection of the enum is LOCKED, which means that this resource will always be freely minted by anyone and we canโt change the permission in the future. Alternatively, you can pass an AccessRule argument if youโd like to set rules around the ability to change rules in the future.
Making a Resource Burnable
Having a resource burnable indicates that an specified supply of this resource can essentially be destroyed. If all the supply of that resource is burnt, the ResourceManager will still exist. we call the .burnable() method when we create our resource.
Burning our Resource Token
Restricting Resource Withdrawal
Resources that have the restrict_withdraw flag can't be withdrawn and are effectively locked in the Vault that contains it. This makes the resource soulbound.
Restricting Resource Deposit
Resources that are restricted from being deposited are commonly called transient resources. Applying the restrict_deposit flag forces a dangling resource to exist. Therefore, if the resource canโt be deposited into a Vault, the resource must be burnt, else we will encounter a dangling resource error. Transient resources are most commonly used as a means to force a specified condition to happen within a transaction. If that condition is met, we can permit the resource to be burned. Alternatively, if we specify an authorization requirement, we can allow this resource to be deposited (when the specified badge is present) if a certain condition is met.
Allowing the Resourceโs NonFungibleData to be Updateable
Each NonFungible resource has unique data that can be attributed to it. Therefore, we can allow this data to be changed. We can also specify that a badge must be present in order for the data to be changed if we apply an authorization requirement to this resource flag.
Making a Resource Recallable
Having a resource to be recallable allows us to send our tokens to anybody, but have the ability for us to retrieve it if we desire. The most common use case for this is to allow for โRental NFTsโ. We can create conditions in how long this resource can essentially be borrowed for.
ResourceManager
The resource address you receive after creating a new resource maps to a ResourceManager. ResourceManager defines how all of the individual tokens of a certain resource behave. For example, the token name, symbol, and supply is defined in its ResourceManager. As we will see later, it also defines the rules for actions (like minting and burning) for that particular resource. In the same token, we need to use the ResourceManager to perform resource actions (like minting and burning).
Using the ResourceManager to Mint Tokens
Using ResourceManager to Query Data
You can use resim to display the information related to a particular ResourceManager with resim show [resource_manager_address]:
Using the ResourceManager Programmatically
.
.
.
์๋๋ ํ ํฐ๊ฑฐ๋ํ๋ ๋ธ๋ฃจํ๋ฆฐํธ ๋ง๋๋ ๊ณผ์
Defining our blueprint
Creating our Resource(s)
Defining our Struct
Defining our Component Instantiation
Notice that the way we want to instantiate this Vault is by calling .new() which doesnโt accept Bucket as an argument, but rather a ResourceAddress. Since we will be expecting our payments to be received through this component, we want to create a Vault that receives the payment that we want. In this case the RADIX_TOKEN. RADIX_TOKEN is the globally recognized ResourceAddress of XRD, the native token of the Radix Network.
Creating our Instantiation Function
Defining Methods
์๋ ๋๋จธ์ง ์๋์ ๊ฑฐ์ฌ๋ฌ ์ฃผ๋ ๊ธฐ๋ฅ์ถ๊ฐ
full implementation
Scryptoโs authorization model starts with three core concepts: Badges, Proofs, and Access Rules.
Badges
A badge is simply any token or resource that is used for authentication and authorization. Badges can either be a Fungible or NonFungible resource type; and anytime a user or component needs some form of authorization or authentication, the badge needs to be present before that action can be performed.
Proofs
proof๋ badge์ ์ฌ๋ณธ๊ฐ์ ๊ฐ๋ . ์ผ์์ ์ผ๋ก transaction์์๋ง ์ฌ์ฉ๊ฐ๋ฅ
Proofs are a transient instance of a resource that can only exist within the duration of the transaction. For authorization and authentication, a Proof of the badge is sent instead of the actual badge. This is because assets on Scrypto have physical characteristics. When we send the physical badge to a component for authorization and authentication, that badge is physically being transferred away from our possession to the vaultโs possession, effectively giving away our ownership of that badge. This can be dangerous because sending a badge to a malicious component effectively allows that component to use the badge for other means.
AccessRules
AccessRule is used to define security measures around your methods and resource behaviors. If you have certain methods you'd like to protect, you can quickly specify rules around what badge(s) are needed to call that method. Additionally, when we create resources, we can also set an AccessRule to protect resource behaviors such as the ability to mint or burn resource tokens. It is intuitive and easy to define your security measures, because much of your authorization needs are already baked into the platform.
We now know that badges are the main resource we use for authorization and authentication.
Anytime we use badges for authorization, we instead want to submit a Proof of the badge to perform the authorization (as opposed to the actual badge itself).
We also introduced the concept of AccessRules that allows us to define security measures of our method calls and resource behaviors.
System-level Authentication
System-level authentication is performed by the Radix Engine. When we define AccessRules in our blueprint and implement them in our component, we communicate to the Radix Engine with the prerequisites required to perform an action. This is powerful as the Radix Engine is designed with a Finite State Machine to enforce strict resource management. Therefore, without having to consider potential edge-cases that may arise when building our own authorization system, the Radix Engine can enforce the rules we create around our components. After weโve implemented AccessRules to our component, the Radix Engine can use the Proofs in the Authorization Zone and compare it against the badges specified in the componentโs AccessRules.
The Authorization Zone (AuthZone)
Every transaction on the Radix Network contains a layer called the Authorization Zone or AuthZone. All Proofs are submitted in the AuthZone. Transactions submitted to the Radix Network are accompanied by the transaction manifest. Chapter 5 explains that the transaction manifest is a list of instruction(s) that describes a sequence of component method calls and movements of resources between components.
If there are AccessRules applied to these method calls and/or resource behaviors, then Proof of the badge(s) is required before these actions can be performed. ย Every Proof generated is then immediately placed in the AuthZone when submitted. The Radix Engine utilizes the Proofs in the AuthZone and automatically compares the Proofs against the badges required by AccessRules implemented in the component. If the Proofs of the badge(s) satisfies the required badge(s) needed to perform an action, access to such action is granted and the call succeeds. Otherwise, the transaction immediately aborts.
Application-level Authentication
While every Proof is automatically sent to the AuthZone, we are not confined to authenticating Proofs in the AuthZone. ย Instead, we can send Proofs directly to our component method(s) to perform our own authentications. This way of applying application-level authentication is called Passing Proofs by Intent. When we pass a Proof directly to our component method(s), authentications are handled by ProofValidation (that we will go over later in this chapter).
Conceptually speaking, when we design our componentโs methods, we can specify to accept Proofs as an argument and create ProofValidation rules within the method logic for every Proof that is passed to our method(s). Arguably, the selection of ProofValidation we perform on Proofs sent to our methods can be more flexible compared to rules defined using AccessRules. While Passing Proof by Intent exposes us with more flexible authentications, more importantly, sending Proofs directly to our component method(s) allows us to read and utilize the NonFungibleData of the resource (if the resource is a NonFungible type)
Creating Fungible Badges
Creating badges is as simple as creating a resource as shown in Chapter 3. A badge is any resource (whether Fungible or NonFungible) that is used for authorization.
Creating NonFungible Badges
Fungible or NonFungible Badges?
If you need to uniquely identify your users you should create a NonFungible badge. This will allow you to refer to your users by their badgeโs ID and also attach relevant information on the badge itself.
If you only care that the user has a particular badge without having to identify them separately, you should use a Fungible badge instead.
RADIX scrypto 1
Accounts on the Radix network are actually Scrypto components that hold resource containers and define rules for accessing them.
You can instantiate a new account component in the simulator with the resim new-account
This will give you back the created accountโs address, public key and private key.
Additionally, at any time, you can find the current default account with the command resim show-configs.
You can send tokens from the default account to another one by running the command:
resim transfer [amount] [resource_address] [recipient_address]
Letโs verify the balance of the second account. You can query the state of an address with the resim show [address] command.
resim show resource_sim1qyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqs6d89k
to easily create a boilerplate Scrypto package with basic functionality. To do this, simply type the following command scrypto new-package [package_name].
Directory Structure
At the root of the generated package directory, you should find the src, and tests folders plus a Cargo.toml file.
The tests folder is where you write the integration tests for your package. You can run the tests located in this directory with the scrypto test command.
All packages must have a lib.rs file - which is the starting point of your Scrypto package.
You can think of blueprints and components like classes and objects in object-oriented programming.
When you create a new project with the scrypto new-package command, it creates a Scrypto package. A simple package, like the HelloToken example, will only contain a single blueprint but you could โpackageโ together multiple blueprints that need each-other to work when deploying them on the ledger. That way, you are certain that all your blueprints are deployed at the same time and the platform knows that those blueprints are related to each other.
(์ฆ ํ๋์ ํฉํค์ง์ ์ฌ๋ฌ๊ฐ์ ๋ธ๋ฃจํ๋ฆฐํธ๊ฐ ์์์์์ผ๋ฉฐ ํ๋์ ํฉํค์ง์์ ์ฌ๋ฌ ๋ธ๋ฃจํ๋ฆฐํธ๋ ์๋ก ์ฐ๊ด๋์ด์๋ค๊ณ ์ฌ๊ฒจ์ง๋ค)
#[blueprint]. A blueprint definition must contain a struct and an impl section with the name of the blueprint
impl ๋ธ๋ฝ ์์
you will write the functions callable on the blueprint itself and the methods callable on the instantiated components.
Itโs important to make a distinction between functions and methods:
Functions can be called on the blueprints and do not have access to any state.
Methods on the other hand are callable on individual components and are able to get data from the state and update or mutate it.
์๋ function ์ ํ ์์
์๋ method์ ํ ์์
&mut self๊ฐ ์ ๋ฌ๋๋ฉด ๋ฉ์๋ ๊ฐ ๋๋ค
Safe Types
These types are just like the u8, i8, u16, etc. but they differ in the fact that they panic (and make the transaction fail) if an overflow occurs when doing operations on them. You define these types by using an uppercase U for unsigned numbers and uppercase I for signed numbers:
I8, I16, I32, I64, I128, I256, I384, I512
U8, U16, U32, U64, U128, U256, U384, U512
They also have the benefit of offering 384 bits and 512 bits options instead of a maximum of 128 bits.
Strings
The String type is supported in Scrypto.
Floating points
the Rust types f32 and f64 representing floating point numbers are not supported in Scrypto. Instead, we offer the Decimal and PreciseDecimal types that allow you to represent numbers with a fractional part using fixed point arithmetic (which is deterministic).
you have to wrap the number in quotes (as seen for c and e in the previous example). If you donโt, you will not be able to compile your package because it will detect the use of floating point numbers.
The Decimal type supports a maximum of 18 decimal places -if you need more you should use PreciseDecimal which supports up to 64 decimal places:
Collections
Scrypto supports the basic Rust collections like Vec, HashMap and HashSet. We also provide a new type KeyValueStore which is like a HashMap, but it does not load the full content of the Map until you request it. Here are some examples:
Scrypto Types
The PackageAddress, ComponentAddress and ResourceAddress types are used to work with the different address types. The Scrypto types you will work with the most are the Bucket and Vault types
Creating Custom Types
You create a custom type by writing a struct outside of the blueprint! definition. It is important to remember to add the line #[scrypto(ScryptoCategorize, ScryptoEncode, ScryptoDecode, LegacyDescribe)] before the struct block. This adds, at compile time, methods to the type to make it compatible with the Radix Engine. Here is an example:
To test our blueprint locally we will use resim. You may recall we saw how to use resim to create accounts and transfer tokens in the simulator. By running the resim --help command you will see that you can do much more with resim. In our case, we will use it to publish our package to the local simulator, instantiate our component, and call a method to interact with it.
To ensure we have a clean slate to begin with letโs run resim reset and then generate a new default account by running resim new-account be sure to save the account address as we will want to inspect it later. You can save this as an environment variable for convenience or just create a file for your own reference to copy and paste.
The next step is to build and deploy the package. You can do that with the following command: resim publish . (make sure you are in the hello_token directory!).
To create an instance of our deployed blueprint we will use the package address that we just received to instantiate our component by calling the instantiate_hello function on the Hello blueprint by running
resim call-function [package_address] [blueprint_name] [function]
which will look something like this:
resim call-function package_sim1qxxkyjgkyryztmtlsypzd8244xkvqeln32aqdersgk3szcwxzq Hello instantiate_hello
After running the call-function command above, you will get various information about the transaction that was executed.
Now that we have an instantiated Hello component, all the methods defined by its blueprint are exposed to us and callable. We are going to call the free_token method on it with a resim command resim call-method [component_address] [method]
token๋ resource ์ค์ ํ๊ฐ์ง ์ด๋ค
Resources are built into the platform
Resources on Radix need to always be placed in some kind of resource containers. Resource containers, as the name suggest, hold resources. Each resource container can only hold one type of resource and the purpose of these resource containers are to properly move, secure, and account for the resources that are being transacted. There are two types of resource containers: Bucket and Vault.
Bucket - Buckets are temporary containers and are used to move resources during a transaction; therefore, only exist in the duration of the transaction.
Vault - Vaults are permanent containers and at the end of each transaction, all resources must be stored in a Vault.
Scrypto offers a handful of utilities to conveniently create and manage resources.
ResourceBuilder - The ResourceBuilder is used to create Fungible and NonFungible resources.
ResourceManager - When a resource is created, a ResourceManager is also created to manage the resource.
The ResourceBuilder is a Scrypto utility that we use to create Fungible and NonFungible resources. Below is a table summarizing the methods provided by the ResourceBuilder for Fungible resources.
Notice that we have fields such as color and rarity. These values are a selection of enums and if you're not familiar with enums, the Rust handbook provides a section on enums.
Creating a NonFungible Resource
Creating a NonFungible resource is a little different from creating a Fungible resource as we saw in the earlier section. To give some context, when we create a NonFungible resource, the collection of the NonFungible resource will have one ResourceAddress. However, each individual NonFungible that we decide to mint will have its own unique identifiers called NonFungibleLocalId. We have an option of data types we can declare to be our NonFungibleLocalId, but it is a requirement to declare a type.
์๋๋ integer๋ฅผ id ๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์ด๋ค
Creating NFTs with a Mutable Supply
You can create NFTs with no specified initial supply. To do so, we would need to create a badge that will be held by the component Vault.
Viewing, Utilizing, and Mutating NonFungibleData
full example code
RUST 179-
cargo
User input
environmental variables
? ์ฐ์ฐ์
? ์ฐ์ฐ์๋ Result, Option ๋ฆฌํดํ๋ ํจ์์์์๋ง ์ฌ์ฉ๊ฐ๋ฅํ๋ค
main ํจ์๋ (), Result๋ง ๋ฆฌํด ๊ฐ๋ฅํ
?์ฐ์ฐ์๋ Err๋ฅผ ๋ง๋๊ฒ๋๋ฉด ๋ฐ๋ก ํจ์ ํธ์ถ์์๊ฒ Err๋ฅผ ๋ฆฌํดํ๋ค
๋ฐ์ ๋๋จธ์ง ์ฝ๋๋ ์คํ๋์ง ์๋๋ค
file read write
์๋ ์์ ์ฝ๋์ ์ถ์ฝ
์๋ ํ์ผ ๋ง๋ค๊ณ ๋ฐ๋ก ์ฐ๊ธฐ ๋ฐฉ๋ฒ
cargo doc
RUST 171-178 in english
time
-
macro์ ๋ํ ์ฐธ๊ณ ๊ณต๋ถ๋ด์ฉ
-
useful macro unreachable!()
macro
์๋ ํ๋ฆฐ ์ฝ๋
https://www.youtube.com/watch?v=7aY3NzriR_Y&list=PLfllocyHVgsRwLkTAhG0E-2QxCf-ozBkk&index=177&pp=iAQB
macro์ด์ฉ struct, function๋ง๋ค
๋งคํฌ๋ก ์์์ ๋งคํฌ๋ก ์์ ์ ํธ์ถํ ์ ์๋ค.
RUST 155-170 in english
์์ ์์๋ ๊ฐ์ ์์ ์ธ๋ฐ ์๋ rayon์ ์ด์ฉํ ๊ฒฝ์ฐ๊ฐ ์ข๋ ๋น ๋ฅด๋ค (parallel์์ )
ย rust crates ํ์ด์ง
rust game engine
array
์๋ ํ๋ฆฐ ์ฝ๋.ย array ๋ฅผ for loop ํ๊ณ ๊ฐ์ด ์ฐ๋ ค๋ฉดย &[] ๋ฅผ ์ด์ฉํด์ผํจ
์๋ ๋ง๋ ์ฝ๋
.iter() ๋ฅผ ์ด์ฉํ ์ ์ฝ๋๋ ๋ง๋ ์ฝ๋
[], () ๋ฅผ ์ด์ฉํด์ ๋ถํด ํ ๋น ๊ฐ๋ฅํ๋ค
integer
add implementation
์๋๋ ์ด์ด์ง
์ฌ์น์ฐ์ฐ์ implementationํ ์ ์๋ค.
floats
์ ๋ง๋ ์ฝ๋
์ ๋ง๋ ์ฝ๋
bool
Vec
my_vec์ 4๋ฒ์งธ์ ์๋ 0 ์ด sortํ๊ณ ๋์ ๋งจ ์์ 0๊ฐ ์๋์ ์๋ค.
์ด๋ฐ ๋ฌธ์ ๋ฅผ ์๊ดํ์ง ์๊ณ sortํ๋ ๊ฒ์ sort_unstable()์ด๋ผ๊ณ ํ๋ค
String
String์ Vec์ ํ ์ข ๋ฅ์ด๋ค
๋ค์ํ String
mem
transmute
no_implicit_prelude
function pointer
https://youtu.be/HduA3uaF_Ac
https://youtu.be/1sgBm7Z0CW8

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch โข No registration required โข HD streaming
RUST 134-154
channel
์ ๊ฒฝ์ฐ ์๋ชป๋ ๊ฒฝ์ฐ ํ๋์ ์ฐ๋ ๋๋ง ์ํ๋๊ณ ๋๋จธ์ง๊ฐ ์ํ๋๋ ๋์ค์ ์ด๋ฏธ ํ๋ก๊ทธ๋จ์ด ๋๋์ ๋๋จธ์ง ์ฐ๋ ๋ ์ํ์ด ์๋ฃ๋์ง ๋ชปํ๋ ์ํฉ
์๋ ์ฌ๋ฐ๋ฅธ ๊ฒฝ์ฐ
์๋ ์ฌ๋ฐ๋ฅธ ๊ฒฝ์ฐย
attributes
๊ธฐ๋ณธ์ผ๋ก unused_variables, dead_code๋ warn ํ๊ฒ ์ค์ ๋์ด์๋๋ฐ
๋ง์ฝ ๋ช ์์ ์ผ๋ก ์ค์ ํ๋ค๋ฉด ์์ ๊ฐ๋ค (๋จ ์ ์ญ์ ์ผ๋ก ์ค์ ํ๋ ๊ฒ์ด๋ฏ๋ก [ ์์ !๊ฐ ์์ด์ผํ๋ ์ ์ด ๋น ์ก์)
๊ธฐ๋ณธ ์ค์ ์ ์์ ๋ ๊ฒฝ์ฐ
test attribute๋ก ํจ์์์์ ํจ๋์ด ๋ฐ์ํ๋ฉด failed๋ก ํ๋จ๋๊ฒ ํ๋ค
์๋ ์ปดํ์ผ์ ์ ํ์ ์ผ๋ก ํ๊ฒ ์ค์ ํ๋ ๋ฐฉ๋ฒ
attributes ๋ชฉ๋ก, ์ฌ์ฉ์์ ๋งํฌ
Default , builder pattern
์ builder pattern์์ validationํ๋ ํจ์ build๋ฅผ ๋ง๋ค์ด์ฃผ๊ณ ย
์ต์ข ์์ ์ build๊ฐ ํ๊ฒ ํ๋ค
dereferencing , dot operator
&์ค๋ธ์ ํธ.๋ฉ์๋ย ์ย ย
&&์ค๋ธ์ ํธ.๋ฉ์๋ย ์ย ย
&&&&&&์ค๋ธ์ ํธ.๋ฉ์๋
๋ค ๊ฐ์ ๊ฒ์ด๋คย
Ref, DeRef
์๋ ํ๋ฆฐ ์ฝ๋ HoldsANumber ๊ฐ deref ๋ฅผ ๊ตฌํํ๊ณ ์์ง ์๊ธฐ ๋๋ฌธ์ด๋ค
๊ธฐ๋ณธ Deref ๊ฐ ์์ ๊ฐ๊ณ ์ด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก implementํด์ผ ํ๋ค
์ ์ฌ๋ฐ๋ฅด๊ฒ ๊ตฌํํ ๊ฒฝ์ฐ
deref, derefmut๋ . operator๊ฐ ๊ฐ๋ฅํ๊ฒ ๋ง๋ค์ด ์ค๋ค. ์ฆ ์ด๋ฅผ ํตํด ๋ค์ํ ๊ธฐ๋ฅ์ ๋ฌผ๋ ค ๋ฐ์์ ์๋ค. ์์ ๊ฒฝ์ฐ pow ๋ฉ์๋๋ฅผ ์ฌ์ฉํ ์ ์๊ฒ ๋๊ฒฝ์ฐ
์์, ์ ์ฌ์ง์ Deref๋ฅผ implementย ํด์ * operator ์ ํน์ ์์ ์ ํ๋ ๊ฒฝ์ฐ๋ฅผ ๋ณด์ฌ์ค๋ค
module, mod
crate - mod - fn ์ ์์ผ๋ก ๊ตฌ์กฐ๋์ด์๋ค.
ํ ํ์ผ์์์ mod๋ฅผ ์ ๊ทผํ ์ ์์ง๋ง ๋ค๋ฅธ ๊ณณ์์๋ pub mod๋ก ์ง์ ํด์ฃผ์ง ์์ผ๋ฉด ์ ๊ทผ ๋ถ๊ฐ ํ๋ค.ย
struct๋ pub mod๋ฅผ ํตํด struct๋ฅผ public์ผ๋ก ์ค์ ํ ์ ์๋ค. ๊ทธ๋ ๊ฒ ํด๋ ๊ฐ๊ฐ์ property ๋ฅผ ๋ ์ค์ ํด์ค์ผ ํ๋ค.
enum์ ๊ฒฝ์ฐ๋ pub enum์ผ๋ก ์์ ์์๊น์ง ๋ค public ์ผ๋ก ๋ง๋ค์ ์๋คย
testing
testing ๊ธด์์ ์ฝ๋
RUST 122-133 in english
Arc
์๋ ์๋ชป๋ ์ฝ๋ (ํ์ดํฌ borrow_mut() )
Rc๋ ์ฐ๋ ๋์ ๊ฐ์ด ์ฌ์ฉํ ์ ์๋ค๋ ๊ฒ์ ๋ณด์ฌ์ค๋ค.
thread safe๊ฐ ๋๊ธฐ ์ํด์๋ Send, Sync ๋๊ฐ๋ค ๊ฐ์ ธ์ผ ํ๋ค
์์ ๊ฐ์ด RefCell์ ๊ฒฝ์ฐ๋ Send๋ ์์ง๋ง Sync๋ ์์ผ๋ฏ๋ก thread safe ๊ฐ ์๋
Arc , Mutex ๊ฐ์ด ์ฌ์ฉํ๊ธฐ
์ ์๋ํ๋ ์ฝ๋ (๋จ ํ์ดํฌ Arc::new(Mutex::new(0))์์ย Mutex ๊ฐ ์๋๊ณ RwLock์ด)
Arc, RwLock ๊ฐ์ด ์ฌ์ฉํ ๊ฒฝ์ฐย
closure
refs_it ์์ ์ฌ์ฉ๋๊ฒฝ์ฐ๋ย borrow ๋ฐฉ๋ฒ (Fn ๋ฐฉ๋ฒ) my_string์ด closure์์์ ๊ฐ์ด ๋ณํ๋์ง๋ ์์๊ธฐ ๋๋ฌธ
mutes_it ์์ ์ฌ์ฉ๋ ๊ฒฝ์ฐ๋ FnMut ๋ฐฉ๋ฒ ์ด๋ค.ย my_string์ด closure์์์ ๊ฐ์ด ๋ณํ๋์ ๋๋ฌธ
์ ๋ง๋ ์ฝ๋ ๋จ( ํ์ดํฌย cool_book.year % 2 == 0 )
impl trait
์ ์ ์๋๋ ๊ฐ์ ํจ๊ณผ
Box
์ array๋ ์คํ์ ๋ง๋ค์ด์ง๊ธฐ ๋๋ฌธ์ ๋น ๋ฅด์ง๋ง ์์ ๊ฐ์ด ๋์ฉ๋ ์ฌ์ฉ์ด ๋ถ๊ฐ๋ฅํ๋ค ๊ทธ๋์ย box๋ฅผ ์ด์ฉํด heap ๋์ฉ๋ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ์ ์๋ค
์์ ๊ฐ์ด ์ฌ์ฉํ ์ ์์๊ฒ ๊ฐ์ง๋ง ์ฌ์ค์ ์๋๋ค. ์๋ํ๋ฉด ๋ฐ์ดํฐ๋ฅผ ์คํ์ ๋จผ์ ๋ง๋ค๊ณ ๊ทธ๊ฒ์ ๋ณต์ฌํด์ heap์ ๋ง๋ค๊ธฐ ๋๋ฌธ์ด๋ค
๊ทธ๋์ ์๋๊ฐ ๋ง๋ ๋ฐฉ๋ฒ์ด๋ค
box๋ ํฌ์ธํฐ๋ฅผ ์คํ์ ์ ์ฅํ๊ณ ๋ฐ์ดํฐ๋ ํ์ ์ ์ฅํ๋ฏ๋ก
๋ชจ๋ box์ ์ฌ์ด์ฆ๋ 8 ๋ฐ์ดํธ๋ก ๊ฐ๋ค
box์ ๊ฐ์ ์ ๊ทผํด์ ์์ ํ๋ ๊ฒฝ์ฐ ํฌ์ธํฐ์ ๊ฐ์ด * operator๋ฅผ ์ด์ฉํ๋ค
dyn
channel
์ ํ์ T ๊ฐ ๋ช ์ ๋์ง ์์๊ธฐ ๋๋ฌธ์ ํจ๋
์๋ ํ์ T๊ฐ ์ ํด์ก์ผ๋ฏ๋ก ํจ๋ํ์ง ์์
RUST
https://youtu.be/m76sRj2VgGo
pointer
1. reference
๋จ์ํ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์๋ฅผ ๊ฐ์ง๋ค (๊ฐ์ ๋น๋ ค์ด)
2. smart pointer
pointer ์ฒ๋ผ ํ๋ํ๋ ๋ฐ์ดํฐ ์คํธ๋ญ์ณ์ด๋ฉฐ ์ถ๊ฐ์ ์ธ ๋ฉํ๋ฐ์ดํฐ, ๊ธฐ๋ฅ์ ๊ฐ์ง๊ณ ์๋ค. ์ค์ ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ง๊ณ ์๋ค. String, Vector๊ฐ ์ค๋งํธ ํฌ์ธํฐ์ ์ข ๋ฅ์ด๋ค
๋ณดํต deref, drop trait์ implementing ํ๋ค
์ ํ๋ฆฐ ์ฝ๋
์ ๋ง๋ ์ฝ๋ ์์ฑ์ค
https://youtu.be/dYEC6NElVOg
์ ๋ง๋ ์ฝ๋
์ ํ๋ฆฐ์ฝ๋ (๋ง์ง๋ง ๋ถ๋ถ)
์ ๋ง๋ ์ฝ๋
Deref
์ ํ๋ฆฐ ์ฝ๋ Deref trait์ implement ํด์ผ ํ๋ค
์ ์ค์ ๋ก ์๋ํ๋ ๋ด์ฉ์ ์์ธํ๊ฒ ๋ณด์ฌ์ค. ์ฌ์ค ์ปดํ์ผ๋ฌ๊ฐ ์ค์ฌ์ *y ๋ง์ผ๋ก๋ ์๋ํ๊ฒ ๋์์ค๋ค
&String => &str ๋ก ์๋ ๋ณํ๋๋ค. deref coercian ์ด๋ผ๊ณ ํ๊ณ ๊ท์น์ ์๋์ ๊ฐ๋ค. mutable type์ derefํ๋ ค๋ ๊ฒฝ์ฐ๋ DerefMut์ ์ฌ์ฉํ๋ค
Drop
https://youtu.be/RPWZcTYBS4k
smart pointer ๋ Deref , Drop trait์ implement ํด์ผํ๋ค.
์๋๋ Drop trait implementingํ๋ ๋ฒ์ ๋ณด์ฌ์ฃผ๊ณ ์๋ค.
์๋์ ๊ฐ์ด smart pointer struct๋ฅผ ํตํด drop์ ํธ์ถํ๋ ๊ฒ์ ๊ธ์งย
standard library์ drop์ ํตํด memory์์ ์์ ๋ ๊ฒ์ ๊ฐ
Rc
https://youtu.be/M9Owp3iLigg
์๋ ํ๋ฒ a์ ์ค๋์ฝ์ด Box::new()์ ์ ๋ฌ๋์๋๋ฐ ๋ฐ์์ ๋ ์ฌ์ฉํ๋ ค๊ณ ํ๊ธฐ ๋๋ฌธ์ ์๋ชป๋ ์ฝ๋
์๋ ์ฌ๋ฐ๋ฅธ ์ฝ๋
์๋ ์ฝ๊ฐ ๋ณํ๋ ํํ๋ก ๋๊ฐ์ ํจ๊ณผ๋ฅผ ๊ฐ์ง๋ค
์๋๋ ๊ฒฐ๊ณผ
interior mutability
https://youtu.be/77aRH6YBKyY
์์์ &mut a;๊ฐ ์๋ชป๋ ์ด์ ๋ ์ ์ด์ a๋ immutable์ด๊ธฐ ๋๋ฌธ์ด๋ค
์์์*d = 20;์ด ์๋ชป๋ ์ด์ ๋ ์ ์ด์ &mut์ผ๋ก ํ์ง ์์๊ธฐ ๋๋ฌธ์ด๋ค
RUST 113-121 in english
type, use, as
์๋ ์ถ์ฝ์
์๋๋ type , use ๋ฅผ ์ฌ์ฉํด์ ์ค์ธ ์ฝ๋
todo!
์ ์๋ฌ ๋ฐ์
์ ์๋ ์ํจ
unimplemented ์ ๊ฐ์ ํจ๊ณผ todo
Rc
์ struct์ impl ๋ ํจ์์ ๊ฒฝ์ฐ ๋ง์น Class ํจ์์ฒ๋ผ ์ ๊ทผ๋ ๊ฐ๋ฅํ๋ค
์ Rc , RefCell ๋ฅผ ๊ฐ์ด ์ฌ์ฉํ ๊ฒฝ์ฐ
thread
์์ ๊ฒฝ์ฐ mainํจ์๊ฐ ๋๊ฐ์ thread ๊ฐ ์์ ์ ๋๋ผ๋ ๊น์ง ๊ธฐ๋ค๋ฆฌ์ง ์๊ณ ย
ํจ์ ๋์ ๋๋ฌํ๋ฉด ํ๋ก๊ทธ๋จ์ ๋ฉ์ถ๊ฒ ๋๋ค
join ์ ํตํด thread ์์ ์ด ๋ง๋ฌด๋ฆฌ ๋ ๋ ๊น์ง ๊ธฐ๋ค๋ฆฐ
์์ฐจ์ ์ผ๋ก ์ฐ๋ ๋๊ฐ ๋๋๋๊ฑธ ๋ณด๋ฉด ์ง์ ํ concurrency ๊ฐ ์๋๋ค
์ concurrency
RUST runtime
https://youtu.be/1QoT9fmPYr8
๋ง๋ ์ฝ๋ ์ค๋์ฝ์ ๋๊ฒจ์ฃผ๊ณ { }์ด ๋๋ฌ๊ธฐ ๋๋ฌธ์ ๋ฌธ์ ์์
ํ๋ฆฐ ์ฝ๋ { } ์์์ b ๊ฐ ๋๋๊ณ ์์ด์ง๋ฏ๋ก garbage reference๋ฅผ ๊ฐ์ง๊ฒ ๋๋ค
ํจ์์์์ ๋ง๋ค์ด์ง a ๋ ํจ์์์์ ์ฌ๋ผ์ง๋๋ฐ ์ด๋ฅผ reference๋ก ๋๊ฒจ์คฌ๊ธฐ ๋๋ฌธ์ ๋ฌธ์
์ธ๋ถย scope์ lifetime์ ๊ฐ์ง๊ณ ์๋ ๊ฒ์ ๋ฐ์์ ๋ค์ ๋๋ ค ์คฌ๊ธฐ ๋๋ฌธ์ ๋ฌธ์ ์๋ค. ์ด์ ๋๋ <โa>๊ฐ ์์ด๋ compiler๊ฐ ์์์ ์ฒ๋ฆฌ ํ๋ค
๋ง๋ ์ฝ๋
์ ๋ฌธ์ ์์
์ ๋ฌธ์ ์์ ํจ์ ๋ฆฌํด๊ฐ์ด &โa i32์ด๊ณ param_1 ์๋ง ํด๋นํ๊ณ param_2๋ ๋ฆฌํด๊ฐ๊ณผ ์ฐ๊ด์ฑ์ด ์์ผ๋ฏ๋ก lifetime์ง์ ํ์ง ์์๋ ๋๋ค
๋ฆฌํด๊ฐ์ด ์ด๋ค๊ฐ ๋ ์ง ๋ชจ๋ฅด์ง๋ง ์ต์ํย โa lifetime์ ๊ฐ์ง๋ค๊ณ ํํํ๊ฒฝ์ฐ (โb:โa ๋ป์ b lifetime์ด a lifetime๋ณด๋ค ๊ธธ๋ค๋ ๋ป ์ฆ ์ต์ํ a lifetime์ ๋๋ค๋ ๋ป)
์ด๋ฐ๊ฒฝ์ฐ๋ ํ์น ์๊ณ ์๋์ ๊ฐ์ด ๊ฐ์ lifetime์ธ ๊ฒฝ์ฐ๊ฐ ๋ณดํต์ด๋ค
์์์ ์ฒซ๋ฒ์งธ, ๋๋ฒ์งธ๋ ๋ง๋ ์ฝ๋
์ธ๋ฒ์งธ๋ ํ๋ฆฐ ์์ reference๋ก ๋ฐ์ ๊ฒ ์๊ณ ์ค๋์ญ๊ณผ ํจ๊ป ๋ฐ์ ํ๋ผ๋ฏธํฐ๋ ํจ์๊ฐ ๋๋๋ฉด ์ฌ๋ผ์ง๋๋ฐ ์ด๊ฑธ reference๋ก ๋๊ฒจ์ฃผ๋ฉด garbage reference ๊ฐ ๋๋ค
์ ๋ง๋ ์ฝ๋
์ ๋ง๋ ์ฝ๋
์ ๋ง๋์ฝ๋
๋ง๋ ์ฝ๋

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch โข No registration required โข HD streaming
RUST 100-112 in english
lifetime
์์์ my_string์ lifetime specifier๊ฐ ์ค์ ๋์ด์์ง ์์์ ๋ฌธ์
static์ผ๋ก lifetime์ผ๋ก ํด๋ my_string์ ํจ์๋ด์์๋ง ์กด์ฌํ๋ฏ๋ก ๋ฌธ์ ๋ฐ์
์๋ ์๋ํ๋ ์ฝ๋
์๋ ์๋ํ๋ ์ฝ๋
์๋ ์๋ํ์ง ์๋ ์ฝ๋
1 ๊ฐ๊ฐ์ ํ๋ผ๋ฏธํฐ๋ ๊ฐ๊ฐ์ lifetime์ ๊ฐ์ง๋ ๋ณดํต์ ํ๋๋ก ํต์ผํด์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค
2. ํ๋ผ๋ฏธํฐ๊ฐ ํ๋๊ณ reference ๋ฆฌํด์ด ํ๋ ์๋ ๊ฒฝ์ฐ. ํ๋์ lifetime์ผ๋ก ์ปดํ์ผ๋ฌ๊ฐ ๊ฐ์ฃผ ์ฒ๋ฆฌํ๋ค
3. ์ฌ๋ฌ ํ๋ผ๋ฏธํฐ์ค &self , &mut self๊ฐ ์๋ ๊ฒฝ์ฐ lifetime self๊ฐ ์ ์ฉ๋ย
์ ํ๋ฆฐ ์ฝ๋
์ ๋ง๋ ์ฝ๋. ์๋์ ๊ฐ์ด ์ถ์ฝ๋ ๊ฐ๋ฅํ๋ค
anonymous lifetime
์ ๋ง๋ ์ฝ๋
์ ๋ง๋ ์ฝ๋
์ ๋ง๋ ์ฝ๋
interior mutability
์ ๋ง๋ ์ฝ๋
RefCell
์ ๋ง๋ ์ฝ๋
์ mutable reference๋ฅผ ๋๋ฒ borrowํ๋ ค๊ณ ํด์ ํจ๋
๊ทธ๋ฆฌ๊ณ Cell, RefCell์ ๋ฐํ์์์ ๋ค์ด๋๋ฏนํ๊ฒ ์ฒ๋ฆฌ๋๋ค
๋น๋ฆฐ reference๋ฅผ ํตํด์๋ ๊ฐ์ ๋ณผ์ ์์ง๋ง ๋น๋ ค์ง ์๋ ๋ณ์๋ฅผ ํตํด์๋ ๊ฐ์ ํ์ธํ ์ ์๋ ๊ฒ์ ์ ์
above , after drop we can see value through variable which was borrowed
์์ย drop์ ์ด์ฉํ๋ ๋ฐฉ๋ฒ์ด ๋ฒ๊ฑฐ๋ก์ด ๊ฒฝ์ฐ ์ ๊ฐ์ด ์ข๋ ๊ฐ๋จํ๊ฒ ์ฌ์ฉํ ์ ์๋ค
Cell์์ take๋ ๊ฐ์ takeํ๊ณ Cell์์ default ๊ฐ์ผ๋ก ๋จ๊ธฐ๋ ๊ฒ์ด
Mutex
Mutex๋ฅผ ํตํด interior mutability๋ฅผ ๊ตฌํํ ์ ์๋ค. Mutex์ thread์ ๊ฐ์ด ์ฌ์ฉํด๋ ์์ ํ๋ค. lock() ํ๋ฉด ๋ค๋ฅธ ๊ณณ์์ ์ ๊ทผ ๋ถ๊ฐํ๋ค
์ ํจ๋์ด ๋ฐ์ํ ๊ฒ์ผ๋ก ๋ณด์ด์ง๋ง ์ค์์ timeout์ด ๋๋ฒ๋ฆฐ๋ค.
์ฒ์ lockํ๊ณ ๋ค์์์ lockํ๋ ค๊ณ ๊ณ์ ๊ธฐ๋ค๋ฆฌ๊ฒ ๋๋ค
์ ์ฒซ๋ฒ์งธ lock์์ lock๋๊ณ try_lock()์์๋ ๊ฐ๋ณ๊ฒฝ์ด ์ด๋ฃจ์ด์ง์ง์๋๋ค
์ฒซ๋ฒ์งธ lock์ดํ drop์ด ๋๊ณ try_lock()์ด ์คํ๋๊ณ ๊ฐ์ด ๋ณ๊ฒฝ๋๊ณ ๋ณ์์ ์ ์ฅํ๊ฒ ์๋๋ฏ๋ก ์์ ํ ๋ฐ๋ก lock ์ด ํ๋ฆฐ๋ค. ๊ทธ๋ฆฌ๊ณ ์ถ๋ ฅํ๋ฉด lock๋ ์ํ๊ฐ ์๋๊ณ ๋ณ๊ฒฝ๋ ๊ฐ์ ๋ณ๊ฒฝ๋๊ฒ ์ถ๋ ฅ๋๋ค.
RwLockย
read write lock
์๋ Mutex๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ ์๋๋ RwLock์ ์ฌ์ฉํ ๊ฒฝ์ฐย
๋์ ๋งค์ฐ ๋น์ทํ๋ค
Cow
vector slice
RUST 89- in korean
inspect
&str
&str ๋ฅผ ๋ชป์ด๋ค. ์๋์ ๊ฐ์ด๋ ์ฌ์ฉํ ์ ์๋ค
lifetime
์์์ ์ฌ์ฉํ static ํ๋ฆฐ ์์
์๋ ๋ง๊ฒ ์ฌ์ฉํ ๊ฒฝ์ฐ
์๋ ํ๋ฆฌ๊ฒ ์ฌ์ฉํ ๊ฒฝ์ฐ
์๋ ๋ง๊ฒ ์ฌ์ฉํ ๊ฒฝ์ฐ
๋๊ฐ์ ๋ค๋ฅธ lifetime์ ์ด์ฉํ ์๋ ์์ง๋ง ์ด๋ฐ ๊ฒฝ์ฐ๋ ๋งค์ฐ ๋๋ฌผ๋ค
impl์ lifetime์ ์ค์ ํด ์ฃผ์ง ์์์ ํ๋ฆฐ ์์
Cell
Cell ์ thread safe ์๋(์ค๋ ๋์ ์ฌ์ฉ๋ถ๊ฐ)
Cell์ ์ด์ฉํ๋ฉด mut ์ง์ ์์ด๋ mutable๋ก ๋ง๋ค์ ์๋ค
https://doc.rust-lang.org/stable/std/cell/struct.Cell.html
cell์ copy trait์ impl ํ ํ์ ๊ณผ ์ฌ์ฉํ๋ฉด ๊ด์ฐฎ์ง๋ง ์๋๊ฒฝ์ฐย
์์ ๊ฐ์ด ์๋ฌ ๋ฐ์ํ๋ค.
String๊ฐ์ด copy ํ์ ์ด ์๋๊ฒฝ์ฐ ์๋์ ๊ฐ์ด RefCell์ ์ด์ฉํ ์์๋คย
RefCell
copy ํ์ ์ด๊ฑฐ๋ ์๋๊ฑฐ๋ ๋๋ค์ ์ฌ์ฉ๊ฐ๋ฅํ๋ค
reference์ ๊ฐ์ด ๋๊ตฐ๋ฐ์ borrowํ ์๋ ์๋ค
์ฒซ๋ฒ์งธ RefCell(true)
๋๋ฒ์งธ RefCell(borrowed)
์ธ๋ฒ์งธ RefCell(borrowed) - ์์ ๊ฐ์ ๋ฐ๋์์ง๋ง ์ํ๊ฐ borrowed์ด๋ค
๋ค๋ฒ์งธ RefCell(false)
Rc