-
-
Notifications
You must be signed in to change notification settings - Fork 381
docs: add docs for more mbtiles functions #1849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,6 +68,20 @@ impl Display for Mbtiles { | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| impl Mbtiles { | ||||||||||||||||||||||||||||
| /// Creates a reference to an mbtiles file. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// This does not open the file, nor check if it exists. | ||||||||||||||||||||||||||||
| /// For this, please use the [`Mbtiles::open`], [`Mbtiles::open_or_new`] or [`Mbtiles::open_readonly`] method respectively. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # Errors | ||||||||||||||||||||||||||||
| /// Returns an error if the filepath contains unsupported characters. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # Examples | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| /// use mbtiles::Mbtiles; | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// let mbtiles = Mbtiles::new("example.mbtiles").unwrap(); | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| pub fn new<P: AsRef<Path>>(filepath: P) -> MbtResult<Self> { | ||||||||||||||||||||||||||||
| let path = filepath.as_ref(); | ||||||||||||||||||||||||||||
| Ok(Self { | ||||||||||||||||||||||||||||
|
|
@@ -83,12 +97,34 @@ impl Mbtiles { | |||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Opens the mbtiles file if it does exist. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # Examples | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| /// use mbtiles::Mbtiles; | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # async fn foo() { | ||||||||||||||||||||||||||||
| /// let mbtiles = Mbtiles::new("example.mbtiles").unwrap(); | ||||||||||||||||||||||||||||
| /// let conn = mbtiles.open().await.unwrap(); | ||||||||||||||||||||||||||||
| /// # } | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| pub async fn open(&self) -> MbtResult<SqliteConnection> { | ||||||||||||||||||||||||||||
| debug!("Opening w/ defaults {self}"); | ||||||||||||||||||||||||||||
| let opt = SqliteConnectOptions::new().filename(self.filepath()); | ||||||||||||||||||||||||||||
| Self::open_int(&opt).await | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Opens the mbtiles file or creates a new one if it doesn't exist. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # Examples | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| /// use mbtiles::Mbtiles; | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # async fn foo() { | ||||||||||||||||||||||||||||
| /// let mbtiles = Mbtiles::new("example.mbtiles").unwrap(); | ||||||||||||||||||||||||||||
| /// let conn = mbtiles.open_or_new().await.unwrap(); | ||||||||||||||||||||||||||||
| /// # } | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| pub async fn open_or_new(&self) -> MbtResult<SqliteConnection> { | ||||||||||||||||||||||||||||
| debug!("Opening or creating {self}"); | ||||||||||||||||||||||||||||
| let opt = SqliteConnectOptions::new() | ||||||||||||||||||||||||||||
|
|
@@ -97,6 +133,17 @@ impl Mbtiles { | |||||||||||||||||||||||||||
| Self::open_int(&opt).await | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Opens an existing mbtiles file in readonly mode. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # Examples | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| /// use mbtiles::Mbtiles; | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # async fn foo() { | ||||||||||||||||||||||||||||
| /// let mbtiles = Mbtiles::new("example.mbtiles").unwrap(); | ||||||||||||||||||||||||||||
| /// let conn = mbtiles.open_or_new().await.unwrap(); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| /// let conn = mbtiles.open_or_new().await.unwrap(); | |
| /// let conn = mbtiles.open_readonly().await.unwrap(); |
Copilot
AI
May 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Raw HTML in Rustdoc can be fragile; consider using Rustdoc admonition syntax (e.g., # Warning or > **Note:**) for better readability and tooling support.
| /// <div class="warning"> | |
| /// | |
| /// **Note:** The returned [`Stream`] holds a mutable reference to the given | |
| /// connection, making it unusable for anything else until the stream | |
| /// is dropped. | |
| /// | |
| /// </div> | |
| /// # Warning | |
| /// | |
| /// **Note:** The returned [`Stream`] holds a mutable reference to the given | |
| /// connection, making it unusable for anything else until the stream | |
| /// is dropped. | |
| /// |
Uh oh!
There was an error while loading. Please reload this page.