Paths
Account storage stores objects under paths. Paths consist of a domain and an identifier.
Paths start with the character /, followed by the domain, the path separator /, and finally the identifier. The identifier must start with a letter and can only be followed by letters, numbers, or the underscore _. For example, the path /storage/test has the domain storage and the identifier test.
There are two valid domains: storage and public.
Paths in the storage domain have type StoragePath, and paths in the public domain have the type PublicPath. Both StoragePath and PublicPath are subtypes of Path.
The storage domain stores storable objects, such as resources and structs. Objects stored under the storage domain are only accessible through account references, which are authorized with a storage entitlement.
The public domain stores capabilities, which are accessible by anyone.
Path functions
_10fun toString(): String
Returns the string representation of the path.
_10let storagePath = /storage/path_10_10storagePath.toString() // is "/storage/path"
There are also utilities to produce paths from strings:
_10fun PublicPath(identifier: string): PublicPath?_10fun StoragePath(identifier: string): StoragePath?
Each of these functions take an identifier and produce a path of the appropriate domain:
_10let pathID = "foo"_10let path = PublicPath(identifier: pathID) // is /public/foo