mononoke: implement FromStr for BookmarkName

Summary:
implement FromStr for BookmarkName, can use it to handle bookmarks
more uniformly with other types in the walker

Reviewed By: mitrandir77

Differential Revision: D24725786

fbshipit-source-id: e7eb7ece4a4bdc5dfd91f253f0383829c4ecc73b
This commit is contained in:
Alex Hornby 2020-11-13 05:21:34 -08:00 committed by Facebook GitHub Bot
parent 99cb9d4f9f
commit aaa2f671c4

View File

@ -19,6 +19,7 @@ use sql::mysql_async::{
use std::convert::TryFrom;
use std::fmt;
use std::ops::{Bound, Range, RangeBounds, RangeFrom, RangeFull};
use std::str::FromStr;
/// This enum represents how fresh you want results to be. MostRecent will go to the master, so you
/// normally don't want to issue queries using MostRecent unless you have a very good reason.
@ -103,6 +104,13 @@ pub struct BookmarkName {
bookmark: AsciiString,
}
impl FromStr for BookmarkName {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(BookmarkName::new(s)?)
}
}
impl fmt::Display for BookmarkName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.bookmark)