File tree Expand file tree Collapse file tree 4 files changed +86
-0
lines changed
Expand file tree Collapse file tree 4 files changed +86
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ members = [
9595 " inodes/overlay/services" ,
9696 " rust/edenfs-asserted-states" ,
9797 " rust/edenfs-asserted-states-client" ,
98+ " rust/manifold_ffi" ,
9899 " rust/redirect_ffi" ,
99100 " service" ,
100101 " service/clients" ,
Original file line number Diff line number Diff line change 1+ load ("@fbsource//tools/build_defs:rust_library.bzl" , "rust_library" )
2+
3+ oncall ("scm_client_infra" )
4+
5+ rust_library (
6+ name = "manifold-ffi" ,
7+ srcs = glob (["src/**/*.rs" ]),
8+ crate_root = "src/lib.rs" ,
9+ cxx_bridge = "src/lib.rs" ,
10+ deps = [
11+ "fbsource//third-party/rust:anyhow" ,
12+ "fbsource//third-party/rust:cxx" ,
13+ "//common/rust/shed/fbinit:fbinit" ,
14+ "//eden/scm/lib/edenfs_ffi/cxxerror:cxxerror" ,
15+ "//scm/telemetry/corpmanifold:corpmanifold" ,
16+ ],
17+ )
Original file line number Diff line number Diff line change 1+ # @generated by autocargo from //eden/fs/rust/manifold_ffi:manifold-ffi
2+
3+ [package ]
4+ name = " manifold-ffi"
5+ version = " 0.1.0"
6+ authors = [" Facebook Source Control Team <sourcecontrol-dev@fb.com>" ]
7+ edition = " 2024"
8+ license = " GPLv2+"
9+
10+ [dependencies ]
11+ anyhow = " 1.0.102"
12+ cxx = " 1.0.119"
13+ cxxerror = { version = " 0.1.0" , path = " ../../../scm/lib/edenfs_ffi/cxxerror" }
14+ fbinit = { version = " 0.2.0" , git = " https://github.com/facebookexperimental/rust-shed.git" , branch = " main" }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ *
4+ * This software may be used and distributed according to the terms of the
5+ * GNU General Public License version 2.
6+ */
7+
8+ use anyhow:: Context ;
9+ use corpmanifold:: manifold:: ManifoldClient ;
10+ use corpmanifold:: manifold:: RequestContext ;
11+ use cxxerror:: Result ;
12+
13+ #[ cxx:: bridge( namespace = "facebook::eden" ) ]
14+ mod ffi {
15+ extern "Rust" {
16+ /// Upload content to a Manifold bucket.
17+ fn manifold_write (
18+ bucket : & str ,
19+ api_key : & str ,
20+ key : & str ,
21+ content : & [ u8 ] ,
22+ timeout_msec : i32 ,
23+ expiration_secs : u32 ,
24+ client_identity : & str ,
25+ ) -> Result < ( ) > ;
26+ }
27+ }
28+
29+ fn manifold_write (
30+ bucket : & str ,
31+ api_key : & str ,
32+ key : & str ,
33+ content : & [ u8 ] ,
34+ timeout_msec : i32 ,
35+ expiration_secs : u32 ,
36+ client_identity : & str ,
37+ ) -> Result < ( ) > {
38+ let client = ManifoldClient :: new (
39+ unsafe { fbinit:: assume_init ( ) } ,
40+ client_identity,
41+ RequestContext {
42+ bucket_name : bucket. to_owned ( ) ,
43+ api_key : api_key. to_owned ( ) ,
44+ timeout_msec,
45+ } ,
46+ )
47+ . with_context ( || format ! ( "Failed to create Manifold client for bucket {}" , bucket) ) ?;
48+
49+ client
50+ . write ( key. to_owned ( ) , content. to_vec ( ) , expiration_secs)
51+ . with_context ( || format ! ( "Failed to write key {} to Manifold bucket {}" , key, bucket) ) ?;
52+
53+ Ok ( ( ) )
54+ }
You can’t perform that action at this time.
0 commit comments